summaryrefslogtreecommitdiff
path: root/ext/intl/tests/calendar_toDateTime_error.phpt
diff options
context:
space:
mode:
authorGeorge Peter Banyard <girgias@php.net>2020-07-31 13:27:22 +0100
committerGeorge Peter Banyard <girgias@php.net>2020-07-31 13:27:22 +0100
commitf78a09101496d05b4fb50fe37b7dbf5d038452ec (patch)
treea5fcb2cce4dc424fc82048ea91ad868a26a7d5b9 /ext/intl/tests/calendar_toDateTime_error.phpt
parentd3a9e1503f71dc64d4c34f0d0e1d7431f2310fec (diff)
downloadphp-git-f78a09101496d05b4fb50fe37b7dbf5d038452ec.tar.gz
Warning to ValueError promotion in Intl extension Part 1
Affects: - IntlCalendar - IntlGregorianCalendar - IntlBreakIterator Closes GH-5669
Diffstat (limited to 'ext/intl/tests/calendar_toDateTime_error.phpt')
-rw-r--r--ext/intl/tests/calendar_toDateTime_error.phpt39
1 files changed, 33 insertions, 6 deletions
diff --git a/ext/intl/tests/calendar_toDateTime_error.phpt b/ext/intl/tests/calendar_toDateTime_error.phpt
index 20f45ef6d2..01cf75c4c2 100644
--- a/ext/intl/tests/calendar_toDateTime_error.phpt
+++ b/ext/intl/tests/calendar_toDateTime_error.phpt
@@ -16,13 +16,40 @@ var_dump($cal->toDateTime());
var_dump("exception: {$e->getMessage()}");
}
-var_dump(intlcal_to_date_time(3));
+try {
+ var_dump(intlcal_to_date_time($cal));
+} catch (\Exception $e) {
+ var_dump($e->getMessage());
+}
+
+$cal = IntlCalendar::createInstance("Etc/Unknown");
+try {
+ var_dump($cal->toDateTime());
+} catch (\Exception $e) {
+ var_dump($e->getMessage());
+}
+
+try {
+ var_dump(intlcal_to_date_time($cal));
+} catch (\Exception $e) {
+ var_dump($e->getMessage());
+}
+
+try {
+ var_dump(intlcal_to_date_time(3));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
--EXPECTF--
Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
string(77) "exception: DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
-Fatal error: Uncaught TypeError: intlcal_to_date_time(): Argument #1 ($calendar) must be of type IntlCalendar, int given in %s:%d
-Stack trace:
-#0 %s(%d): intlcal_to_date_time(3)
-#1 {main}
- thrown in %s on line %d
+Warning: intlcal_to_date_time(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
+string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
+
+Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
+string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
+
+Warning: intlcal_to_date_time(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
+string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
+intlcal_to_date_time(): Argument #1 ($calendar) must be of type IntlCalendar, int given