diff options
| author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:37:27 -0400 |
|---|---|---|
| committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:37:27 -0400 |
| commit | 2d4e5b09576bb4f0ba716cc82cdf29ea04d9184b (patch) | |
| tree | 41ccc042009cba53e4ce43e727fcba4c1cfbf7f3 /ext/date/tests | |
| parent | d29a4fd2dd3b5d4cf6e80b602544d7b71d794e76 (diff) | |
| download | php-upstream/5.2.2.tar.gz | |
Imported Upstream version 5.2.2upstream/5.2.2
Diffstat (limited to 'ext/date/tests')
| -rw-r--r-- | ext/date/tests/010.phpt | 653 | ||||
| -rw-r--r-- | ext/date/tests/011.phpt | 23 | ||||
| -rw-r--r-- | ext/date/tests/012.phpt | 37 | ||||
| -rw-r--r-- | ext/date/tests/013.phpt | 38 | ||||
| -rw-r--r-- | ext/date/tests/014.phpt | 33 | ||||
| -rw-r--r-- | ext/date/tests/bug35885.phpt | 8 | ||||
| -rw-r--r-- | ext/date/tests/bug37514.phpt | 22 | ||||
| -rw-r--r-- | ext/date/tests/bug39782.phpt | 19 | ||||
| -rw-r--r-- | ext/date/tests/bug40861.phpt | 33 | ||||
| -rw-r--r-- | ext/date/tests/date_parse_001.phpt | 303 | ||||
| -rw-r--r-- | ext/date/tests/date_sun_info_001.phpt | 32 | ||||
| -rw-r--r-- | ext/date/tests/date_sun_info_002.phpt | 24 | ||||
| -rw-r--r-- | ext/date/tests/oo_002.phpt | 8 |
13 files changed, 1217 insertions, 16 deletions
diff --git a/ext/date/tests/010.phpt b/ext/date/tests/010.phpt new file mode 100644 index 000000000..3cba29f01 --- /dev/null +++ b/ext/date/tests/010.phpt @@ -0,0 +1,653 @@ +--TEST-- +timezone_abbreviations_list() tests +--INI-- +date.timezone=UTC +--FILE-- +<?php + $timezone_abbreviations = timezone_abbreviations_list(); + var_dump($timezone_abbreviations["est"]); + echo "Done\n"; +?> +--EXPECTF-- +array(71) { + [0]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(16) "America/New_York" + } + [1]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(15) "America/Antigua" + } + [2]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(16) "America/Atikokan" + } + [3]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(21) "America/Cambridge_Bay" + } + [4]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(14) "America/Cancun" + } + [5]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(14) "America/Cayman" + } + [6]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(15) "America/Chicago" + } + [7]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(21) "America/Coral_Harbour" + } + [8]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(15) "America/Detroit" + } + [9]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(18) "America/Fort_Wayne" + } + [10]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(18) "America/Grand_Turk" + } + [11]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(28) "America/Indiana/Indianapolis" + } + [12]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(20) "America/Indiana/Knox" + } + [13]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(23) "America/Indiana/Marengo" + } + [14]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(26) "America/Indiana/Petersburg" + } + [15]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(21) "America/Indiana/Vevay" + } + [16]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(25) "America/Indiana/Vincennes" + } + [17]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(23) "America/Indiana/Winamac" + } + [18]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(20) "America/Indianapolis" + } + [19]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(15) "America/Iqaluit" + } + [20]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(15) "America/Jamaica" + } + [21]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(27) "America/Kentucky/Louisville" + } + [22]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(27) "America/Kentucky/Monticello" + } + [23]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(15) "America/Knox_IN" + } + [24]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(18) "America/Louisville" + } + [25]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(15) "America/Managua" + } + [26]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(17) "America/Menominee" + } + [27]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(14) "America/Merida" + } + [28]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(16) "America/Montreal" + } + [29]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(14) "America/Nassau" + } + [30]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(15) "America/Nipigon" + } + [31]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(14) "America/Panama" + } + [32]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(19) "America/Pangnirtung" + } + [33]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(22) "America/Port-au-Prince" + } + [34]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(20) "America/Rankin_Inlet" + } + [35]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(21) "America/Santo_Domingo" + } + [36]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(19) "America/Thunder_Bay" + } + [37]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(15) "America/Toronto" + } + [38]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(14) "Canada/Eastern" + } + [39]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(3) "EST" + } + [40]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(7) "EST5EDT" + } + [41]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(7) "Jamaica" + } + [42]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(10) "US/Central" + } + [43]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(15) "US/East-Indiana" + } + [44]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(10) "US/Eastern" + } + [45]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(17) "US/Indiana-Starke" + } + [46]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(-18000) + ["timezone_id"]=> + string(11) "US/Michigan" + } + [47]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(36000) + ["timezone_id"]=> + string(13) "Australia/ACT" + } + [48]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(36000) + ["timezone_id"]=> + string(18) "Australia/Brisbane" + } + [49]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(36000) + ["timezone_id"]=> + string(18) "Australia/Canberra" + } + [50]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(36000) + ["timezone_id"]=> + string(16) "Australia/Currie" + } + [51]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(36000) + ["timezone_id"]=> + string(16) "Australia/Hobart" + } + [52]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(36000) + ["timezone_id"]=> + string(18) "Australia/Lindeman" + } + [53]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(36000) + ["timezone_id"]=> + string(19) "Australia/Melbourne" + } + [54]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(36000) + ["timezone_id"]=> + string(13) "Australia/NSW" + } + [55]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(36000) + ["timezone_id"]=> + string(20) "Australia/Queensland" + } + [56]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(36000) + ["timezone_id"]=> + string(16) "Australia/Sydney" + } + [57]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(36000) + ["timezone_id"]=> + string(18) "Australia/Tasmania" + } + [58]=> + array(3) { + ["dst"]=> + bool(false) + ["offset"]=> + int(36000) + ["timezone_id"]=> + string(18) "Australia/Victoria" + } + [59]=> + array(3) { + ["dst"]=> + bool(true) + ["offset"]=> + int(39600) + ["timezone_id"]=> + string(19) "Australia/Melbourne" + } + [60]=> + array(3) { + ["dst"]=> + bool(true) + ["offset"]=> + int(39600) + ["timezone_id"]=> + string(13) "Australia/ACT" + } + [61]=> + array(3) { + ["dst"]=> + bool(true) + ["offset"]=> + int(39600) + ["timezone_id"]=> + string(18) "Australia/Brisbane" + } + [62]=> + array(3) { + ["dst"]=> + bool(true) + ["offset"]=> + int(39600) + ["timezone_id"]=> + string(18) "Australia/Canberra" + } + [63]=> + array(3) { + ["dst"]=> + bool(true) + ["offset"]=> + int(39600) + ["timezone_id"]=> + string(16) "Australia/Currie" + } + [64]=> + array(3) { + ["dst"]=> + bool(true) + ["offset"]=> + int(39600) + ["timezone_id"]=> + string(16) "Australia/Hobart" + } + [65]=> + array(3) { + ["dst"]=> + bool(true) + ["offset"]=> + int(39600) + ["timezone_id"]=> + string(18) "Australia/Lindeman" + } + [66]=> + array(3) { + ["dst"]=> + bool(true) + ["offset"]=> + int(39600) + ["timezone_id"]=> + string(13) "Australia/NSW" + } + [67]=> + array(3) { + ["dst"]=> + bool(true) + ["offset"]=> + int(39600) + ["timezone_id"]=> + string(20) "Australia/Queensland" + } + [68]=> + array(3) { + ["dst"]=> + bool(true) + ["offset"]=> + int(39600) + ["timezone_id"]=> + string(16) "Australia/Sydney" + } + [69]=> + array(3) { + ["dst"]=> + bool(true) + ["offset"]=> + int(39600) + ["timezone_id"]=> + string(18) "Australia/Tasmania" + } + [70]=> + array(3) { + ["dst"]=> + bool(true) + ["offset"]=> + int(39600) + ["timezone_id"]=> + string(18) "Australia/Victoria" + } +} +Done diff --git a/ext/date/tests/011.phpt b/ext/date/tests/011.phpt new file mode 100644 index 000000000..1302f1d21 --- /dev/null +++ b/ext/date/tests/011.phpt @@ -0,0 +1,23 @@ +--TEST-- +timezone_name_from_abbr() tests +--INI-- +date.timezone=UTC +--FILE-- +<?php + +var_dump(timezone_name_from_abbr()); +var_dump(timezone_name_from_abbr("CET")); +var_dump(timezone_name_from_abbr("AEST")); +var_dump(timezone_name_from_abbr("", 3600)); +var_dump(timezone_name_from_abbr("", 3600, 0)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: timezone_name_from_abbr() expects at least 1 parameter, 0 given in %s on line 3 +bool(false) +string(13) "Europe/Berlin" +bool(false) +bool(false) +string(12) "Europe/Paris" +Done diff --git a/ext/date/tests/012.phpt b/ext/date/tests/012.phpt new file mode 100644 index 000000000..1eaeca099 --- /dev/null +++ b/ext/date/tests/012.phpt @@ -0,0 +1,37 @@ +--TEST-- +date_isodate_set() tests +--INI-- +date.timezone=UTC +--FILE-- +<?php + +$dto = date_create("2006-12-12"); +var_dump(date_isodate_set($dto, 2006, 2, 15)); +var_dump($dto->format("Y/m/d H:i:s")); +var_dump(date_isodate_set($dto, 2006)); +var_dump($dto->format("Y/m/d H:i:s")); +var_dump(date_isodate_set($dto, 2006, 5)); +var_dump($dto->format("Y/m/d H:i:s")); +var_dump(date_isodate_set($dto, 2006, 100, 15)); +var_dump($dto->format("Y/m/d H:i:s")); +var_dump(date_isodate_set($dto, 2006, 100, 15, 10)); +var_dump($dto->format("Y/m/d H:i:s")); + +echo "Done\n"; +?> +--EXPECTF-- +NULL +string(19) "2006/01/23 00:00:00" + +Warning: date_isodate_set() expects at least 3 parameters, 2 given in %s on line %d +bool(false) +string(19) "2006/01/23 00:00:00" +NULL +string(19) "2006/01/30 00:00:00" +NULL +string(19) "2007/12/10 00:00:00" + +Warning: date_isodate_set() expects at most 4 parameters, 5 given in %s on line %d +bool(false) +string(19) "2007/12/10 00:00:00" +Done diff --git a/ext/date/tests/013.phpt b/ext/date/tests/013.phpt new file mode 100644 index 000000000..f30954ada --- /dev/null +++ b/ext/date/tests/013.phpt @@ -0,0 +1,38 @@ +--TEST-- +date_date_set() tests +--INI-- +date.timezone=UTC +--FILE-- +<?php + +$dto = date_create("2006-12-12"); +var_dump($dto); +var_dump($dto->format("Y.m.d H:i:s")); +var_dump(date_date_set()); +var_dump($dto->format("Y.m.d H:i:s")); +var_dump(date_date_set($dto, 2006, 5)); +var_dump($dto->format("Y.m.d H:i:s")); +var_dump(date_date_set($dto, 2006, 2, 15)); +var_dump($dto->format("Y.m.d H:i:s")); +var_dump(date_date_set($dto, 2006, 24, 60)); +var_dump($dto->format("Y.m.d H:i:s")); + +echo "Done\n"; +?> +--EXPECTF-- +object(DateTime)#%d (0) { +} +string(19) "2006.12.12 00:00:00" + +Warning: date_date_set() expects exactly 4 parameters, 0 given in %s on line %d +bool(false) +string(19) "2006.12.12 00:00:00" + +Warning: date_date_set() expects exactly 4 parameters, 3 given in %s on line %d +bool(false) +string(19) "2006.12.12 00:00:00" +NULL +string(19) "2006.02.15 00:00:00" +NULL +string(19) "2008.01.29 00:00:00" +Done diff --git a/ext/date/tests/014.phpt b/ext/date/tests/014.phpt new file mode 100644 index 000000000..af57e55dd --- /dev/null +++ b/ext/date/tests/014.phpt @@ -0,0 +1,33 @@ +--TEST-- +timezone_offset_get() tests +--INI-- +date.timezone=UTC +--FILE-- +<?php + +$dto = date_create("2006-12-12"); +var_dump($dto); + +$dtz = date_timezone_get($dto); +var_dump($dtz); + +var_dump(timezone_offset_get()); +var_dump(timezone_offset_get($dtz, $dto)); +var_dump(timezone_offset_get($dto, $dtz)); + +echo "Done\n"; + +?> +--EXPECTF-- +object(DateTime)#%d (0) { +} +object(DateTimeZone)#%d (0) { +} + +Warning: timezone_offset_get() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) +int(0) + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d +bool(false) +Done diff --git a/ext/date/tests/bug35885.phpt b/ext/date/tests/bug35885.phpt index 5f4e5d58c..60fc2ca69 100644 --- a/ext/date/tests/bug35885.phpt +++ b/ext/date/tests/bug35885.phpt @@ -7,7 +7,13 @@ date_default_timezone_set("UTC"); $ts = date(DATE_ISO8601, strtotime('NOW')); $ts2 = date(DATE_ISO8601, time()); -var_dump($ts == $ts2); +$res = ($ts == $ts2); +var_dump($res); + +if (!$res) { + var_dump($ts); + var_dump($ts2); +} ?> --EXPECT-- diff --git a/ext/date/tests/bug37514.phpt b/ext/date/tests/bug37514.phpt index 31318b46a..abbb4407c 100644 --- a/ext/date/tests/bug37514.phpt +++ b/ext/date/tests/bug37514.phpt @@ -4,17 +4,17 @@ Bug #37514 (strtotime doesn't assume year correctly). 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"; +echo date('r', strtotime('May 18th 5:05', 1168156376)), "\n"; +echo date('r', strtotime('May 18th 5:05pm', 1168156376)), "\n"; +echo date('r', strtotime('May 18th 5:05 pm', 1168156376)), "\n"; +echo date('r', strtotime('May 18th 5:05am', 1168156376)), "\n"; +echo date('r', strtotime('May 18th 5:05 am', 1168156376)), "\n"; +echo date('r', strtotime('May 18th 2006 5:05pm', 1168156376)), "\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 +Fri, 18 May 2007 05:05:00 +0000 +Fri, 18 May 2007 17:05:00 +0000 +Fri, 18 May 2007 17:05:00 +0000 +Fri, 18 May 2007 05:05:00 +0000 +Fri, 18 May 2007 05:05:00 +0000 Thu, 18 May 2006 17:05:00 +0000 diff --git a/ext/date/tests/bug39782.phpt b/ext/date/tests/bug39782.phpt new file mode 100644 index 000000000..99abdd7bc --- /dev/null +++ b/ext/date/tests/bug39782.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #39782 (setTime() on a DateTime constructed with a Weekday yields incorrect results) +--FILE-- +<?php +date_default_timezone_set("GMT"); + +$dttTest = new DateTime('Dec 10 2006 Next Wednesday'); +echo $dttTest->format('D M j Y - H:i:s') . "\n"; + +$dttTest->setTime(12, 0, 0); +echo $dttTest->format('D M j Y - H:i:s') . "\n"; + +$dttTest->setTime(12, 0, 0); +echo $dttTest->format('D M j Y - H:i:s') . "\n"; +?> +--EXPECT-- +Wed Dec 13 2006 - 00:00:00 +Wed Dec 13 2006 - 12:00:00 +Wed Dec 13 2006 - 12:00:00
\ No newline at end of file diff --git a/ext/date/tests/bug40861.phpt b/ext/date/tests/bug40861.phpt new file mode 100644 index 000000000..d4ef96198 --- /dev/null +++ b/ext/date/tests/bug40861.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #40861 (Multiple +/- on relative units breaks strtotime()) +--FILE-- +<?php +date_default_timezone_set("GMT"); + +$offset = +60; +$ts = strtotime('2000-01-01 12:00:00'); +$result = date("Y-m-d H:i:s", strtotime("+$offset minutes", $ts)); +echo $result . "\n"; + +$offset = -60; +$ts = strtotime('2000-01-01 12:00:00'); +$result = date("Y-m-d H:i:s", strtotime("+$offset minutes", $ts)); +echo $result . "\n"; + +$offset = -60; +$ts = strtotime('2000-01-01 12:00:00'); +$result = date("Y-m-d H:i:s", strtotime("-$offset minutes", $ts)); +echo $result . "\n"; + + +$offset = 60; +$ts = strtotime('2000-01-01 12:00:00'); +$result = date("Y-m-d H:i:s", strtotime("+$offset minutes", $ts)); +echo $result . "\n"; + +?> +--EXPECT-- +2000-01-01 13:00:00 +2000-01-01 11:00:00 +2000-01-01 13:00:00 +2000-01-01 13:00:00 diff --git a/ext/date/tests/date_parse_001.phpt b/ext/date/tests/date_parse_001.phpt new file mode 100644 index 000000000..205380fc9 --- /dev/null +++ b/ext/date/tests/date_parse_001.phpt @@ -0,0 +1,303 @@ +--TEST-- +Test basic date_parse() +--INI-- +date.timezone=UTC +--FILE-- +<?php + var_dump(date_parse("2006-12-12 10:00:00.5")); + var_dump(date_parse("2006-12-12")); + var_dump(date_parse("2006-12--12")); + var_dump(date_parse("2006-02-30")); + var_dump(date_parse("2006-03-04")); + var_dump(date_parse("2006-03")); + var_dump(date_parse("03-03")); + var_dump(date_parse("0-0")); + var_dump(date_parse("")); + var_dump(date_parse(array())); + echo "Done\n"; +?> +--EXPECTF-- +array(12) { + ["year"]=> + int(2006) + ["month"]=> + int(12) + ["day"]=> + int(12) + ["hour"]=> + int(10) + ["minute"]=> + int(0) + ["second"]=> + int(0) + ["fraction"]=> + float(0.5) + ["warning_count"]=> + int(0) + ["warnings"]=> + array(0) { + } + ["error_count"]=> + int(0) + ["errors"]=> + array(0) { + } + ["is_localtime"]=> + bool(false) +} +array(12) { + ["year"]=> + int(2006) + ["month"]=> + int(12) + ["day"]=> + int(12) + ["hour"]=> + bool(false) + ["minute"]=> + bool(false) + ["second"]=> + bool(false) + ["fraction"]=> + bool(false) + ["warning_count"]=> + int(0) + ["warnings"]=> + array(0) { + } + ["error_count"]=> + int(0) + ["errors"]=> + array(0) { + } + ["is_localtime"]=> + bool(false) +} +array(15) { + ["year"]=> + int(2006) + ["month"]=> + int(12) + ["day"]=> + bool(false) + ["hour"]=> + bool(false) + ["minute"]=> + bool(false) + ["second"]=> + bool(false) + ["fraction"]=> + bool(false) + ["warning_count"]=> + int(0) + ["warnings"]=> + array(0) { + } + ["error_count"]=> + int(1) + ["errors"]=> + array(1) { + [7]=> + string(20) "Unexpected character" + } + ["is_localtime"]=> + bool(true) + ["zone_type"]=> + int(1) + ["zone"]=> + int(720) + ["is_dst"]=> + bool(false) +} +array(12) { + ["year"]=> + int(2006) + ["month"]=> + int(2) + ["day"]=> + int(30) + ["hour"]=> + bool(false) + ["minute"]=> + bool(false) + ["second"]=> + bool(false) + ["fraction"]=> + bool(false) + ["warning_count"]=> + int(0) + ["warnings"]=> + array(0) { + } + ["error_count"]=> + int(0) + ["errors"]=> + array(0) { + } + ["is_localtime"]=> + bool(false) +} +array(12) { + ["year"]=> + int(2006) + ["month"]=> + int(3) + ["day"]=> + int(4) + ["hour"]=> + bool(false) + ["minute"]=> + bool(false) + ["second"]=> + bool(false) + ["fraction"]=> + bool(false) + ["warning_count"]=> + int(0) + ["warnings"]=> + array(0) { + } + ["error_count"]=> + int(0) + ["errors"]=> + array(0) { + } + ["is_localtime"]=> + bool(false) +} +array(12) { + ["year"]=> + int(2006) + ["month"]=> + int(3) + ["day"]=> + bool(false) + ["hour"]=> + bool(false) + ["minute"]=> + bool(false) + ["second"]=> + bool(false) + ["fraction"]=> + bool(false) + ["warning_count"]=> + int(0) + ["warnings"]=> + array(0) { + } + ["error_count"]=> + int(0) + ["errors"]=> + array(0) { + } + ["is_localtime"]=> + bool(false) +} +array(15) { + ["year"]=> + bool(false) + ["month"]=> + bool(false) + ["day"]=> + bool(false) + ["hour"]=> + bool(false) + ["minute"]=> + bool(false) + ["second"]=> + bool(false) + ["fraction"]=> + bool(false) + ["warning_count"]=> + int(0) + ["warnings"]=> + array(0) { + } + ["error_count"]=> + int(2) + ["errors"]=> + array(2) { + [0]=> + string(20) "Unexpected character" + [1]=> + string(20) "Unexpected character" + } + ["is_localtime"]=> + bool(true) + ["zone_type"]=> + int(1) + ["zone"]=> + int(180) + ["is_dst"]=> + bool(false) +} +array(15) { + ["year"]=> + bool(false) + ["month"]=> + bool(false) + ["day"]=> + bool(false) + ["hour"]=> + bool(false) + ["minute"]=> + bool(false) + ["second"]=> + bool(false) + ["fraction"]=> + bool(false) + ["warning_count"]=> + int(0) + ["warnings"]=> + array(0) { + } + ["error_count"]=> + int(1) + ["errors"]=> + array(1) { + [0]=> + string(20) "Unexpected character" + } + ["is_localtime"]=> + bool(true) + ["zone_type"]=> + int(1) + ["zone"]=> + int(0) + ["is_dst"]=> + bool(false) +} +array(12) { + ["year"]=> + bool(false) + ["month"]=> + bool(false) + ["day"]=> + bool(false) + ["hour"]=> + bool(false) + ["minute"]=> + bool(false) + ["second"]=> + bool(false) + ["fraction"]=> + bool(false) + ["warning_count"]=> + int(0) + ["warnings"]=> + array(0) { + } + ["error_count"]=> + int(1) + ["errors"]=> + array(1) { + [0]=> + string(12) "Empty string" + } + ["is_localtime"]=> + bool(false) +} + +Warning: date_parse() expects parameter 1 to be string, array given in %s on line %d +bool(false) +Done diff --git a/ext/date/tests/date_sun_info_001.phpt b/ext/date/tests/date_sun_info_001.phpt new file mode 100644 index 000000000..d469e37e7 --- /dev/null +++ b/ext/date/tests/date_sun_info_001.phpt @@ -0,0 +1,32 @@ +--TEST-- +Test basic date_sun_info() +--INI-- +date.timezone=UTC +--FILE-- +<?php +$sun_info = date_sun_info(strtotime("2006-12-12"), 31.7667, 35.2333); +var_dump($sun_info); +echo "Done\n"; +?> +--EXPECTF-- +array(9) { + ["sunrise"]=> + int(1165897782) + ["sunset"]=> + int(1165934168) + ["transit"]=> + int(1165915975) + ["civil_twilight_begin"]=> + int(1165896176) + ["civil_twilight_end"]=> + int(1165935773) + ["nautical_twilight_begin"]=> + int(1165894353) + ["nautical_twilight_end"]=> + int(1165937597) + ["astronomical_twilight_begin"]=> + int(1165892570) + ["astronomical_twilight_end"]=> + int(1165939380) +} +Done diff --git a/ext/date/tests/date_sun_info_002.phpt b/ext/date/tests/date_sun_info_002.phpt new file mode 100644 index 000000000..b41d123d9 --- /dev/null +++ b/ext/date/tests/date_sun_info_002.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test basic date_sun_info() +--INI-- +date.timezone=Europe/Oslo +--FILE-- +<?php +$sun_info = date_sun_info(strtotime("2007-04-13 08:31:15 UTC"), 59.21, 9.61); +foreach ($sun_info as $key => $elem ) +{ + echo date( 'Y-m-d H:i:s T', $elem ), " ", $key, "\n"; +} +echo "Done\n"; +?> +--EXPECTF-- +2007-04-13 06:12:19 CEST sunrise +2007-04-13 20:31:50 CEST sunset +2007-04-13 13:22:05 CEST transit +2007-04-13 05:28:03 CEST civil_twilight_begin +2007-04-13 21:16:06 CEST civil_twilight_end +2007-04-13 04:30:08 CEST nautical_twilight_begin +2007-04-13 22:14:01 CEST nautical_twilight_end +2007-04-13 03:14:36 CEST astronomical_twilight_begin +2007-04-13 23:29:33 CEST astronomical_twilight_end +Done diff --git a/ext/date/tests/oo_002.phpt b/ext/date/tests/oo_002.phpt index a83cb583b..e619d9dfe 100644 --- a/ext/date/tests/oo_002.phpt +++ b/ext/date/tests/oo_002.phpt @@ -20,9 +20,9 @@ $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(29) "Wed, 01 Aug 07 13:00:00 +0000" +string(29) "Wed, 01 Aug 07 13:00:00 +0000" +string(29) "Wed, 01 Aug 07 14:00:00 +0000" +string(29) "Wed, 01 Aug 07 12:59:59 +0000" string(10) "Asia/Tokyo" string(10) "Asia/Tokyo" |
