Annotation of embedaddon/php/ext/date/tests/DateTime_extends_basic1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test DateTime class inheritance
3: --FILE--
4: <?php
5:
6: //Set the default time zone
7: date_default_timezone_set("Europe/London");
8:
9: echo "*** Testing basic DateTime inheritance() ***\n";
10:
11:
12: class DateTimeExt extends DateTime
13: {
14: public static $format = "F j, Y, g:i:s a";
15:
16: public function __toString()
17: {
18: return parent::format(self::$format);
19: }
20: }
21:
22: echo "\n-- Create an instance of DateTimeExt --\n";
23: $d = new DateTimeExt("1967-05-01 22:30:41");
24:
25: echo "\n-- Invoke __toString --\n";
26: echo $d . "\n";
27:
28: echo "\n -- modify date and time --\n";
29: $d->setDate(1963, 7, 2);
30: $d->setTime(10, 45, 30);
31:
32: echo "\n-- Invoke __toString again --\n";
33: echo $d . "\n";
34:
35: ?>
36: ===DONE===
37: --EXPECTF--
38: *** Testing basic DateTime inheritance() ***
39:
40: -- Create an instance of DateTimeExt --
41:
42: -- Invoke __toString --
43: May 1, 1967, 10:30:41 pm
44:
45: -- modify date and time --
46:
47: -- Invoke __toString again --
48: July 2, 1963, 10:45:30 am
49: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>