summaryrefslogtreecommitdiff
path: root/ext/date/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/date/tests')
-rw-r--r--ext/date/tests/DatePeriod_wrong_constructor.phpt17
-rw-r--r--ext/date/tests/bug27719.phpt2
-rw-r--r--ext/date/tests/bug45554.phpt20
-rw-r--r--ext/date/tests/bug48058.phpt6
-rw-r--r--ext/date/tests/cal_days_in_month_invalid_calendar.phpt16
-rw-r--r--ext/date/tests/cal_days_in_month_invalid_date.phpt16
-rw-r--r--ext/date/tests/date_sunrise_variation5.phpt8
-rw-r--r--ext/date/tests/date_sunset_variation5.phpt6
-rw-r--r--ext/date/tests/date_timestamp_get.phpt20
-rw-r--r--ext/date/tests/strtotime_basic.phpt12
-rw-r--r--ext/date/tests/timezone_identifiers_list_wrong_constructor.phpt15
-rw-r--r--ext/date/tests/timezone_location_get.phpt24
12 files changed, 145 insertions, 17 deletions
diff --git a/ext/date/tests/DatePeriod_wrong_constructor.phpt b/ext/date/tests/DatePeriod_wrong_constructor.phpt
new file mode 100644
index 000000000..62e6aa98a
--- /dev/null
+++ b/ext/date/tests/DatePeriod_wrong_constructor.phpt
@@ -0,0 +1,17 @@
+--TEST--
+DatePeriod: Test wrong __construct parameter
+--CREDITS--
+Havard Eide <nucleuz@gmail.com>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+new DatePeriod();
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'Exception' with message 'DatePeriod::__construct(): This constructor accepts either (DateTime, DateInterval, int) OR (DateTime, DateInterval, DateTime) OR (string) as arguments.' in %s:%d
+Stack trace:
+#0 %s(%d): DatePeriod->__construct()
+#1 {main}
+ thrown in %s on line %d \ No newline at end of file
diff --git a/ext/date/tests/bug27719.phpt b/ext/date/tests/bug27719.phpt
index b86c32422..e18c9267b 100644
--- a/ext/date/tests/bug27719.phpt
+++ b/ext/date/tests/bug27719.phpt
@@ -4,7 +4,7 @@ Bug #27719 (mktime returns incorrect timestamp for dst days)
date.timezone=EST
error_reporting=2047
--FILE--
-<?php /* $Id: bug27719.phpt,v 1.1.6.1 2009/05/12 19:46:58 felipe Exp $ */
+<?php /* $Id: bug27719.phpt 280398 2009-05-12 19:46:58Z felipe $ */
$a = mktime(0, 0, 0, 4, 4, 2004, 0);
$b = mktime(0, 0, 0, 4, 4, 2004, 1);
$c = mktime(0, 0, 0, 4, 4, 2004, -1);
diff --git a/ext/date/tests/bug45554.phpt b/ext/date/tests/bug45554.phpt
new file mode 100644
index 000000000..9416214e9
--- /dev/null
+++ b/ext/date/tests/bug45554.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #45554 (Inconsistent behavior of the u format char)
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+$format = "m-d-Y H:i:s.u T";
+$d = date_create_from_format($format, "03-15-2005 12:22:29.000000 PST");
+echo $d->format($format), "\n";
+
+$d = date_create_from_format($format, "03-15-2005 12:22:29.001001 PST");
+echo $d->format($format), "\n";
+
+$d = date_create_from_format($format, "03-15-2005 12:22:29.0010 PST");
+var_dump( $d );
+?>
+--EXPECT--
+03-15-2005 12:22:29.000000 PST
+03-15-2005 12:22:29.001000 PST
+bool(false)
diff --git a/ext/date/tests/bug48058.phpt b/ext/date/tests/bug48058.phpt
index 290d3df0f..46a1918b4 100644
--- a/ext/date/tests/bug48058.phpt
+++ b/ext/date/tests/bug48058.phpt
@@ -13,12 +13,12 @@ $base_time = '28 Feb 2008 12:00:00';
$dt = date_create( "$base_time +10000000000 years" );
echo date_format( $dt, DATE_ISO8601 );
?>
---EXPECT--
+--EXPECTF--
array(5) {
["ts"]=>
- int(-9223372036854775808)
+ int(-%d)
["time"]=>
- string(33) "-292277022657-01-27T08:29:52+0000"
+ string(%d) "%s"
["offset"]=>
int(3600)
["isdst"]=>
diff --git a/ext/date/tests/cal_days_in_month_invalid_calendar.phpt b/ext/date/tests/cal_days_in_month_invalid_calendar.phpt
new file mode 100644
index 000000000..3550b91e7
--- /dev/null
+++ b/ext/date/tests/cal_days_in_month_invalid_calendar.phpt
@@ -0,0 +1,16 @@
+--TEST--
+cal_days_in_month: test invalid parameter
+--CREDITS--
+Havard Eide <nucleuz@gmail.com>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--SKIPIF--
+<?php if (!extension_loaded("calendar")) { echo "skip extension not available"; } ?>
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+echo cal_days_in_month(99,0, 2009);
+?>
+--EXPECTF--
+Warning: cal_days_in_month(): invalid calendar ID 99. in %s on line %d
+
diff --git a/ext/date/tests/cal_days_in_month_invalid_date.phpt b/ext/date/tests/cal_days_in_month_invalid_date.phpt
new file mode 100644
index 000000000..031527074
--- /dev/null
+++ b/ext/date/tests/cal_days_in_month_invalid_date.phpt
@@ -0,0 +1,16 @@
+--TEST--
+cal_days_in_month: test invalid parameter
+--CREDITS--
+Havard Eide <nucleuz@gmail.com>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--SKIPIF--
+<?php if (!extension_loaded("calendar")) { echo "skip extension not available"; } ?>
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+echo cal_days_in_month(CAL_GREGORIAN,0, 2009);
+?>
+--EXPECTF--
+Warning: cal_days_in_month(): invalid date. in %s on line %d
+
diff --git a/ext/date/tests/date_sunrise_variation5.phpt b/ext/date/tests/date_sunrise_variation5.phpt
index e697836d1..42674789f 100644
--- a/ext/date/tests/date_sunrise_variation5.phpt
+++ b/ext/date/tests/date_sunrise_variation5.phpt
@@ -113,13 +113,13 @@ bool(false)
bool(false)
--int 12345--
-string(5) "09:52"
-float(9.882%d)
-int(1218169377)
+string(5) "09:51"
+float(9.855%d)
+int(1218169278)
--int -12345--
string(5) "09:54"
-float(9.909%d)
+float(9.9097820911118)
int(1218169475)
--empty array--
diff --git a/ext/date/tests/date_sunset_variation5.phpt b/ext/date/tests/date_sunset_variation5.phpt
index 26bf4ccc9..071963362 100644
--- a/ext/date/tests/date_sunset_variation5.phpt
+++ b/ext/date/tests/date_sunset_variation5.phpt
@@ -113,9 +113,9 @@ bool(false)
bool(false)
--int 12345--
-string(5) "19:19"
-float(19.319%d)
-int(1218203349)
+string(5) "19:20"
+float(19.340%d)
+int(1218203424)
--int -12345--
bool(false)
diff --git a/ext/date/tests/date_timestamp_get.phpt b/ext/date/tests/date_timestamp_get.phpt
new file mode 100644
index 000000000..bdd4d047e
--- /dev/null
+++ b/ext/date/tests/date_timestamp_get.phpt
@@ -0,0 +1,20 @@
+--TEST--
+DateTime: Test correct setup and correct DateTime parameter to date_timestamp_get()
+--CREDITS--
+Havard Eide <nucleuz@gmail.com>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+$tz = date_timestamp_get(new DateTime());
+var_dump(is_int($tz));
+echo "\n\n";
+$tz = date_timestamp_get(time());
+?>
+--EXPECTF--
+bool(true)
+
+
+
+Warning: date_timestamp_get() expects parameter 1 to be DateTime, integer given in %s on line %d \ No newline at end of file
diff --git a/ext/date/tests/strtotime_basic.phpt b/ext/date/tests/strtotime_basic.phpt
index 673b9fb45..75f66978a 100644
--- a/ext/date/tests/strtotime_basic.phpt
+++ b/ext/date/tests/strtotime_basic.phpt
@@ -13,29 +13,29 @@ date_default_timezone_set('UTC');
/*
* This is parsed as the "first following Monday OR the current day if it is a Monday"
*/
-var_dump(date('Y-m-d', strtotime('1 Monday December 2008')));
+var_dump(date('Y-m-d', strtotime('1 Monday December 2008')));
/*
* This is parsed as the "second following Monday OR the first following
* Monday if the current day is a Monday"
*/
-var_dump(date('Y-m-d', strtotime('2 Monday December 2008')));
+var_dump(date('Y-m-d', strtotime('2 Monday December 2008')));
/*
* This is parsed as the "third following Monday OR the second following
* Monday if the current day is a Monday"
*/
-var_dump(date('Y-m-d', strtotime('3 Monday December 2008')));
+var_dump(date('Y-m-d', strtotime('3 Monday December 2008')));
/*
* This is parsed as the "first following Monday after the first Monday in December"
*/
-var_dump(date('Y-m-d', strtotime('first Monday December 2008')));
+var_dump(date('Y-m-d', strtotime('first Monday December 2008')));
/*
* This is parsed as the "second following Monday after the first Monday in December"
*/
-var_dump(date('Y-m-d', strtotime('second Monday December 2008')));
+var_dump(date('Y-m-d', strtotime('second Monday December 2008')));
/*
* This is parsed as the "third following Monday after the first Monday in December"
*/
-var_dump(date('Y-m-d', strtotime('third Monday December 2008')));
+var_dump(date('Y-m-d', strtotime('third Monday December 2008')));
?>
--EXPECTF--
%string|unicode%(10) "2008-12-01"
diff --git a/ext/date/tests/timezone_identifiers_list_wrong_constructor.phpt b/ext/date/tests/timezone_identifiers_list_wrong_constructor.phpt
new file mode 100644
index 000000000..5b8493ba1
--- /dev/null
+++ b/ext/date/tests/timezone_identifiers_list_wrong_constructor.phpt
@@ -0,0 +1,15 @@
+--TEST--
+timezone_identifiers_list: Test that correct notice is given when timezone_identifiers_list is given 4096 as parameter
+--CREDITS--
+Havard Eide <nucleuz@gmail.com>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--INI--
+error_reporting=E_ALL
+date.timezone=UTC
+--FILE--
+<?php
+print_r(timezone_identifiers_list(4096));
+
+?>
+--EXPECTF--
+Notice: timezone_identifiers_list(): A two-letter ISO 3166-1 compatible country code is expected in %s on line %d \ No newline at end of file
diff --git a/ext/date/tests/timezone_location_get.phpt b/ext/date/tests/timezone_location_get.phpt
new file mode 100644
index 000000000..745fc8799
--- /dev/null
+++ b/ext/date/tests/timezone_location_get.phpt
@@ -0,0 +1,24 @@
+--TEST--
+timezone_location_get: Test that timezone_location_get returns a correct array of information
+--CREDITS--
+Havard Eide <nucleuz@gmail.com>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+$location = timezone_location_get(new DateTimeZone("Europe/Oslo"));
+var_dump($location);
+?>
+--EXPECT--
+array(4) {
+ ["country_code"]=>
+ string(2) "NO"
+ ["latitude"]=>
+ float(59.91666)
+ ["longitude"]=>
+ float(10.75)
+ ["comments"]=>
+ string(0) ""
+}
+