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