]> granicus.if.org Git - php/commitdiff
add & fix tests for lenient parsing
authorStanislav Malyshev <stas@php.net>
Sun, 12 Dec 2010 22:38:05 +0000 (22:38 +0000)
committerStanislav Malyshev <stas@php.net>
Sun, 12 Dec 2010 22:38:05 +0000 (22:38 +0000)
ext/date/tests/bug51866.phpt
ext/date/tests/date-lenient-create.phpt [new file with mode: 0644]
ext/date/tests/date-lenient.phpt [new file with mode: 0644]

index 8630b08faf9de3bbda95518c4be8ab440d8f4372..568b5a3d701e93034bc53da6ca2806cc3de09ad0 100644 (file)
@@ -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"]=>
diff --git a/ext/date/tests/date-lenient-create.phpt b/ext/date/tests/date-lenient-create.phpt
new file mode 100644 (file)
index 0000000..49ee3c1
--- /dev/null
@@ -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
+        (
+        )
+
+)
+==
diff --git a/ext/date/tests/date-lenient.phpt b/ext/date/tests/date-lenient.phpt
new file mode 100644 (file)
index 0000000..e5862e1
--- /dev/null
@@ -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] => 
+)