1--TEST--
2Test of compare object handler for DateTimeZone objects
3--FILE--
4<?php
5
6$timezones = array(
7    ['+0200', '-0200'],
8    ['EST', 'PST'],
9    ['Europe/Amsterdam', 'Europe/Berlin']
10);
11
12foreach ($timezones as [$timezone1, $timezone2]) {
13    compare_timezones($timezone1, $timezone1);
14    compare_timezones($timezone1, $timezone2);
15}
16
17var_dump(new DateTimeZone('Europe/Berlin') == new DateTimeZone('CET'));
18
19function compare_timezones($timezone1, $timezone2)
20{
21    $tz1 = new DateTimeZone($timezone1);
22    $tz2 = new DateTimeZone($timezone2);
23    echo "compare $timezone1 with $timezone2\n";
24    echo "< ";
25    var_dump($tz1 < $tz2);
26    echo "= ";
27    var_dump($tz1 == $tz2);
28    echo "> ";
29    var_dump($tz1 > $tz2);
30}
31
32// Test comparison of uninitialized DateTimeZone objects.
33class MyDateTimeZone extends DateTimeZone {
34    function __construct() {
35         // parent ctor not called
36    }
37}
38
39$tz1 = new MyDateTimeZone();
40$tz2 = new MyDateTimeZone();
41var_dump($tz1 == $tz2);
42
43?>
44--EXPECTF--
45compare +0200 with +0200
46< bool(false)
47= bool(true)
48> bool(false)
49compare +0200 with -0200
50< bool(false)
51= bool(false)
52> bool(false)
53compare EST with EST
54< bool(false)
55= bool(true)
56> bool(false)
57compare EST with PST
58< bool(false)
59= bool(false)
60> bool(false)
61compare Europe/Amsterdam with Europe/Amsterdam
62< bool(false)
63= bool(true)
64> bool(false)
65compare Europe/Amsterdam with Europe/Berlin
66< bool(false)
67= bool(false)
68> bool(false)
69
70Warning: main(): Trying to compare different kinds of DateTimeZone objects in %s on line %d
71bool(false)
72
73Warning: main(): Trying to compare uninitialized DateTimeZone objects in %s on line %d
74bool(false)
75