DateTimeImmutable_createFromMutable-002.phpt 742 B

1234567891011121314151617181920212223242526272829
  1. --TEST--
  2. Tests for inherited DateTimeImmutable::createFromMutable
  3. --INI--
  4. date.timezone=Europe/London
  5. --FILE--
  6. <?php
  7. class MyDateTimeImmutable extends DateTimeImmutable {}
  8. $current = "2014-03-02 16:24:08";
  9. $i = MyDateTimeImmutable::createFromMutable( date_create( $current ) );
  10. var_dump( $i );
  11. try {
  12. MyDateTimeImmutable::createFromMutable( date_create_immutable( $current ) );
  13. } catch (TypeError $e) {
  14. echo $e->getMessage(), "\n";
  15. }
  16. ?>
  17. --EXPECTF--
  18. object(MyDateTimeImmutable)#%d (3) {
  19. ["date"]=>
  20. string(26) "2014-03-02 16:24:08.000000"
  21. ["timezone_type"]=>
  22. int(3)
  23. ["timezone"]=>
  24. string(13) "Europe/London"
  25. }
  26. DateTimeImmutable::createFromMutable(): Argument #1 ($object) must be of type DateTime, DateTimeImmutable given