PageRenderTime 36ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-php
PHP | 108 lines | 60 code | 24 blank | 24 comment | 0 complexity | 9029bc3ea210b992e7f7ed12b180817d 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 : DateTime date_time_set ( DateTime $object , int $hour , int $minute [, int $second ] )
  3. * Description: Resets the current time of the DateTime object to a different time.
  4. * Source code: ext/date/php_date.c
  5. * Alias to functions: DateTime::setTime
  6. */
  7. echo "*** Testing date_time_set() : usage variation - unexpected values to second argument \$hour***\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. $object = date_create("2009-01-31 15:14:10");
  75. $minute = 13;
  76. $sec = 45;
  77. foreach($inputs as $variation =>$hour) {
  78. echo "\n-- $variation --\n";
  79. var_dump( date_time_set($object, $hour, $minute, $sec) );
  80. };
  81. // closing the resource
  82. fclose( $file_handle );
  83. ?>
  84. ===DONE===