1--TEST--
2IntlDateFormatter::formatObject(): error conditions
3--EXTENSIONS--
4intl
5--FILE--
6<?php
7ini_set("intl.error_level", E_WARNING);
8ini_set("intl.default_locale", "pt_PT");
9ini_set("date.timezone", "Europe/Lisbon");
10
11var_dump(IntlDateFormatter::formatObject(new stdclass));
12
13class A extends IntlCalendar {function __construct(){}}
14var_dump(IntlDateFormatter::formatObject(new A));
15class B extends DateTime {function __construct(){}}
16try {
17    var_dump(IntlDateFormatter::formatObject(new B));
18} catch (Error $e) {
19    echo $e->getMessage(), "\n";
20}
21
22$cal = IntlCalendar::createInstance();
23var_dump(IntlDateFormatter::formatObject($cal, -2));
24var_dump(IntlDateFormatter::formatObject($cal, array()));
25var_dump(IntlDateFormatter::formatObject($cal, array(1,2,3)));
26var_dump(IntlDateFormatter::formatObject($cal, array(array(), 1)));
27var_dump(IntlDateFormatter::formatObject($cal, array(1, -2)));
28var_dump(IntlDateFormatter::formatObject($cal, ""));
29
30?>
31--EXPECTF--
32Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the passed object must be an instance of either IntlCalendar or DateTimeInterface in %s on line %d
33bool(false)
34
35Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad IntlCalendar instance: not initialized properly in %s on line %d
36bool(false)
37
38Warning: IntlDateFormatter::formatObject(): datefmt_format_object: error calling ::getTimeStamp() on the object in %s on line %d
39The DateTime object has not been correctly initialized by its constructor
40
41Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the date/time format type is invalid in %s on line %d
42bool(false)
43
44Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; if array, it must have two elements in %s on line %d
45bool(false)
46
47Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; if array, it must have two elements in %s on line %d
48bool(false)
49
50Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; the date format (first element of the array) is not valid in %s on line %d
51bool(false)
52
53Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; the time format (second element of the array) is not valid in %s on line %d
54bool(false)
55
56Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the format is empty in %s on line %d
57bool(false)
58