mktime_variation2.phpt 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. echo "*** Testing mktime() : usage variation - unexpected values to second argument \$minute***\n";
  11. //Set the default time zone
  12. date_default_timezone_set("Europe/London");
  13. //get an unset variable
  14. $unset_var = 10;
  15. unset ($unset_var);
  16. // define some classes
  17. class classWithToString
  18. {
  19. public function __toString() {
  20. return "Class A object";
  21. }
  22. }
  23. class classWithoutToString
  24. {
  25. }
  26. // heredoc string
  27. $heredoc = <<<EOT
  28. hello world
  29. EOT;
  30. // add arrays
  31. $index_array = array (1, 2, 3);
  32. $assoc_array = array ('one' => 1, 'two' => 2);
  33. // resource
  34. $file_handle = fopen(__FILE__, 'r');
  35. //array of values to iterate over
  36. $inputs = array(
  37. // int data
  38. 'int 0' => 0,
  39. 'int 12345' => 12345,
  40. 'int -12345' => -12345,
  41. // float data
  42. 'float 10.5' => 10.5,
  43. 'float -10.5' => -10.5,
  44. 'float .5' => .5,
  45. // array data
  46. 'empty array' => array(),
  47. 'int indexed array' => $index_array,
  48. 'associative array' => $assoc_array,
  49. 'nested arrays' => array('foo', $index_array, $assoc_array),
  50. // null data
  51. 'uppercase NULL' => NULL,
  52. 'lowercase null' => null,
  53. // boolean data
  54. 'lowercase true' => true,
  55. 'lowercase false' =>false,
  56. 'uppercase TRUE' =>TRUE,
  57. 'uppercase FALSE' =>FALSE,
  58. // empty data
  59. 'empty string DQ' => "",
  60. 'empty string SQ' => '',
  61. // string data
  62. 'string DQ' => "string",
  63. 'string SQ' => 'string',
  64. 'mixed case string' => "sTrInG",
  65. 'heredoc' => $heredoc,
  66. // object data
  67. 'instance of classWithToString' => new classWithToString(),
  68. 'instance of classWithoutToString' => new classWithoutToString(),
  69. // undefined data
  70. 'undefined var' => @$undefined_var,
  71. // unset data
  72. 'unset var' => @$unset_var,
  73. // resource
  74. 'resource' => $file_handle
  75. );
  76. $hour = 10;
  77. foreach($inputs as $variation =>$minute) {
  78. echo "\n-- $variation --\n";
  79. var_dump( mktime($hour, $minute) );
  80. };
  81. // closing the resource
  82. fclose( $file_handle );
  83. ?>
  84. ===DONE===
  85. --EXPECTF--
  86. *** Testing mktime() : usage variation - unexpected values to second argument $minute***
  87. -- int 0 --
  88. int(%i)
  89. -- int 12345 --
  90. int(%i)
  91. -- int -12345 --
  92. int(%i)
  93. -- float 10.5 --
  94. int(%i)
  95. -- float -10.5 --
  96. int(%i)
  97. -- float .5 --
  98. int(%i)
  99. -- empty array --
  100. Warning: mktime() expects parameter 2 to be long, array given in %s on line %d
  101. bool(false)
  102. -- int indexed array --
  103. Warning: mktime() expects parameter 2 to be long, array given in %s on line %d
  104. bool(false)
  105. -- associative array --
  106. Warning: mktime() expects parameter 2 to be long, array given in %s on line %d
  107. bool(false)
  108. -- nested arrays --
  109. Warning: mktime() expects parameter 2 to be long, array given in %s on line %d
  110. bool(false)
  111. -- uppercase NULL --
  112. int(%i)
  113. -- lowercase null --
  114. int(%i)
  115. -- lowercase true --
  116. int(%i)
  117. -- lowercase false --
  118. int(%i)
  119. -- uppercase TRUE --
  120. int(%i)
  121. -- uppercase FALSE --
  122. int(%i)
  123. -- empty string DQ --
  124. Warning: mktime() expects parameter 2 to be long, string given in %s on line %d
  125. bool(false)
  126. -- empty string SQ --
  127. Warning: mktime() expects parameter 2 to be long, string given in %s on line %d
  128. bool(false)
  129. -- string DQ --
  130. Warning: mktime() expects parameter 2 to be long, string given in %s on line %d
  131. bool(false)
  132. -- string SQ --
  133. Warning: mktime() expects parameter 2 to be long, string given in %s on line %d
  134. bool(false)
  135. -- mixed case string --
  136. Warning: mktime() expects parameter 2 to be long, string given in %s on line %d
  137. bool(false)
  138. -- heredoc --
  139. Warning: mktime() expects parameter 2 to be long, string given in %s on line %d
  140. bool(false)
  141. -- instance of classWithToString --
  142. Warning: mktime() expects parameter 2 to be long, object given in %s on line %d
  143. bool(false)
  144. -- instance of classWithoutToString --
  145. Warning: mktime() expects parameter 2 to be long, object given in %s on line %d
  146. bool(false)
  147. -- undefined var --
  148. int(%i)
  149. -- unset var --
  150. int(%i)
  151. -- resource --
  152. Warning: mktime() expects parameter 2 to be long, resource given in %s on line %d
  153. bool(false)
  154. ===DONE===