1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/intl/tests/calendar_toDateTime_error.phpt
Gina Peter Banyard 1e108e9ab2 ext/intl: wrap DateTimeZone constructor exception in an IntlException (#19410)
The motivation is two fold:
- Userland code that deals with ext/intl can be expected to handle IntlException but not necessarily ext/date exceptions
- This removes the possibility of superfluous warnings being emitted by ext/intl when an exception has already been thrown
2025-08-09 11:24:11 +01:00

52 lines
1.7 KiB
PHP

--TEST--
IntlCalendar::toDateTime(): bad arguments
--EXTENSIONS--
intl
--FILE--
<?php
$cal = new IntlGregorianCalendar("Etc/Unknown");
try {
var_dump($cal->toDateTime());
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
$previous = $e->getPrevious();
echo ' ', $previous::class, ': ', $previous->getMessage(), PHP_EOL;
}
try {
var_dump(intlcal_to_date_time($cal));
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
$previous = $e->getPrevious();
echo ' ', $previous::class, ': ', $previous->getMessage(), PHP_EOL;
}
$cal = IntlCalendar::createInstance("Etc/Unknown");
try {
var_dump($cal->toDateTime());
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
$previous = $e->getPrevious();
echo ' ', $previous::class, ': ', $previous->getMessage(), PHP_EOL;
}
try {
var_dump(intlcal_to_date_time($cal));
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
$previous = $e->getPrevious();
echo ' ', $previous::class, ': ', $previous->getMessage(), PHP_EOL;
}
?>
--EXPECT--
IntlException: DateTimeZone constructor threw exception
DateInvalidTimeZoneException: DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)
IntlException: DateTimeZone constructor threw exception
DateInvalidTimeZoneException: DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)
IntlException: DateTimeZone constructor threw exception
DateInvalidTimeZoneException: DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)
IntlException: DateTimeZone constructor threw exception
DateInvalidTimeZoneException: DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)