PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/hphp/test/zend/bad/ext/date/tests/timezone_transitions_get_variation2.php

http://github.com/facebook/hiphop-php
PHP | 109 lines | 61 code | 24 blank | 24 comment | 0 complexity | 72688ff7eea329e637d8790dc9f3fdaf MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?php
  2. /* Prototype : array timezone_transitions_get ( DateTimeZone $object, [ int $timestamp_begin [, int $timestamp_end ]] )
  3. * Description: Returns all transitions for the timezone
  4. * Source code: ext/date/php_date.c
  5. * Alias to functions: DateTimeZone::getTransitions()
  6. */
  7. echo "*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument \$timestamp_begin ***\n";
  8. //Set the default time zone
  9. date_default_timezone_set("Europe/London");
  10. //get an unset variable
  11. $unset_var = 10;
  12. unset ($unset_var);
  13. // define some classes
  14. class classWithToString
  15. {
  16. public function __toString() {
  17. return "Class A object";
  18. }
  19. }
  20. class classWithoutToString
  21. {
  22. }
  23. // heredoc string
  24. $heredoc = <<<EOT
  25. hello world
  26. EOT;
  27. // add arrays
  28. $index_array = array (1, 2, 3);
  29. $assoc_array = array ('one' => 1, 'two' => 2);
  30. // resource
  31. $file_handle = fopen(__FILE__, 'r');
  32. //array of values to iterate over
  33. $inputs = array(
  34. // int data
  35. 'int 0' => 0,
  36. 'int 1' => 1,
  37. 'int 12345' => 12345,
  38. 'int -12345' => -12345,
  39. // float data
  40. 'float 10.5' => 10.5,
  41. 'float -10.5' => -10.5,
  42. 'float .5' => .5,
  43. // array data
  44. 'empty array' => array(),
  45. 'int indexed array' => $index_array,
  46. 'associative array' => $assoc_array,
  47. 'nested arrays' => array('foo', $index_array, $assoc_array),
  48. // null data
  49. 'uppercase NULL' => NULL,
  50. 'lowercase null' => null,
  51. // boolean data
  52. 'lowercase true' => true,
  53. 'lowercase false' =>false,
  54. 'uppercase TRUE' =>TRUE,
  55. 'uppercase FALSE' =>FALSE,
  56. // empty data
  57. 'empty string DQ' => "",
  58. 'empty string SQ' => '',
  59. // string data
  60. 'string DQ' => "string",
  61. 'string SQ' => 'string',
  62. 'mixed case string' => "sTrInG",
  63. 'heredoc' => $heredoc,
  64. // object data
  65. 'instance of classWithToString' => new classWithToString(),
  66. 'instance of classWithoutToString' => new classWithoutToString(),
  67. // undefined data
  68. 'undefined var' => @$undefined_var,
  69. // unset data
  70. 'unset var' => @$unset_var,
  71. // resource
  72. 'resource' => $file_handle
  73. );
  74. $tz = timezone_open("Europe/London");
  75. $timestamp_end = mktime(0, 0, 0, 1, 1, 1975);
  76. foreach($inputs as $variation =>$timestamp_begin) {
  77. echo "\n-- $variation --\n";
  78. $tran = timezone_transitions_get($tz, $timestamp_begin, $timestamp_end);
  79. var_dump( gettype($tran) );
  80. var_dump( count($tran) );
  81. };
  82. // closing the resource
  83. fclose( $file_handle );
  84. ?>
  85. ===DONE===