1--TEST--
2IntlCalendar::toDateTime(): bad arguments
3--SKIPIF--
4<?php
5if (!extension_loaded('intl'))
6    die('skip intl extension not enabled');
7--FILE--
8<?php
9ini_set("intl.error_level", E_WARNING);
10ini_set('date.timezone', 'Europe/Lisbon');
11
12$cal = new IntlGregorianCalendar("Etc/Unknown");
13try {
14var_dump($cal->toDateTime());
15} catch (Exception $e) {
16var_dump("exception: {$e->getMessage()}");
17}
18
19try {
20    var_dump(intlcal_to_date_time($cal));
21} catch (\Exception $e) {
22    var_dump($e->getMessage());
23}
24
25$cal = IntlCalendar::createInstance("Etc/Unknown");
26try {
27    var_dump($cal->toDateTime());
28} catch (\Exception $e) {
29    var_dump($e->getMessage());
30}
31
32try {
33    var_dump(intlcal_to_date_time($cal));
34} catch (\Exception $e) {
35    var_dump($e->getMessage());
36}
37
38try {
39    var_dump(intlcal_to_date_time(3));
40} catch (\TypeError $e) {
41    echo $e->getMessage() . \PHP_EOL;
42}
43?>
44--EXPECTF--
45Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
46string(77) "exception: DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
47
48Warning: intlcal_to_date_time(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
49string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
50
51Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
52string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
53
54Warning: intlcal_to_date_time(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
55string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
56intlcal_to_date_time(): Argument #1 ($calendar) must be of type IntlCalendar, int given
57