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

1.1     ! misho       1: --TEST--
        !             2: Test date() function : usage variation - Passing unexpected values to first argument $format.
        !             3: --FILE--
        !             4: <?php
        !             5: /* Prototype  : string date  ( string $format  [, int $timestamp  ] )
        !             6:  * Description: Format a local time/date.
        !             7:  * Source code: ext/date/php_date.c
        !             8:  */
        !             9: 
        !            10: echo "*** Testing date() : usage variation -  unexpected values to first argument \$format***\n";
        !            11: 
        !            12: //Set the default time zone 
        !            13: date_default_timezone_set("Europe/London");
        !            14: 
        !            15: //get an unset variable
        !            16: $unset_var = 10;
        !            17: unset ($unset_var);
        !            18: 
        !            19: // define some classes
        !            20: class classWithToString
        !            21: {
        !            22:        public function __toString() {
        !            23:                return "Class A object";
        !            24:        }
        !            25: }
        !            26: 
        !            27: class classWithoutToString
        !            28: {
        !            29: }
        !            30: 
        !            31: // heredoc string
        !            32: $heredoc = <<<EOT
        !            33: hello world
        !            34: EOT;
        !            35: 
        !            36: // add arrays
        !            37: $index_array = array (1, 2, 3);
        !            38: $assoc_array = array ('one' => 1, 'two' => 2);
        !            39: 
        !            40: // resource
        !            41: $file_handle = fopen(__FILE__, 'r');
        !            42: 
        !            43: //array of values to iterate over
        !            44: $inputs = array(
        !            45: 
        !            46:       // int data
        !            47:       'int 0' => 0,
        !            48:       'int 1' => 1,
        !            49:       'int 12345' => 12345,
        !            50:       'int -12345' => -12345,
        !            51: 
        !            52:       // float data
        !            53:       'float 10.5' => 10.5,
        !            54:       'float -10.5' => -10.5,
        !            55:       'float .5' => .5,
        !            56: 
        !            57:       // array data
        !            58:       'empty array' => array(),
        !            59:       'int indexed array' => $index_array,
        !            60:       'associative array' => $assoc_array,
        !            61:       'nested arrays' => array('foo', $index_array, $assoc_array),
        !            62: 
        !            63:       // null data
        !            64:       'uppercase NULL' => NULL,
        !            65:       'lowercase null' => null,
        !            66: 
        !            67:       // boolean data
        !            68:       'lowercase true' => true,
        !            69:       'lowercase false' =>false,
        !            70:       'uppercase TRUE' =>TRUE,
        !            71:       'uppercase FALSE' =>FALSE,
        !            72: 
        !            73:       // empty data
        !            74:       'empty string DQ' => "",
        !            75:       'empty string SQ' => '',
        !            76: 
        !            77:       // string data
        !            78:       'string DQ' => "string",
        !            79:       'string SQ' => 'string',
        !            80:       'mixed case string' => "sTrInG",
        !            81:       'heredoc' => $heredoc,
        !            82: 
        !            83:       // object data
        !            84:       'instance of classWithToString' => new classWithToString(),
        !            85:       'instance of classWithoutToString' => new classWithoutToString(),
        !            86: 
        !            87:       // undefined data
        !            88:       'undefined var' => @$undefined_var,
        !            89: 
        !            90:       // unset data
        !            91:       'unset var' => @$unset_var,
        !            92:       
        !            93:       // resource 
        !            94:       'resource' => $file_handle
        !            95: );
        !            96: 
        !            97: $timestamp = mktime(10, 44, 30, 2, 27, 2009);
        !            98: 
        !            99: foreach($inputs as $variation =>$format) {
        !           100:       echo "\n-- $variation --\n";
        !           101:       var_dump( date($format, $timestamp) );
        !           102: };
        !           103: 
        !           104: // closing the resource
        !           105: fclose( $file_handle );
        !           106: 
        !           107: ?>
        !           108: ===DONE===
        !           109: --EXPECTF--
        !           110: *** Testing date() : usage variation -  unexpected values to first argument $format***
        !           111: 
        !           112: -- int 0 --
        !           113: string(1) "0"
        !           114: 
        !           115: -- int 1 --
        !           116: string(1) "1"
        !           117: 
        !           118: -- int 12345 --
        !           119: string(5) "12345"
        !           120: 
        !           121: -- int -12345 --
        !           122: string(6) "-12345"
        !           123: 
        !           124: -- float 10.5 --
        !           125: string(4) "10.5"
        !           126: 
        !           127: -- float -10.5 --
        !           128: string(5) "-10.5"
        !           129: 
        !           130: -- float .5 --
        !           131: string(3) "0.5"
        !           132: 
        !           133: -- empty array --
        !           134: 
        !           135: Warning: date() expects parameter 1 to be string, array given in %s on line %d
        !           136: bool(false)
        !           137: 
        !           138: -- int indexed array --
        !           139: 
        !           140: Warning: date() expects parameter 1 to be string, array given in %s on line %d
        !           141: bool(false)
        !           142: 
        !           143: -- associative array --
        !           144: 
        !           145: Warning: date() expects parameter 1 to be string, array given in %s on line %d
        !           146: bool(false)
        !           147: 
        !           148: -- nested arrays --
        !           149: 
        !           150: Warning: date() expects parameter 1 to be string, array given in %s on line %d
        !           151: bool(false)
        !           152: 
        !           153: -- uppercase NULL --
        !           154: string(0) ""
        !           155: 
        !           156: -- lowercase null --
        !           157: string(0) ""
        !           158: 
        !           159: -- lowercase true --
        !           160: string(1) "1"
        !           161: 
        !           162: -- lowercase false --
        !           163: string(0) ""
        !           164: 
        !           165: -- uppercase TRUE --
        !           166: string(1) "1"
        !           167: 
        !           168: -- uppercase FALSE --
        !           169: string(0) ""
        !           170: 
        !           171: -- empty string DQ --
        !           172: string(0) ""
        !           173: 
        !           174: -- empty string SQ --
        !           175: string(0) ""
        !           176: 
        !           177: -- string DQ --
        !           178: string(40) "3028Fri, 27 Feb 2009 10:44:30 +000044210"
        !           179: 
        !           180: -- string SQ --
        !           181: string(40) "3028Fri, 27 Feb 2009 10:44:30 +000044210"
        !           182: 
        !           183: -- mixed case string --
        !           184: string(40) "30GMTFri, 27 Feb 2009 10:44:30 +00000210"
        !           185: 
        !           186: -- heredoc --
        !           187: string(76) "10Europe/LondonFridayFriday2009 52009Fri, 27 Feb 2009 10:44:30 +0000Friday27"
        !           188: 
        !           189: -- instance of classWithToString --
        !           190: string(64) "CFridayam3030 AM 2009b27Europe/London2009-02-27T10:44:30+00:0028"
        !           191: 
        !           192: -- instance of classWithoutToString --
        !           193: 
        !           194: Warning: date() expects parameter 1 to be string, object given in %s on line %d
        !           195: bool(false)
        !           196: 
        !           197: -- undefined var --
        !           198: string(0) ""
        !           199: 
        !           200: -- unset var --
        !           201: string(0) ""
        !           202: 
        !           203: -- resource --
        !           204: 
        !           205: Warning: date() expects parameter 1 to be string, resource given in %s on line %d
        !           206: bool(false)
        !           207: ===DONE===
        !           208: 

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