cvs: php-src /ext/date/tests strtotime-mysql.phpt strtotime2.phpt strtotime3.phpt
| From: | Nuno Lopes | Date: | Fri, 16 Jun 2006 22:48:29 +0000 |
| Subject: | cvs: php-src /ext/date/tests strtotime-mysql.phpt strtotime2.phpt strtotime3.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-38773@lists.php.net to get a copy of this message | ||
nlopess Fri Jun 16 22:48:29 2006 UTC
Modified files:
/php-src/ext/date/tests strtotime-mysql.phpt strtotime2.phpt
strtotime3.phpt
Log:
MFB: new tests
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/tests/strtotime-mysql.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/date/tests/strtotime-mysql.phpt
diff -u /dev/null php-src/ext/date/tests/strtotime-mysql.phpt:1.2
--- /dev/null Fri Jun 16 22:48:29 2006
+++ php-src/ext/date/tests/strtotime-mysql.phpt Fri Jun 16 22:48:29 2006
@@ -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)
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/tests/strtotime2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/date/tests/strtotime2.phpt
diff -u /dev/null php-src/ext/date/tests/strtotime2.phpt:1.2
--- /dev/null Fri Jun 16 22:48:29 2006
+++ php-src/ext/date/tests/strtotime2.phpt Fri Jun 16 22:48:29 2006
@@ -0,0 +1,38 @@
+--TEST--
+strtotime() on date constants
+--FILE--
+<?php
+$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
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/tests/strtotime3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/date/tests/strtotime3.phpt
diff -u /dev/null php-src/ext/date/tests/strtotime3.phpt:1.2
--- /dev/null Fri Jun 16 22:48:29 2006
+++ php-src/ext/date/tests/strtotime3.phpt Fri Jun 16 22:48:29 2006
@@ -0,0 +1,67 @@
+--TEST--
+strtotime() function
+--FILE--
+<?php
+date_default_timezone_set('Portugal');
+$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',
+ '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 Jan 2006 00:00:00 +0000"
+string(31) "Mon, 16 Jan 2006 00:00:00 +0000"