timezone_transitions_get_variation2.phpt 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. --TEST--
  2. Test timezone_transitions_get() function : usage variation - Passing unexpected values to first argument $timestamp_begin.
  3. --FILE--
  4. <?php
  5. /* Prototype : array timezone_transitions_get ( DateTimeZone $object, [ int $timestamp_begin [, int $timestamp_end ]] )
  6. * Description: Returns all transitions for the timezone
  7. * Source code: ext/date/php_date.c
  8. * Alias to functions: DateTimeZone::getTransitions()
  9. */
  10. echo "*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument \$timestamp_begin ***\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 1' => 1,
  40. 'int 12345' => 12345,
  41. 'int -12345' => -12345,
  42. // float data
  43. 'float 10.5' => 10.5,
  44. 'float -10.5' => -10.5,
  45. 'float .5' => .5,
  46. // array data
  47. 'empty array' => array(),
  48. 'int indexed array' => $index_array,
  49. 'associative array' => $assoc_array,
  50. 'nested arrays' => array('foo', $index_array, $assoc_array),
  51. // null data
  52. 'uppercase NULL' => NULL,
  53. 'lowercase null' => null,
  54. // boolean data
  55. 'lowercase true' => true,
  56. 'lowercase false' =>false,
  57. 'uppercase TRUE' =>TRUE,
  58. 'uppercase FALSE' =>FALSE,
  59. // empty data
  60. 'empty string DQ' => "",
  61. 'empty string SQ' => '',
  62. // string data
  63. 'string DQ' => "string",
  64. 'string SQ' => 'string',
  65. 'mixed case string' => "sTrInG",
  66. 'heredoc' => $heredoc,
  67. // object data
  68. 'instance of classWithToString' => new classWithToString(),
  69. 'instance of classWithoutToString' => new classWithoutToString(),
  70. // undefined data
  71. 'undefined var' => @$undefined_var,
  72. // unset data
  73. 'unset var' => @$unset_var,
  74. // resource
  75. 'resource' => $file_handle
  76. );
  77. $tz = timezone_open("Europe/London");
  78. $timestamp_end = mktime(0, 0, 0, 1, 1, 1975);
  79. foreach($inputs as $variation =>$timestamp_begin) {
  80. echo "\n-- $variation --\n";
  81. $tran = timezone_transitions_get($tz, $timestamp_begin, $timestamp_end);
  82. var_dump( gettype($tran) );
  83. var_dump( count($tran) );
  84. };
  85. // closing the resource
  86. fclose( $file_handle );
  87. ?>
  88. ===DONE===
  89. --EXPECTF--
  90. *** Testing timezone_transitions_get() : usage variation - unexpected values to first argument $timestamp_begin ***
  91. -- int 0 --
  92. string(5) "array"
  93. int(8)
  94. -- int 1 --
  95. string(5) "array"
  96. int(8)
  97. -- int 12345 --
  98. string(5) "array"
  99. int(8)
  100. -- int -12345 --
  101. string(5) "array"
  102. int(8)
  103. -- float 10.5 --
  104. string(5) "array"
  105. int(8)
  106. -- float -10.5 --
  107. string(5) "array"
  108. int(8)
  109. -- float .5 --
  110. string(5) "array"
  111. int(8)
  112. -- empty array --
  113. Warning: timezone_transitions_get() expects parameter 2 to be long, array given in %s on line %d
  114. string(7) "boolean"
  115. int(1)
  116. -- int indexed array --
  117. Warning: timezone_transitions_get() expects parameter 2 to be long, array given in %s on line %d
  118. string(7) "boolean"
  119. int(1)
  120. -- associative array --
  121. Warning: timezone_transitions_get() expects parameter 2 to be long, array given in %s on line %d
  122. string(7) "boolean"
  123. int(1)
  124. -- nested arrays --
  125. Warning: timezone_transitions_get() expects parameter 2 to be long, array given in %s on line %d
  126. string(7) "boolean"
  127. int(1)
  128. -- uppercase NULL --
  129. string(5) "array"
  130. int(8)
  131. -- lowercase null --
  132. string(5) "array"
  133. int(8)
  134. -- lowercase true --
  135. string(5) "array"
  136. int(8)
  137. -- lowercase false --
  138. string(5) "array"
  139. int(8)
  140. -- uppercase TRUE --
  141. string(5) "array"
  142. int(8)
  143. -- uppercase FALSE --
  144. string(5) "array"
  145. int(8)
  146. -- empty string DQ --
  147. Warning: timezone_transitions_get() expects parameter 2 to be long, string given in %s on line %d
  148. string(7) "boolean"
  149. int(1)
  150. -- empty string SQ --
  151. Warning: timezone_transitions_get() expects parameter 2 to be long, string given in %s on line %d
  152. string(7) "boolean"
  153. int(1)
  154. -- string DQ --
  155. Warning: timezone_transitions_get() expects parameter 2 to be long, string given in %s on line %d
  156. string(7) "boolean"
  157. int(1)
  158. -- string SQ --
  159. Warning: timezone_transitions_get() expects parameter 2 to be long, string given in %s on line %d
  160. string(7) "boolean"
  161. int(1)
  162. -- mixed case string --
  163. Warning: timezone_transitions_get() expects parameter 2 to be long, string given in %s on line %d
  164. string(7) "boolean"
  165. int(1)
  166. -- heredoc --
  167. Warning: timezone_transitions_get() expects parameter 2 to be long, string given in %s on line %d
  168. string(7) "boolean"
  169. int(1)
  170. -- instance of classWithToString --
  171. Warning: timezone_transitions_get() expects parameter 2 to be long, object given in %s on line %d
  172. string(7) "boolean"
  173. int(1)
  174. -- instance of classWithoutToString --
  175. Warning: timezone_transitions_get() expects parameter 2 to be long, object given in %s on line %d
  176. string(7) "boolean"
  177. int(1)
  178. -- undefined var --
  179. string(5) "array"
  180. int(8)
  181. -- unset var --
  182. string(5) "array"
  183. int(8)
  184. -- resource --
  185. Warning: timezone_transitions_get() expects parameter 2 to be long, resource given in %s on line %d
  186. string(7) "boolean"
  187. int(1)
  188. ===DONE===