Annotation of embedaddon/php/ext/date/tests/gmstrftime_variation2.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test gmstrftime() function : usage variation - Passing unexpected values to second argument 'timestamp'.
        !             3: --SKIPIF--
        !             4: <?php
        !             5: if(PHP_INT_SIZE != 4 ) {
        !             6:   die("skip Test is not valid for 64-bit");
        !             7: }
        !             8: ?>
        !             9: --FILE--
        !            10: <?php
        !            11: /* Prototype  : string gmstrftime(string format [, int timestamp])
        !            12:  * Description: Format a GMT/UCT time/date according to locale settings 
        !            13:  * Source code: ext/date/php_date.c
        !            14:  * Alias to functions: 
        !            15:  */
        !            16: 
        !            17: echo "*** Testing gmstrftime() : usage variation ***\n";
        !            18: 
        !            19: date_default_timezone_set("Asia/Calcutta");
        !            20: 
        !            21: // Initialise function arguments not being substituted (if any)
        !            22: $format = '%b %d %Y %H:%M:%S';
        !            23: 
        !            24: //get an unset variable
        !            25: $unset_var = 10;
        !            26: unset ($unset_var);
        !            27: 
        !            28: // define some classes
        !            29: class classWithToString
        !            30: {
        !            31:        public function __toString() {
        !            32:                return "Class A object";
        !            33:        }
        !            34: }
        !            35: 
        !            36: class classWithoutToString
        !            37: {
        !            38: }
        !            39: 
        !            40: // heredoc string
        !            41: $heredoc = <<<EOT
        !            42: hello world
        !            43: EOT;
        !            44: 
        !            45: // add arrays
        !            46: $index_array = array (1, 2, 3);
        !            47: $assoc_array = array ('one' => 1, 'two' => 2);
        !            48: 
        !            49: //array of values to iterate over
        !            50: $inputs = array(
        !            51: 
        !            52:       // float data
        !            53:       'float 10.5' => 10.5,
        !            54:       'float -10.5' => -10.5,
        !            55:       'float 12.3456789000e10' => 12.3456789000e10,
        !            56:       'float -12.3456789000e10' => -12.3456789000e10,
        !            57:       'float .5' => .5,
        !            58: 
        !            59:       // array data
        !            60:       'empty array' => array(),
        !            61:       'int indexed array' => $index_array,
        !            62:       'associative array' => $assoc_array,
        !            63:       'nested arrays' => array('foo', $index_array, $assoc_array),
        !            64: 
        !            65:       // null data
        !            66:       'uppercase NULL' => NULL,
        !            67:       'lowercase null' => null,
        !            68: 
        !            69:       // boolean data
        !            70:       'lowercase true' => true,
        !            71:       'lowercase false' =>false,
        !            72:       'uppercase TRUE' =>TRUE,
        !            73:       'uppercase FALSE' =>FALSE,
        !            74: 
        !            75:       // empty data
        !            76:       'empty string DQ' => "",
        !            77:       'empty string SQ' => '',
        !            78: 
        !            79:       // string data
        !            80:       'string DQ' => "string",
        !            81:       'string SQ' => 'string',
        !            82:       'mixed case string' => "sTrInG",
        !            83:       'heredoc' => $heredoc,
        !            84: 
        !            85:       // object data
        !            86:       'instance of classWithToString' => new classWithToString(),
        !            87:       'instance of classWithoutToString' => new classWithoutToString(),
        !            88: 
        !            89:       // undefined data
        !            90:       'undefined var' => @$undefined_var,
        !            91: 
        !            92:       // unset data
        !            93:       'unset var' => @$unset_var,
        !            94: );
        !            95: 
        !            96: // loop through each element of the array for timestamp
        !            97: 
        !            98: foreach($inputs as $key =>$value) {
        !            99:       echo "\n--$key--\n";
        !           100:       var_dump( gmstrftime($format, $value) );
        !           101: };
        !           102: 
        !           103: ?>
        !           104: ===DONE===
        !           105: --EXPECTF--
        !           106: *** Testing gmstrftime() : usage variation ***
        !           107: 
        !           108: --float 10.5--
        !           109: string(20) "Jan 01 1970 00:00:10"
        !           110: 
        !           111: --float -10.5--
        !           112: string(20) "Dec 31 1969 23:59:50"
        !           113: 
        !           114: --float 12.3456789000e10--
        !           115: string(20) "Mar 26 1935 04:50:16"
        !           116: 
        !           117: --float -12.3456789000e10--
        !           118: string(20) "Oct 08 2004 19:09:44"
        !           119: 
        !           120: --float .5--
        !           121: string(20) "Jan 01 1970 00:00:00"
        !           122: 
        !           123: --empty array--
        !           124: 
        !           125: Warning: gmstrftime() expects parameter 2 to be long, array given in %s on line %d
        !           126: bool(false)
        !           127: 
        !           128: --int indexed array--
        !           129: 
        !           130: Warning: gmstrftime() expects parameter 2 to be long, array given in %s on line %d
        !           131: bool(false)
        !           132: 
        !           133: --associative array--
        !           134: 
        !           135: Warning: gmstrftime() expects parameter 2 to be long, array given in %s on line %d
        !           136: bool(false)
        !           137: 
        !           138: --nested arrays--
        !           139: 
        !           140: Warning: gmstrftime() expects parameter 2 to be long, array given in %s on line %d
        !           141: bool(false)
        !           142: 
        !           143: --uppercase NULL--
        !           144: string(20) "Jan 01 1970 00:00:00"
        !           145: 
        !           146: --lowercase null--
        !           147: string(20) "Jan 01 1970 00:00:00"
        !           148: 
        !           149: --lowercase true--
        !           150: string(20) "Jan 01 1970 00:00:01"
        !           151: 
        !           152: --lowercase false--
        !           153: string(20) "Jan 01 1970 00:00:00"
        !           154: 
        !           155: --uppercase TRUE--
        !           156: string(20) "Jan 01 1970 00:00:01"
        !           157: 
        !           158: --uppercase FALSE--
        !           159: string(20) "Jan 01 1970 00:00:00"
        !           160: 
        !           161: --empty string DQ--
        !           162: 
        !           163: Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d
        !           164: bool(false)
        !           165: 
        !           166: --empty string SQ--
        !           167: 
        !           168: Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d
        !           169: bool(false)
        !           170: 
        !           171: --string DQ--
        !           172: 
        !           173: Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d
        !           174: bool(false)
        !           175: 
        !           176: --string SQ--
        !           177: 
        !           178: Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d
        !           179: bool(false)
        !           180: 
        !           181: --mixed case string--
        !           182: 
        !           183: Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d
        !           184: bool(false)
        !           185: 
        !           186: --heredoc--
        !           187: 
        !           188: Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d
        !           189: bool(false)
        !           190: 
        !           191: --instance of classWithToString--
        !           192: 
        !           193: Warning: gmstrftime() expects parameter 2 to be long, object given in %s on line %d
        !           194: bool(false)
        !           195: 
        !           196: --instance of classWithoutToString--
        !           197: 
        !           198: Warning: gmstrftime() expects parameter 2 to be long, object given in %s on line %d
        !           199: bool(false)
        !           200: 
        !           201: --undefined var--
        !           202: string(20) "Jan 01 1970 00:00:00"
        !           203: 
        !           204: --unset var--
        !           205: string(20) "Jan 01 1970 00:00:00"
        !           206: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>