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