oo_001.phpt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. --TEST--
  2. date OO interface
  3. --FILE--
  4. <?php
  5. date_default_timezone_set('UTC');
  6. class _d extends DateTime {
  7. function __construct() {
  8. }
  9. }
  10. class _t extends DateTimeZone {
  11. function __construct() {
  12. }
  13. }
  14. class _p extends DatePeriod {
  15. function __construct() {
  16. }
  17. }
  18. $d = new DateTime;
  19. var_dump($d->format("Y-m-d H:i:s"));
  20. try {
  21. $d = new _d;
  22. var_dump($d->format("Y-m-d H:i:s"));
  23. } catch (Error $e) {
  24. echo $e->getMessage(),"\n";
  25. }
  26. try {
  27. new DateTime("1am todax");
  28. } catch (Exception $e) {
  29. echo $e->getMessage(),"\n";
  30. }
  31. $t = new DateTimeZone("UTC");
  32. var_dump($t->getName());
  33. try {
  34. $t = new _t;
  35. var_dump($t->getName());
  36. } catch (Error $e) {
  37. echo $e->getMessage(),"\n";
  38. }
  39. try {
  40. new DateTimeZone("GottaFindThisOne");
  41. } catch (Exception $e) {
  42. echo $e->getMessage(),"\n";
  43. }
  44. $p = new _p;
  45. try {
  46. var_dump($p->getStartDate());
  47. } catch (Error $e) {
  48. echo $e->getMessage(),"\n";
  49. }
  50. try {
  51. var_dump($p->getDateInterval());
  52. } catch (Error $e) {
  53. echo $e->getMessage(),"\n";
  54. }
  55. echo "DONE\n";
  56. ?>
  57. --EXPECTF--
  58. string(19) "%d-%d-%d %d:%d:%d"
  59. The DateTime object has not been correctly initialized by its constructor
  60. Failed to parse time string (1am todax) at position 4 (t): The timezone could not be found in the database
  61. string(3) "UTC"
  62. The DateTimeZone object has not been correctly initialized by its constructor
  63. DateTimeZone::__construct(): Unknown or bad timezone (GottaFindThisOne)
  64. The DatePeriod object has not been correctly initialized by its constructor
  65. The DatePeriod object has not been correctly initialized by its constructor
  66. DONE