1
0
mirror of https://github.com/php/php-src.git synced 2026-04-18 13:31:27 +02:00
Files
archived-php-src/ext/date/tests/bug51866.phpt
Dmitry Stogov 9dd66e4d53 Merge branch 'master' into phpng
* master:
  Fixed issue #183 (TMP_VAR is not only used once)
  Fix broken Junit output with --disable-cgi
  Added folder mark
  Further test fixes for the fdb2709 breakage.
  Fix broken test caused by fdb2709.
  Added tests for ZipArchive::addGlob() and ZipArchive::addPattern()
  Fix run-tests.php with Valgrind >= 3.10.0.
  Add microseconds to the serialised form of DateTime objects.
  Improved test for bug #62479
  fix typo in ODBC code
  gcov: tentative fix for broken coverage data after fix for opcache coverage slightly hackish, but works. The idea is that we want to give priority to .gcda files in .libs dirs vs the files in the upper level dir
  5.5.14 now
  Fix bug #67060: use default mode of 660

Conflicts:
	ext/date/php_date.c
2014-05-26 10:52:43 +04:00

162 lines
2.4 KiB
PHP

--TEST--
Bug #51866 (Lenient parsing with parseFromFormat)
--FILE--
<?php
date_default_timezone_set('UTC');
$tests = array(
array( 'Y-m-d', '2001-11-29 13:20:01' ),
array( 'Y-m-d+', '2001-11-29 13:20:01' ),
array( 'Y-m-d +', '2001-11-29 13:20:01' ),
array( 'Y-m-d+', '2001-11-29' ),
array( 'Y-m-d +', '2001-11-29' ),
array( 'Y-m-d +', '2001-11-29 ' ),
);
foreach( $tests as $test )
{
list($format, $str) = $test;
var_dump($format, $str);
$d = DateTime::createFromFormat($format, $str);
var_dump($d);
var_dump(DateTime::getLastErrors());
echo "\n\n";
}
--EXPECTF--
string(5) "Y-m-d"
string(19) "2001-11-29 13:20:01"
bool(false)
array(4) {
["warning_count"]=>
int(0)
["warnings"]=>
array(0) {
}
["error_count"]=>
int(1)
["errors"]=>
array(1) {
[10]=>
string(13) "Trailing data"
}
}
string(6) "Y-m-d+"
string(19) "2001-11-29 13:20:01"
object(DateTime)#%d (3) {
["date"]=>
string(26) "2001-11-29 %d:%d:%d.%d"
["timezone_type"]=>
int(3)
["timezone"]=>
string(%d) "%s"
}
array(4) {
["warning_count"]=>
int(1)
["warnings"]=>
array(1) {
[10]=>
string(13) "Trailing data"
}
["error_count"]=>
int(0)
["errors"]=>
array(0) {
}
}
string(7) "Y-m-d +"
string(19) "2001-11-29 13:20:01"
object(DateTime)#%d (3) {
["date"]=>
string(26) "2001-11-29 %d:%d:%d.%d"
["timezone_type"]=>
int(3)
["timezone"]=>
string(%d) "%s"
}
array(4) {
["warning_count"]=>
int(1)
["warnings"]=>
array(1) {
[11]=>
string(13) "Trailing data"
}
["error_count"]=>
int(0)
["errors"]=>
array(0) {
}
}
string(6) "Y-m-d+"
string(10) "2001-11-29"
object(DateTime)#%d (3) {
["date"]=>
string(26) "2001-11-29 %d:%d:%d.%d"
["timezone_type"]=>
int(3)
["timezone"]=>
string(%d) "%s"
}
array(4) {
["warning_count"]=>
int(0)
["warnings"]=>
array(0) {
}
["error_count"]=>
int(0)
["errors"]=>
array(0) {
}
}
string(7) "Y-m-d +"
string(10) "2001-11-29"
bool(false)
array(4) {
["warning_count"]=>
int(0)
["warnings"]=>
array(0) {
}
["error_count"]=>
int(1)
["errors"]=>
array(1) {
[10]=>
string(12) "Data missing"
}
}
string(7) "Y-m-d +"
string(11) "2001-11-29 "
object(DateTime)#%d (3) {
["date"]=>
string(26) "2001-11-29 %d:%d:%d.%d"
["timezone_type"]=>
int(3)
["timezone"]=>
string(%d) "%s"
}
array(4) {
["warning_count"]=>
int(0)
["warnings"]=>
array(0) {
}
["error_count"]=>
int(0)
["errors"]=>
array(0) {
}
}