diff options
Diffstat (limited to 'ext/date/tests')
| -rw-r--r-- | ext/date/tests/003.phpt | 47 | ||||
| -rw-r--r-- | ext/date/tests/004.phpt | 73 | ||||
| -rw-r--r-- | ext/date/tests/005.phpt | 45 | ||||
| -rw-r--r-- | ext/date/tests/006.phpt | 33 | ||||
| -rw-r--r-- | ext/date/tests/007.phpt | 101 | ||||
| -rw-r--r-- | ext/date/tests/008.phpt | 67 | ||||
| -rw-r--r-- | ext/date/tests/009.phpt | 46 | ||||
| -rw-r--r-- | ext/date/tests/bug20382-2.phpt | 2 | ||||
| -rw-r--r-- | ext/date/tests/bug37368.phpt | 10 | ||||
| -rw-r--r-- | ext/date/tests/bug37514.phpt | 20 | ||||
| -rw-r--r-- | ext/date/tests/bug37616.phpt | 9 | ||||
| -rw-r--r-- | ext/date/tests/bug37747.phpt | 11 | ||||
| -rw-r--r-- | ext/date/tests/bug38229.phpt | 13 | ||||
| -rw-r--r-- | ext/date/tests/date_constants.phpt | 75 | ||||
| -rw-r--r-- | ext/date/tests/date_create-1.phpt | 2 | ||||
| -rw-r--r-- | ext/date/tests/date_create-2.phpt | 2 | ||||
| -rw-r--r-- | ext/date/tests/date_modify-1.phpt | 12 | ||||
| -rw-r--r-- | ext/date/tests/date_modify-2.phpt | 4 | ||||
| -rw-r--r-- | ext/date/tests/oo_001.phpt | 53 | ||||
| -rw-r--r-- | ext/date/tests/oo_002.phpt | 28 | ||||
| -rwxr-xr-x | ext/date/tests/strtotime-mysql.phpt | 25 | ||||
| -rw-r--r-- | ext/date/tests/strtotime2.phpt | 40 | ||||
| -rw-r--r-- | ext/date/tests/strtotime3.phpt | 69 | ||||
| -rw-r--r-- | ext/date/tests/timezones.phpt | 26 |
24 files changed, 802 insertions, 11 deletions
diff --git a/ext/date/tests/003.phpt b/ext/date/tests/003.phpt new file mode 100644 index 000000000..621a87b34 --- /dev/null +++ b/ext/date/tests/003.phpt @@ -0,0 +1,47 @@ +--TEST-- +date suffixes test +--INI-- +date.timezone=UTC +--FILE-- +<?php + +for ($i = 0; $i < 32; $i++) { + var_dump(date("jS", mktime(0,0,0, 1, $i, 2006))); +} + +echo "Done\n"; +?> +--EXPECTF-- +string(4) "31st" +string(3) "1st" +string(3) "2nd" +string(3) "3rd" +string(3) "4th" +string(3) "5th" +string(3) "6th" +string(3) "7th" +string(3) "8th" +string(3) "9th" +string(4) "10th" +string(4) "11th" +string(4) "12th" +string(4) "13th" +string(4) "14th" +string(4) "15th" +string(4) "16th" +string(4) "17th" +string(4) "18th" +string(4) "19th" +string(4) "20th" +string(4) "21st" +string(4) "22nd" +string(4) "23rd" +string(4) "24th" +string(4) "25th" +string(4) "26th" +string(4) "27th" +string(4) "28th" +string(4) "29th" +string(4) "30th" +string(4) "31st" +Done diff --git a/ext/date/tests/004.phpt b/ext/date/tests/004.phpt new file mode 100644 index 000000000..33e1fc791 --- /dev/null +++ b/ext/date/tests/004.phpt @@ -0,0 +1,73 @@ +--TEST-- +date() format params +--FILE-- +<?php + +date_default_timezone_set("UTC"); +$tz = array("UTC", "Asia/Jerusalem", "America/Chicago", "Europe/London"); +$t = mktime(0, 0, 0, 6, 27, 2006); + +foreach ($tz as $zone) { + date_default_timezone_set($zone); + + var_dump(date("w", $t)); + var_dump(date("z", $t)); + var_dump(date("n", $t)); + var_dump(date("t", $t)); + var_dump(date("L", $t)); + var_dump(date("a", $t)); + var_dump(date("B", $t)); + var_dump(date("g", $t)); + var_dump(date("G", $t)); + var_dump(date("Z", $t)); + var_dump(date("U", $t)); +} + +echo "Done\n"; +?> +--EXPECTF-- +string(1) "2" +string(3) "177" +string(1) "6" +string(2) "30" +string(1) "0" +string(2) "am" +string(3) "041" +string(2) "12" +string(1) "0" +string(1) "0" +string(10) "1151366400" +string(1) "2" +string(3) "177" +string(1) "6" +string(2) "30" +string(1) "0" +string(2) "am" +string(3) "041" +string(1) "3" +string(1) "3" +string(5) "10800" +string(10) "1151366400" +string(1) "1" +string(3) "176" +string(1) "6" +string(2) "30" +string(1) "0" +string(2) "pm" +string(3) "041" +string(1) "7" +string(2) "19" +string(6) "-18000" +string(10) "1151366400" +string(1) "2" +string(3) "177" +string(1) "6" +string(2) "30" +string(1) "0" +string(2) "am" +string(3) "041" +string(1) "1" +string(1) "1" +string(4) "3600" +string(10) "1151366400" +Done diff --git a/ext/date/tests/005.phpt b/ext/date/tests/005.phpt new file mode 100644 index 000000000..c6551b76b --- /dev/null +++ b/ext/date/tests/005.phpt @@ -0,0 +1,45 @@ +--TEST-- +idate() and invalid params +--INI-- +date.timezone=UTC +--FILE-- +<?php + +$t = mktime(0,0,0, 6, 27, 2006); + +var_dump(idate()); +var_dump(idate(1,1,1)); + +var_dump(idate(1,1)); +var_dump(idate("")); +var_dump(idate(0)); + +var_dump(idate("B", $t)); +var_dump(idate("[", $t)); +var_dump(idate("'")); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: idate() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +Warning: idate() expects at most 2 parameters, 3 given in %s on line %d +bool(false) + +Warning: idate(): Unrecognized date format token. in %s on line %d +bool(false) + +Warning: idate(): idate format is one char in %s on line %d +bool(false) + +Warning: idate(): Unrecognized date format token. in %s on line %d +bool(false) +int(41) + +Warning: idate(): Unrecognized date format token. in %s on line %d +bool(false) + +Warning: idate(): Unrecognized date format token. in %s on line %d +bool(false) +Done diff --git a/ext/date/tests/006.phpt b/ext/date/tests/006.phpt new file mode 100644 index 000000000..407242b16 --- /dev/null +++ b/ext/date/tests/006.phpt @@ -0,0 +1,33 @@ +--TEST-- +checkdate() tests +--INI-- +date.timezone=UTC +--FILE-- +<?php + +var_dump(checkdate()); +var_dump(checkdate(1,1,1)); + +var_dump(checkdate(2,29,2006)); +var_dump(checkdate(31,6,2006)); +var_dump(checkdate(1,1,32768)); +var_dump(checkdate(1,1,32767)); + +var_dump(checkdate(-1,1,2006)); +var_dump(checkdate(1,-1,2006)); +var_dump(checkdate(1,1,-1)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: checkdate() expects exactly 3 parameters, 0 given in %s on line %d +bool(false) +bool(true) +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +bool(false) +Done diff --git a/ext/date/tests/007.phpt b/ext/date/tests/007.phpt new file mode 100644 index 000000000..f0c878465 --- /dev/null +++ b/ext/date/tests/007.phpt @@ -0,0 +1,101 @@ +--TEST-- +localtime() tests +--INI-- +date.timezone=UTC +--FILE-- +<?php + +$t = mktime(0,0,0, 6, 27, 2006); +var_dump(localtime(1,1,1)); + +var_dump(localtime()); +var_dump(localtime($t)); +var_dump(localtime($t, true)); +var_dump(localtime($t, false)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: localtime() expects at most 2 parameters, 3 given in %s on line %d +bool(false) +array(9) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) +} +array(9) { + [0]=> + int(0) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(27) + [4]=> + int(5) + [5]=> + int(106) + [6]=> + int(2) + [7]=> + int(177) + [8]=> + int(0) +} +array(9) { + ["tm_sec"]=> + int(0) + ["tm_min"]=> + int(0) + ["tm_hour"]=> + int(0) + ["tm_mday"]=> + int(27) + ["tm_mon"]=> + int(5) + ["tm_year"]=> + int(106) + ["tm_wday"]=> + int(2) + ["tm_yday"]=> + int(177) + ["tm_isdst"]=> + int(0) +} +array(9) { + [0]=> + int(0) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(27) + [4]=> + int(5) + [5]=> + int(106) + [6]=> + int(2) + [7]=> + int(177) + [8]=> + int(0) +} +Done diff --git a/ext/date/tests/008.phpt b/ext/date/tests/008.phpt new file mode 100644 index 000000000..424e15678 --- /dev/null +++ b/ext/date/tests/008.phpt @@ -0,0 +1,67 @@ +--TEST-- +getdate() tests +--INI-- +date.timezone=UTC +--FILE-- +<?php + +$t = mktime(0,0,0, 6, 27, 2006); +var_dump(getdate(1,1)); + +var_dump(getdate($t)); +var_dump(getdate()); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: getdate() expects at most 1 parameter, 2 given in %s on line %d +bool(false) +array(11) { + ["seconds"]=> + int(0) + ["minutes"]=> + int(0) + ["hours"]=> + int(0) + ["mday"]=> + int(27) + ["wday"]=> + int(2) + ["mon"]=> + int(6) + ["year"]=> + int(2006) + ["yday"]=> + int(177) + ["weekday"]=> + string(7) "Tuesday" + ["month"]=> + string(4) "June" + [0]=> + int(1151366400) +} +array(11) { + ["seconds"]=> + int(%d) + ["minutes"]=> + int(%d) + ["hours"]=> + int(%d) + ["mday"]=> + int(%d) + ["wday"]=> + int(%d) + ["mon"]=> + int(%d) + ["year"]=> + int(%d) + ["yday"]=> + int(%d) + ["weekday"]=> + string(%d) "%s" + ["month"]=> + string(%d) "%s" + [0]=> + int(%d) +} +Done diff --git a/ext/date/tests/009.phpt b/ext/date/tests/009.phpt new file mode 100644 index 000000000..0ce7b7e0b --- /dev/null +++ b/ext/date/tests/009.phpt @@ -0,0 +1,46 @@ +--TEST-- +strftime() and gmstrftime() tests +--INI-- +date.timezone=Asia/Jerusalem +--FILE-- +<?php + +$t = mktime(0,0,0, 6, 27, 2006); + +var_dump(strftime()); + +var_dump(strftime("")); +var_dump(strftime("%a %A %b %B %c %C %d %D %e %g %G %h %H %I %j %m %M %n %p %r %R %S %t %T %u %U %V %W %w %x %X %y %Y %Z %z %%", $t)); +var_dump(strftime("%%q %%a", $t)); +var_dump(strftime("%q", $t)); +var_dump(strftime("blah", $t)); + +var_dump(gmstrftime()); + +var_dump(gmstrftime("")); +var_dump(gmstrftime("%a %A %b %B %c %C %d %D %e %g %G %h %H %I %j %m %M %n %p %r %R %S %t %T %u %U %V %W %w %x %X %y %Y %Z %z %%", $t)); +var_dump(gmstrftime("%%q %%a", $t)); +var_dump(gmstrftime("%q", $t)); +var_dump(gmstrftime("blah", $t)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: strftime() expects at least 1 parameter, 0 given in %s on line %d +bool(false) +bool(false) +string(%d) "Tue Tuesday Jun June Tue Jun 27 00:00:00 2006 %s +%s %" +string(5) "%q %a" +string(%d) "%s" +string(4) "blah" + +Warning: gmstrftime() expects at least 1 parameter, 0 given in %s on line %d +bool(false) +bool(false) +string(%d) "Mon Monday Jun June Mon Jun 26 21:00:00 2006 %s +%s %" +string(5) "%q %a" +string(%d) "%s" +string(4) "blah" +Done diff --git a/ext/date/tests/bug20382-2.phpt b/ext/date/tests/bug20382-2.phpt index 6e6a1ba6f..639f1b799 100644 --- a/ext/date/tests/bug20382-2.phpt +++ b/ext/date/tests/bug20382-2.phpt @@ -166,5 +166,5 @@ wanted = Monday 00:00:00 Asia/Baku ts = Monday 1995-12-25 17:17:17 AZT -result = Monday 1996-01-01 01:00:00 AZST +result = Monday 1996-01-01 00:00:00 AZT wanted = Monday 00:00:00 diff --git a/ext/date/tests/bug37368.phpt b/ext/date/tests/bug37368.phpt new file mode 100644 index 000000000..5be1c9679 --- /dev/null +++ b/ext/date/tests/bug37368.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #37368 (Incorrect timestamp returned for strtotime()). +--INI-- +date.timezone=UTC +--FILE-- +<?php +echo date("r", strtotime("Mon, 08 May 2006 13:06:44 -0400 +30 days")); +?> +--EXPECT-- +Wed, 07 Jun 2006 17:06:44 +0000 diff --git a/ext/date/tests/bug37514.phpt b/ext/date/tests/bug37514.phpt new file mode 100644 index 000000000..31318b46a --- /dev/null +++ b/ext/date/tests/bug37514.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #37514 (strtotime doesn't assume year correctly). +--INI-- +date.timezone=UTC +--FILE-- +<?php +echo date('r', strtotime('May 18th 5:05')), "\n"; +echo date('r', strtotime('May 18th 5:05pm')), "\n"; +echo date('r', strtotime('May 18th 5:05 pm')), "\n"; +echo date('r', strtotime('May 18th 5:05am')), "\n"; +echo date('r', strtotime('May 18th 5:05 am')), "\n"; +echo date('r', strtotime('May 18th 2006 5:05pm')), "\n"; +?> +--EXPECT-- +Thu, 18 May 2006 05:05:00 +0000 +Thu, 18 May 2006 17:05:00 +0000 +Thu, 18 May 2006 17:05:00 +0000 +Thu, 18 May 2006 05:05:00 +0000 +Thu, 18 May 2006 05:05:00 +0000 +Thu, 18 May 2006 17:05:00 +0000 diff --git a/ext/date/tests/bug37616.phpt b/ext/date/tests/bug37616.phpt new file mode 100644 index 000000000..765250176 --- /dev/null +++ b/ext/date/tests/bug37616.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #37616 (DATE_RFC822 does not product RFC 822 dates) +--FILE-- +<?php + date_default_timezone_set("Europe/Oslo"); + var_dump(date(DATE_RFC822, strtotime("1 Jul 06 14:27:30 +0200"))); +?> +--EXPECT-- +string(29) "Sat, 01 Jul 06 14:27:30 +0200" diff --git a/ext/date/tests/bug37747.phpt b/ext/date/tests/bug37747.phpt new file mode 100644 index 000000000..465f791c4 --- /dev/null +++ b/ext/date/tests/bug37747.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #37747 (strtotime segfaults when given "nextyear") +--FILE-- +<?php + date_default_timezone_set("Europe/Oslo"); + var_dump(strtotime("nextyear")); + echo "ALIVE\n"; +?> +--EXPECT-- +bool(false) +ALIVE diff --git a/ext/date/tests/bug38229.phpt b/ext/date/tests/bug38229.phpt new file mode 100644 index 000000000..472a05fae --- /dev/null +++ b/ext/date/tests/bug38229.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #38229 (strtotime() does not parse YYYY-MM) +--FILE-- +<?php +date_default_timezone_set("GMT"); +echo date("Y-m", strtotime('2006-1'))."\n"; +echo date("Y-m", strtotime('2006-03'))."\n"; +echo date("Y-m", strtotime('2006-12'))."\n"; +?> +--EXPECT-- +2006-01 +2006-03 +2006-12 diff --git a/ext/date/tests/date_constants.phpt b/ext/date/tests/date_constants.phpt new file mode 100644 index 000000000..132e24159 --- /dev/null +++ b/ext/date/tests/date_constants.phpt @@ -0,0 +1,75 @@ +--TEST-- +Date constants +--FILE-- +<?php + date_default_timezone_set("Europe/Oslo"); + $constants = array( + DATE_ATOM, + DATE_COOKIE, + DATE_ISO8601, + DATE_RFC822, + DATE_RFC850, + DATE_RFC1036, + DATE_RFC1123, + DATE_RFC2822, + DATE_RFC3339, + DATE_RSS, + DATE_W3C + ); + + foreach($constants as $const) { + var_dump(date($const, strtotime("1 Jul 06 14:27:30 +0200"))); + var_dump(date($const, strtotime("2006-05-30T14:32:13+02:00"))); + } + + print "\n"; + + var_dump( + DATE_ATOM == DateTime::ATOM, + DATE_COOKIE == DateTime::COOKIE, + DATE_ISO8601 == DateTime::ISO8601, + DATE_RFC822 == DateTime::RFC822, + DATE_RFC850 == DateTime::RFC850, + DATE_RFC1036 == DateTime::RFC1036, + DATE_RFC1123 == DateTime::RFC1123, + DATE_RFC2822 == DateTime::RFC2822, + DATE_RFC3339 == DateTime::RFC3339, + DATE_RSS == DateTime::RSS, + DATE_W3C == DateTime::W3C + ); +?> +--EXPECT-- +string(25) "2006-07-01T14:27:30+02:00" +string(25) "2006-05-30T14:32:13+02:00" +string(33) "Saturday, 01-Jul-06 14:27:30 CEST" +string(32) "Tuesday, 30-May-06 14:32:13 CEST" +string(24) "2006-07-01T14:27:30+0200" +string(24) "2006-05-30T14:32:13+0200" +string(29) "Sat, 01 Jul 06 14:27:30 +0200" +string(29) "Tue, 30 May 06 14:32:13 +0200" +string(33) "Saturday, 01-Jul-06 14:27:30 CEST" +string(32) "Tuesday, 30-May-06 14:32:13 CEST" +string(29) "Sat, 01 Jul 06 14:27:30 +0200" +string(29) "Tue, 30 May 06 14:32:13 +0200" +string(31) "Sat, 01 Jul 2006 14:27:30 +0200" +string(31) "Tue, 30 May 2006 14:32:13 +0200" +string(31) "Sat, 01 Jul 2006 14:27:30 +0200" +string(31) "Tue, 30 May 2006 14:32:13 +0200" +string(25) "2006-07-01T14:27:30+02:00" +string(25) "2006-05-30T14:32:13+02:00" +string(31) "Sat, 01 Jul 2006 14:27:30 +0200" +string(31) "Tue, 30 May 2006 14:32:13 +0200" +string(25) "2006-07-01T14:27:30+02:00" +string(25) "2006-05-30T14:32:13+02:00" + +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/ext/date/tests/date_create-1.phpt b/ext/date/tests/date_create-1.phpt index c66bb6fd3..365d54dc9 100644 --- a/ext/date/tests/date_create-1.phpt +++ b/ext/date/tests/date_create-1.phpt @@ -28,7 +28,7 @@ $d[] = date_create("2005-07-14 22:30:41 Europe/Oslo", $tz1); $d[] = date_create("2005-07-14 22:30:41 America/Los_Angeles", $tz2); foreach($d as $date) { - echo $date->format(date::ISO8601), "\n"; + echo $date->format(DateTime::ISO8601), "\n"; } ?> --EXPECT-- diff --git a/ext/date/tests/date_create-2.phpt b/ext/date/tests/date_create-2.phpt index d7c785e22..4aa33595d 100644 --- a/ext/date/tests/date_create-2.phpt +++ b/ext/date/tests/date_create-2.phpt @@ -6,7 +6,7 @@ date_create() function [2] <?php date_default_timezone_set("GMT"); $d = date_create("2005-07-18 22:10:00 +0400"); -echo $d->format(date::RFC822), "\n"; +echo $d->format('D, d M Y H:i:s T'), "\n"; ?> --EXPECT-- Mon, 18 Jul 2005 22:10:00 GMT+0400 diff --git a/ext/date/tests/date_modify-1.phpt b/ext/date/tests/date_modify-1.phpt index dc03f5ff9..7707b7fc2 100644 --- a/ext/date/tests/date_modify-1.phpt +++ b/ext/date/tests/date_modify-1.phpt @@ -6,20 +6,20 @@ date_modify() function [1] <?php date_default_timezone_set("Pacific/Kwajalein"); $ts = date_create("Thu Aug 19 1993 23:59:59"); -echo date_format($ts, date::RFC822), "\n"; +echo date_format($ts, 'D, d M Y H:i:s T'), "\n"; $ts->modify("+1 second"); -echo date_format($ts, date::RFC822), "\n"; +echo date_format($ts, 'D, d M Y H:i:s T'), "\n"; date_default_timezone_set("Europe/Amsterdam"); $ts = date_create("Sun Mar 27 01:59:59 2005"); -echo date_format($ts, date::RFC822), "\n"; +echo date_format($ts, 'D, d M Y H:i:s T'), "\n"; $ts->modify("+1 second"); -echo date_format($ts, date::RFC822), "\n"; +echo date_format($ts, 'D, d M Y H:i:s T'), "\n"; $ts = date_create("Sun Oct 30 01:59:59 2005"); -echo date_format($ts, date::RFC822), "\n"; +echo date_format($ts, 'D, d M Y H:i:s T'), "\n"; $ts->modify("+ 1 hour 1 second"); -echo date_format($ts, date::RFC822), "\n"; +echo date_format($ts, 'D, d M Y H:i:s T'), "\n"; ?> --EXPECT-- Thu, 19 Aug 1993 23:59:59 KWAT diff --git a/ext/date/tests/date_modify-2.phpt b/ext/date/tests/date_modify-2.phpt index 9bf7a5d2d..cc197fcdc 100644 --- a/ext/date/tests/date_modify-2.phpt +++ b/ext/date/tests/date_modify-2.phpt @@ -6,9 +6,9 @@ date_modify() function [2] <?php date_default_timezone_set("GMT"); $d = date_create("2005-07-18 22:10:00 +0400"); -echo date_format($d, date::RFC822), "\n"; +echo date_format($d, 'D, d M Y H:i:s T'), "\n"; date_modify($d, "+1 hour"); -echo date_format($d, date::RFC822), "\n"; +echo date_format($d, 'D, d M Y H:i:s T'), "\n"; ?> --EXPECT-- Mon, 18 Jul 2005 22:10:00 GMT+0400 diff --git a/ext/date/tests/oo_001.phpt b/ext/date/tests/oo_001.phpt new file mode 100644 index 000000000..9b6142158 --- /dev/null +++ b/ext/date/tests/oo_001.phpt @@ -0,0 +1,53 @@ +--TEST-- +date OO interface +--INI-- +date.timezone=UTC +--FILE-- +<?php +class _d extends DateTime { + function __construct() { + } +} +class _t extends DateTimeZone { + function __construct() { + } +} + +$d = new DateTime; +var_dump($d->format("Y-m-d H:i:s")); + +$d = new _d; +var_dump($d->format("Y-m-d H:i:s")); + +try { + new DateTime("1am todax"); +} catch (Exception $e) { + echo $e->getMessage(),"\n"; +} + +$t = new DateTimeZone("UTC"); +var_dump($t->getName()); + +$t = new _t; +var_dump($t->getName()); + +try { + new DateTimeZone("GottaFindThisOne"); +} catch (Exception $e) { + echo $e->getMessage(),"\n"; +} + +echo "DONE\n"; +?> +--EXPECTF-- +string(19) "%d-%d-%d %d:%d:%d" + +Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in %soo_001.php on line %d +bool(false) +DateTime::__construct(): Failed to parse time string (1am todax) at position 4 (t): The timezone could not be found in the database +string(3) "UTC" + +Warning: DateTimeZone::getName(): The DateTimeZone object has not been correctly initialized by its constructor in %soo_001.php on line %d +bool(false) +DateTimeZone::__construct(): Unknown or bad timezone (GottaFindThisOne) +DONE diff --git a/ext/date/tests/oo_002.phpt b/ext/date/tests/oo_002.phpt new file mode 100644 index 000000000..a83cb583b --- /dev/null +++ b/ext/date/tests/oo_002.phpt @@ -0,0 +1,28 @@ +--TEST-- +date OO cloning +--INI-- +date.timezone=Europe/Berlin +--FILE-- +<?php +class _d extends DateTime {} +class _t extends DateTimeZone {} +$d = new _d("1pm Aug 1 GMT"); +var_dump($d->format(DateTime::RFC822)); +$c = clone $d; +var_dump($c->format(DateTime::RFC822)); +$d->modify("1 hour after"); +$c->modify("1 second ago"); +var_dump($d->format(DateTime::RFC822)); +var_dump($c->format(DateTime::RFC822)); +$t = new _t("Asia/Tokyo"); +var_dump($t->getName()); +$c = clone $t; +var_dump($c->getName()); +?> +--EXPECT-- +string(29) "Tue, 01 Aug 06 13:00:00 +0000" +string(29) "Tue, 01 Aug 06 13:00:00 +0000" +string(29) "Tue, 01 Aug 06 14:00:00 +0000" +string(29) "Tue, 01 Aug 06 12:59:59 +0000" +string(10) "Asia/Tokyo" +string(10) "Asia/Tokyo" diff --git a/ext/date/tests/strtotime-mysql.phpt b/ext/date/tests/strtotime-mysql.phpt new file mode 100755 index 000000000..88a8f10fe --- /dev/null +++ b/ext/date/tests/strtotime-mysql.phpt @@ -0,0 +1,25 @@ +--TEST-- +strtotime() and mysql timestamps +--FILE-- +<?php +date_default_timezone_set('UTC'); + +/* Format: YYYYMMDDHHMMSS */ +$d[] = '19970523091528'; +$d[] = '20001231185859'; +$d[] = '20800410101010'; // overflow.. + +foreach($d as $date) { + $time = strtotime($date); + + if (is_integer($time)) { + var_dump(date('r', $time)); + } else { + var_dump($time); + } +} +?> +--EXPECT-- +string(31) "Fri, 23 May 1997 09:15:28 +0000" +string(31) "Sun, 31 Dec 2000 18:58:59 +0000" +bool(false) diff --git a/ext/date/tests/strtotime2.phpt b/ext/date/tests/strtotime2.phpt new file mode 100644 index 000000000..b8b605923 --- /dev/null +++ b/ext/date/tests/strtotime2.phpt @@ -0,0 +1,40 @@ +--TEST-- +strtotime() on date constants +--FILE-- +<?php + +date_default_timezone_set("Europe/Oslo"); +$time = time(); + +$constants = array( + 'DATE_ATOM', + 'DATE_COOKIE', + 'DATE_ISO8601', + 'DATE_RFC822', + 'DATE_RFC850', + 'DATE_RFC1036', + 'DATE_RFC1123', + 'DATE_RFC2822', + 'DATE_RFC3339', + 'DATE_RSS', + 'DATE_W3C' +); + + +foreach ($constants as $const) { + echo "$const:\t"; + echo ((strtotime(date(constant($const), $time)) === $time) ? "OK" : "FAIL") . "\n"; +} +?> +--EXPECT-- +DATE_ATOM: OK +DATE_COOKIE: OK +DATE_ISO8601: OK +DATE_RFC822: OK +DATE_RFC850: OK +DATE_RFC1036: OK +DATE_RFC1123: OK +DATE_RFC2822: OK +DATE_RFC3339: OK +DATE_RSS: OK +DATE_W3C: OK diff --git a/ext/date/tests/strtotime3.phpt b/ext/date/tests/strtotime3.phpt new file mode 100644 index 000000000..c5d13d8a6 --- /dev/null +++ b/ext/date/tests/strtotime3.phpt @@ -0,0 +1,69 @@ +--TEST-- +strtotime() function +--FILE-- +<?php +date_default_timezone_set('Europe/Lisbon'); +$time = 1150494719; // 16/June/2006 + +$strs = array( + '', + " \t\r\n000", + 'yesterday', + '22:49:12', + '22:49:12 bogusTZ', + '22.49.12.42GMT', + '22.49.12.42bogusTZ', + 't0222', + 't0222 t0222', + '022233', + '022233 bogusTZ', + '2-3-2004', + '2.3.2004', + '20060212T23:12:23UTC', + '20060212T23:12:23 bogusTZ', + '2006167', //pgydotd + 'Jan-15-2006', //pgtextshort + '2006-Jan-15', //pgtextreverse + '10/Oct/2000:13:55:36 +0100', //clf + '10/Oct/2000:13:55:36 +00100', //clf + '2006', + '1986', // year + 'JAN', + 'January', +); + +foreach ($strs as $str) { + $t = strtotime($str, $time); + if (is_integer($t)) { + var_dump(date(DATE_RFC2822, $t)); + } else { + var_dump($t); + } +} + +?> +--EXPECT-- +bool(false) +bool(false) +string(31) "Thu, 15 Jun 2006 00:00:00 +0100" +string(31) "Fri, 16 Jun 2006 22:49:12 +0100" +bool(false) +string(31) "Fri, 16 Jun 2006 23:49:12 +0100" +bool(false) +string(31) "Fri, 16 Jun 2006 02:22:00 +0100" +bool(false) +string(31) "Fri, 16 Jun 2006 02:22:33 +0100" +bool(false) +string(31) "Tue, 02 Mar 2004 00:00:00 +0000" +string(31) "Tue, 02 Mar 2004 00:00:00 +0000" +string(31) "Sun, 12 Feb 2006 23:12:23 +0000" +bool(false) +string(31) "Fri, 16 Jun 2006 00:00:00 +0100" +string(31) "Sun, 15 Jan 2006 00:00:00 +0000" +string(31) "Sun, 15 Jan 2006 00:00:00 +0000" +string(31) "Tue, 10 Oct 2000 13:55:36 +0100" +bool(false) +string(31) "Fri, 16 Jun 2006 20:06:00 +0100" +string(31) "Mon, 16 Jun 1986 22:51:59 +0100" +string(31) "Mon, 16 Jan 2006 00:00:00 +0000" +string(31) "Mon, 16 Jan 2006 00:00:00 +0000" diff --git a/ext/date/tests/timezones.phpt b/ext/date/tests/timezones.phpt new file mode 100644 index 000000000..c7e470ab8 --- /dev/null +++ b/ext/date/tests/timezones.phpt @@ -0,0 +1,26 @@ +--TEST-- +setting bogus timezones +--FILE-- +<?php + +//bogus +var_dump(date_default_timezone_set('AAA')); +var_dump(date_default_timezone_set('ZZZ')); + + +//now the first and the last one +var_dump(date_default_timezone_set("Africa/Abidjan")); +var_dump(date_default_timezone_set("Zulu")); + +echo "done\n"; + +?> +--EXPECTF-- +Notice: date_default_timezone_set(): Timezone ID 'AAA' is invalid in %stimezones.php on line 4 +bool(false) + +Notice: date_default_timezone_set(): Timezone ID 'ZZZ' is invalid in %stimezones.php on line 5 +bool(false) +bool(true) +bool(true) +done |
