Annotation of embedaddon/php/ext/date/tests/mktime_variation2.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test mktime() function : usage variation - Passing unexpected values to second argument $minute.
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : int mktime  ([ int $hour= date("H")  [, int $minute= date("i")  [, int $second= date("s")  [, int $month= date("n")  [, int $day= date("j")  [, int $year= date("Y")  [, int $is_dst= -1  ]]]]]]] )
                      6:  * Description: Get Unix timestamp for a date
                      7:  * Source code: ext/date/php_date.c
                      8:  * Alias to functions: 
                      9:  */
                     10: 
                     11: echo "*** Testing mktime() : usage variation -  unexpected values to second argument \$minute***\n";
                     12: 
                     13: //Set the default time zone 
                     14: date_default_timezone_set("Europe/London");
                     15: 
                     16: //get an unset variable
                     17: $unset_var = 10;
                     18: unset ($unset_var);
                     19: 
                     20: // define some classes
                     21: class classWithToString
                     22: {
                     23:        public function __toString() {
                     24:                return "Class A object";
                     25:        }
                     26: }
                     27: 
                     28: class classWithoutToString
                     29: {
                     30: }
                     31: 
                     32: // heredoc string
                     33: $heredoc = <<<EOT
                     34: hello world
                     35: EOT;
                     36: 
                     37: // add arrays
                     38: $index_array = array (1, 2, 3);
                     39: $assoc_array = array ('one' => 1, 'two' => 2);
                     40: 
                     41: // resource
                     42: $file_handle = fopen(__FILE__, 'r');
                     43: 
                     44: //array of values to iterate over
                     45: $inputs = array(
                     46: 
                     47:       // int data
                     48:       'int 0' => 0,
                     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: $hour = 10;
                     98: 
                     99: foreach($inputs as $variation =>$minute) {
                    100:       echo "\n-- $variation --\n";
                    101:       var_dump( mktime($hour, $minute) );
                    102: };
                    103: 
                    104: // closing the resource
                    105: fclose( $file_handle );
                    106: 
                    107: ?>
                    108: ===DONE===
                    109: --EXPECTF--
                    110: *** Testing mktime() : usage variation -  unexpected values to second argument $minute***
                    111: 
                    112: -- int 0 --
                    113: int(%i)
                    114: 
                    115: -- int 12345 --
                    116: int(%i)
                    117: 
                    118: -- int -12345 --
                    119: int(%i)
                    120: 
                    121: -- float 10.5 --
                    122: int(%i)
                    123: 
                    124: -- float -10.5 --
                    125: int(%i)
                    126: 
                    127: -- float .5 --
                    128: int(%i)
                    129: 
                    130: -- empty array --
                    131: 
                    132: Warning: mktime() expects parameter 2 to be long, array given in %s on line %d
                    133: bool(false)
                    134: 
                    135: -- int indexed array --
                    136: 
                    137: Warning: mktime() expects parameter 2 to be long, array given in %s on line %d
                    138: bool(false)
                    139: 
                    140: -- associative array --
                    141: 
                    142: Warning: mktime() expects parameter 2 to be long, array given in %s on line %d
                    143: bool(false)
                    144: 
                    145: -- nested arrays --
                    146: 
                    147: Warning: mktime() expects parameter 2 to be long, array given in %s on line %d
                    148: bool(false)
                    149: 
                    150: -- uppercase NULL --
                    151: int(%i)
                    152: 
                    153: -- lowercase null --
                    154: int(%i)
                    155: 
                    156: -- lowercase true --
                    157: int(%i)
                    158: 
                    159: -- lowercase false --
                    160: int(%i)
                    161: 
                    162: -- uppercase TRUE --
                    163: int(%i)
                    164: 
                    165: -- uppercase FALSE --
                    166: int(%i)
                    167: 
                    168: -- empty string DQ --
                    169: 
                    170: Warning: mktime() expects parameter 2 to be long, string given in %s on line %d
                    171: bool(false)
                    172: 
                    173: -- empty string SQ --
                    174: 
                    175: Warning: mktime() expects parameter 2 to be long, string given in %s on line %d
                    176: bool(false)
                    177: 
                    178: -- string DQ --
                    179: 
                    180: Warning: mktime() expects parameter 2 to be long, string given in %s on line %d
                    181: bool(false)
                    182: 
                    183: -- string SQ --
                    184: 
                    185: Warning: mktime() expects parameter 2 to be long, string given in %s on line %d
                    186: bool(false)
                    187: 
                    188: -- mixed case string --
                    189: 
                    190: Warning: mktime() expects parameter 2 to be long, string given in %s on line %d
                    191: bool(false)
                    192: 
                    193: -- heredoc --
                    194: 
                    195: Warning: mktime() expects parameter 2 to be long, string given in %s on line %d
                    196: bool(false)
                    197: 
                    198: -- instance of classWithToString --
                    199: 
                    200: Warning: mktime() expects parameter 2 to be long, object given in %s on line %d
                    201: bool(false)
                    202: 
                    203: -- instance of classWithoutToString --
                    204: 
                    205: Warning: mktime() expects parameter 2 to be long, object given in %s on line %d
                    206: bool(false)
                    207: 
                    208: -- undefined var --
                    209: int(%i)
                    210: 
                    211: -- unset var --
                    212: int(%i)
                    213: 
                    214: -- resource --
                    215: 
                    216: Warning: mktime() expects parameter 2 to be long, resource given in %s on line %d
                    217: bool(false)
                    218: ===DONE===

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