calendar_fromDateTime_error.phpt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. --TEST--
  2. IntlCalendar::fromDateTime(): errors
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded('intl'))
  6. die('skip intl extension not enabled');
  7. --FILE--
  8. <?php
  9. ini_set("intl.error_level", E_WARNING);
  10. ini_set("intl.default_locale", "nl");
  11. date_default_timezone_set('Europe/Lisbon');
  12. var_dump(IntlCalendar::fromDateTime());
  13. var_dump(IntlCalendar::fromDateTime(0,1,2));
  14. try {
  15. IntlCalendar::fromDateTime("foobar");
  16. } catch (Exception $e) {
  17. echo "threw exception, OK";
  18. }
  19. class A extends DateTime {
  20. function __construct() {}
  21. }
  22. var_dump(IntlCalendar::fromDateTime(new A));
  23. $date = new DateTime('2012-01-01 00:00:00 +24:00');
  24. var_dump(IntlCalendar::fromDateTime($date));
  25. $date = new DateTime('2012-01-01 00:00:00 WEST');
  26. var_dump(IntlCalendar::fromDateTime($date));
  27. var_dump(intlcal_from_date_time());
  28. --EXPECTF--
  29. Warning: IntlCalendar::fromDateTime() expects at least 1 parameter, 0 given in %s on line %d
  30. Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: bad arguments in %s on line %d
  31. NULL
  32. Warning: IntlCalendar::fromDateTime() expects at most 2 parameters, 3 given in %s on line %d
  33. Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: bad arguments in %s on line %d
  34. NULL
  35. threw exception, OK
  36. Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: DateTime object is unconstructed in %s on line %d
  37. NULL
  38. Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: object has an time zone offset that's too large in %s on line %d
  39. NULL
  40. Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d
  41. NULL
  42. Warning: intlcal_from_date_time() expects at least 1 parameter, 0 given in %s on line %d
  43. Warning: intlcal_from_date_time(): intlcal_from_date_time: bad arguments in %s on line %d
  44. NULL