1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Files
archived-php-src/ext/date/tests/DateTimeImmutable_createFromInterface_exceptions.phpt
2023-02-08 10:27:33 +00:00

38 lines
942 B
PHP

--TEST--
DateTimeImmutable::createFromInterface exception
--INI--
date.timezone=Europe/London
--FILE--
<?php
class MyDateTime extends DateTime
{
function __construct()
{
}
}
class MyDateTimeImmutable extends DateTimeImmutable
{
function __construct()
{
}
}
$i = new MyDateTime();
try {
$m = DateTimeImmutable::createFromInterface( $i );
} catch (\DateObjectError $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
$i = new MyDateTimeImmutable();
try {
$m = DateTimeImmutable::createFromInterface( $i );
} catch (\DateObjectError $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECTF--
DateObjectError: Object of type MyDateTime (inheriting DateTime) has not been correctly initialized by calling parent::__construct() in its constructor
DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor