mirror of
https://github.com/php/php-src.git
synced 2025-08-17 22:48:57 +02:00
add & fix tests for lenient parsing
This commit is contained in:
parent
52ea9da401
commit
91ad5e7369
3 changed files with 299 additions and 4 deletions
|
@ -48,7 +48,7 @@ object(DateTime)#2 (3) {
|
|||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
string(%d) "%s"
|
||||
}
|
||||
array(4) {
|
||||
["warning_count"]=>
|
||||
|
@ -74,7 +74,7 @@ object(DateTime)#3 (3) {
|
|||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
string(%d) "%s"
|
||||
}
|
||||
array(4) {
|
||||
["warning_count"]=>
|
||||
|
@ -100,7 +100,7 @@ object(DateTime)#2 (3) {
|
|||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
string(%d) "%s"
|
||||
}
|
||||
array(4) {
|
||||
["warning_count"]=>
|
||||
|
@ -143,7 +143,7 @@ object(DateTime)#2 (3) {
|
|||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
string(%d) "%s"
|
||||
}
|
||||
array(4) {
|
||||
["warning_count"]=>
|
||||
|
|
149
ext/date/tests/date-lenient-create.phpt
Normal file
149
ext/date/tests/date-lenient-create.phpt
Normal file
|
@ -0,0 +1,149 @@
|
|||
--TEST--
|
||||
Test for + character in date format
|
||||
--FILE--
|
||||
<?php
|
||||
$tz = new DateTimeZone("UTC");
|
||||
$date = "06/08/04 12:00";
|
||||
echo "==\n";
|
||||
print_r( date_create_from_format( 'm/d/y', $date , $tz) );
|
||||
print_r( date_get_last_errors() );
|
||||
echo "==\n";
|
||||
print_r( date_create_from_format( 'm/d/y+', $date , $tz)->setTime(0, 0) );
|
||||
print_r( date_get_last_errors() );
|
||||
echo "==\n";
|
||||
print_r( date_create_from_format( '+m/d/y', $date , $tz)->setTime(0, 0) );
|
||||
print_r( date_get_last_errors() );
|
||||
echo "==\n";
|
||||
print_r( date_create_from_format( 'm/d/y++', $date , $tz)->setTime(0, 0) );
|
||||
print_r( date_get_last_errors() );
|
||||
echo "==\n";
|
||||
|
||||
$date = "06/08/04";
|
||||
print_r( date_create_from_format( 'm/d/y+', $date , $tz)->setTime(0, 0) );
|
||||
print_r( date_get_last_errors() );
|
||||
echo "==\n";
|
||||
print_r( date_create_from_format( '+m/d/y', $date , $tz)->setTime(0, 0) );
|
||||
print_r( date_get_last_errors() );
|
||||
echo "==\n";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
==
|
||||
Array
|
||||
(
|
||||
[warning_count] => 0
|
||||
[warnings] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[error_count] => 1
|
||||
[errors] => Array
|
||||
(
|
||||
[8] => Trailing data
|
||||
)
|
||||
|
||||
)
|
||||
==
|
||||
DateTime Object
|
||||
(
|
||||
[date] => 2004-06-08 00:00:00
|
||||
[timezone_type] => 3
|
||||
[timezone] => UTC
|
||||
)
|
||||
Array
|
||||
(
|
||||
[warning_count] => 1
|
||||
[warnings] => Array
|
||||
(
|
||||
[8] => Trailing data
|
||||
)
|
||||
|
||||
[error_count] => 0
|
||||
[errors] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
==
|
||||
DateTime Object
|
||||
(
|
||||
[date] => 2004-06-08 00:00:00
|
||||
[timezone_type] => 3
|
||||
[timezone] => UTC
|
||||
)
|
||||
Array
|
||||
(
|
||||
[warning_count] => 1
|
||||
[warnings] => Array
|
||||
(
|
||||
[8] => Trailing data
|
||||
)
|
||||
|
||||
[error_count] => 0
|
||||
[errors] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
==
|
||||
DateTime Object
|
||||
(
|
||||
[date] => 2004-06-08 00:00:00
|
||||
[timezone_type] => 3
|
||||
[timezone] => UTC
|
||||
)
|
||||
Array
|
||||
(
|
||||
[warning_count] => 1
|
||||
[warnings] => Array
|
||||
(
|
||||
[8] => Trailing data
|
||||
)
|
||||
|
||||
[error_count] => 0
|
||||
[errors] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
==
|
||||
DateTime Object
|
||||
(
|
||||
[date] => 2004-06-08 00:00:00
|
||||
[timezone_type] => 3
|
||||
[timezone] => UTC
|
||||
)
|
||||
Array
|
||||
(
|
||||
[warning_count] => 0
|
||||
[warnings] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[error_count] => 0
|
||||
[errors] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
==
|
||||
DateTime Object
|
||||
(
|
||||
[date] => 2004-06-08 00:00:00
|
||||
[timezone_type] => 3
|
||||
[timezone] => UTC
|
||||
)
|
||||
Array
|
||||
(
|
||||
[warning_count] => 0
|
||||
[warnings] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[error_count] => 0
|
||||
[errors] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
==
|
146
ext/date/tests/date-lenient.phpt
Normal file
146
ext/date/tests/date-lenient.phpt
Normal file
|
@ -0,0 +1,146 @@
|
|||
--TEST--
|
||||
Test for + character in date format
|
||||
--FILE--
|
||||
<?php
|
||||
$date = "06/08/04 12:00";
|
||||
print_r( date_parse_from_format( 'm/d/y', $date ) );
|
||||
print_r( date_parse_from_format( 'm/d/y+', $date ) );
|
||||
print_r( date_parse_from_format( '+m/d/y', $date ) );
|
||||
print_r( date_parse_from_format( 'm/d/y++', $date ) );
|
||||
|
||||
$date = "06/08/04";
|
||||
print_r( date_parse_from_format( 'm/d/y+', $date ) );
|
||||
print_r( date_parse_from_format( '+m/d/y', $date ) );
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Array
|
||||
(
|
||||
[year] => 2004
|
||||
[month] => 6
|
||||
[day] => 8
|
||||
[hour] =>
|
||||
[minute] =>
|
||||
[second] =>
|
||||
[fraction] =>
|
||||
[warning_count] => 0
|
||||
[warnings] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[error_count] => 1
|
||||
[errors] => Array
|
||||
(
|
||||
[8] => Trailing data
|
||||
)
|
||||
|
||||
[is_localtime] =>
|
||||
)
|
||||
Array
|
||||
(
|
||||
[year] => 2004
|
||||
[month] => 6
|
||||
[day] => 8
|
||||
[hour] =>
|
||||
[minute] =>
|
||||
[second] =>
|
||||
[fraction] =>
|
||||
[warning_count] => 1
|
||||
[warnings] => Array
|
||||
(
|
||||
[8] => Trailing data
|
||||
)
|
||||
|
||||
[error_count] => 0
|
||||
[errors] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[is_localtime] =>
|
||||
)
|
||||
Array
|
||||
(
|
||||
[year] => 2004
|
||||
[month] => 6
|
||||
[day] => 8
|
||||
[hour] =>
|
||||
[minute] =>
|
||||
[second] =>
|
||||
[fraction] =>
|
||||
[warning_count] => 1
|
||||
[warnings] => Array
|
||||
(
|
||||
[8] => Trailing data
|
||||
)
|
||||
|
||||
[error_count] => 0
|
||||
[errors] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[is_localtime] =>
|
||||
)
|
||||
Array
|
||||
(
|
||||
[year] => 2004
|
||||
[month] => 6
|
||||
[day] => 8
|
||||
[hour] =>
|
||||
[minute] =>
|
||||
[second] =>
|
||||
[fraction] =>
|
||||
[warning_count] => 1
|
||||
[warnings] => Array
|
||||
(
|
||||
[8] => Trailing data
|
||||
)
|
||||
|
||||
[error_count] => 0
|
||||
[errors] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[is_localtime] =>
|
||||
)
|
||||
Array
|
||||
(
|
||||
[year] => 2004
|
||||
[month] => 6
|
||||
[day] => 8
|
||||
[hour] =>
|
||||
[minute] =>
|
||||
[second] =>
|
||||
[fraction] =>
|
||||
[warning_count] => 0
|
||||
[warnings] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[error_count] => 0
|
||||
[errors] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[is_localtime] =>
|
||||
)
|
||||
Array
|
||||
(
|
||||
[year] => 2004
|
||||
[month] => 6
|
||||
[day] => 8
|
||||
[hour] =>
|
||||
[minute] =>
|
||||
[second] =>
|
||||
[fraction] =>
|
||||
[warning_count] => 0
|
||||
[warnings] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[error_count] => 0
|
||||
[errors] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[is_localtime] =>
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue