Annotation of embedaddon/php/ext/date/tests/DateTime_compare_basic1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test of compare object handler for DateTime objects
3: --FILE--
4: <?php
5:
6: echo "Simple test for DateTime compare object handler\n";
7:
8: //Set the default time zone
9: date_default_timezone_set("Europe/London");
10:
11: class DateTimeExt1 extends DateTime {
12: }
13:
14: class DateTimeExt2 extends DateTime{
15: public $foo = "Hello";
16: private $bar = 99;
17: }
18:
19: class DateTimeExt3 extends DateTimeExt2 {
20: }
21:
22: $obj1 = new DateTime("2009-02-12 12:47:41 GMT");
23: $obj2 = new DateTimeExt1("2009-02-12 12:47:41 GMT");
24: $obj3 = new DateTimeExt2("2009-02-12 12:47:41 GMT");
25: $obj4 = new DateTimeExt3("2009-02-12 12:47:41 GMT");
26:
27: echo "\n-- All the following tests should compare equal --\n";
28: var_dump($obj1 == $obj1);
29: var_dump($obj1 == $obj2);
30: var_dump($obj1 == $obj3);
31: var_dump($obj1 == $obj4);
32: var_dump($obj2 == $obj3);
33: var_dump($obj2 == $obj4);
34: var_dump($obj3 == $obj4);
35:
36: date_modify($obj1, "+1 day");
37: echo "\n-- The following test should still compare equal --\n";
38: var_dump($obj1 == $obj1);
39: echo "\n-- All the following tests should now compare NOT equal --\n";
40: var_dump($obj1 == $obj2);
41: var_dump($obj1 == $obj3);
42: var_dump($obj1 == $obj4);
43:
44: echo "\n-- All the following tests should again compare equal --\n";
45: date_modify($obj2, "+1 day");
46: date_modify($obj3, "+1 day");
47: date_modify($obj4, "+1 day");
48: var_dump($obj1 == $obj2);
49: var_dump($obj1 == $obj3);
50: var_dump($obj1 == $obj4);
51: ?>
52: ===DONE===
53: --EXPECT--
54: Simple test for DateTime compare object handler
55:
56: -- All the following tests should compare equal --
57: bool(true)
58: bool(true)
59: bool(true)
60: bool(true)
61: bool(true)
62: bool(true)
63: bool(true)
64:
65: -- The following test should still compare equal --
66: bool(true)
67:
68: -- All the following tests should now compare NOT equal --
69: bool(false)
70: bool(false)
71: bool(false)
72:
73: -- All the following tests should again compare equal --
74: bool(true)
75: bool(true)
76: bool(true)
77: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>