mirror of
https://github.com/php/php-src.git
synced 2026-03-26 01:02:25 +01:00
new tests. the .re file coverage increases to 96%. really good :)
This commit is contained in:
25
ext/date/tests/strtotime-mysql.phpt
Executable file
25
ext/date/tests/strtotime-mysql.phpt
Executable file
@@ -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)
|
||||
38
ext/date/tests/strtotime2.phpt
Normal file
38
ext/date/tests/strtotime2.phpt
Normal file
@@ -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
|
||||
67
ext/date/tests/strtotime3.phpt
Normal file
67
ext/date/tests/strtotime3.phpt
Normal file
@@ -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"
|
||||
Reference in New Issue
Block a user