Skip to content

Commit 98b12d1

Browse files
committed
Tests: Fix failing malformed date test
Dates without leading zeros (e.g., `2012-1-08`, `2012-01-8`) are now correctly recognized as valid dates. This change fixes the test cases to correctly reflect that these formats are valid and fixes an undefined variable reference. Follow-up to [61172]. Props wildworks, westonruter. Fixes #26798. git-svn-id: https://develop.svn.wordpress.org/trunk@61173 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8b5dd7a commit 98b12d1

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

tests/phpunit/tests/post.php

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ public function test_use_block_editor_for_post() {
826826
*/
827827
public function test_wp_insert_post_handle_malformed_post_date( $input, $expected ) {
828828
$post = array(
829-
'post_author' => self::$editor_id,
829+
'post_author' => self::$user_ids['editor'],
830830
'post_status' => 'publish',
831831
'post_content' => 'content',
832832
'post_title' => 'title',
@@ -893,37 +893,38 @@ public function data_wp_insert_post_handle_malformed_post_date() {
893893
'2012-01-01 00:60:00',
894894
true,
895895
),
896-
// Failures.
896+
// Dates without leading zeros (valid but malformed format).
897897
array(
898-
'2012-08-0z',
899-
false,
898+
'2012-08-1',
899+
true,
900900
),
901901
array(
902-
'2012-08-1',
903-
false,
902+
'2012-1-08 00:00:00',
903+
true,
904904
),
905905
array(
906-
'201-01-08 00:00:00',
907-
false,
906+
'2012-01-8 00:00:00',
907+
true,
908908
),
909+
// Failures.
909910
array(
910-
'201-01-08 00:60:00',
911+
'2012-08-0z',
911912
false,
912913
),
913914
array(
914-
'201a-01-08 00:00:00',
915+
'201-01-08 00:00:00',
915916
false,
916917
),
917918
array(
918-
'2012-1-08 00:00:00',
919+
'201-01-08 00:60:00',
919920
false,
920921
),
921922
array(
922-
'2012-31-08 00:00:00',
923+
'201a-01-08 00:00:00',
923924
false,
924925
),
925926
array(
926-
'2012-01-8 00:00:00',
927+
'2012-31-08 00:00:00',
927928
false,
928929
),
929930
array(
@@ -1016,24 +1017,25 @@ public function data_wp_resolve_post_date_regex() {
10161017
'2012-01-01 00:00:60',
10171018
'2012-01-01 00:00:60',
10181019
),
1020+
// Dates without leading zeros (valid but malformed format).
10191021
array(
1020-
'201-01-08',
1021-
false,
1022+
'2012-1-08',
1023+
'2012-1-08',
10221024
),
10231025
array(
1024-
'201a-01-08',
1025-
false,
1026+
'2012-01-8',
1027+
'2012-01-8',
10261028
),
10271029
array(
1028-
'2012-1-08',
1030+
'201-01-08',
10291031
false,
10301032
),
10311033
array(
1032-
'2012-31-08',
1034+
'201a-01-08',
10331035
false,
10341036
),
10351037
array(
1036-
'2012-01-8',
1038+
'2012-31-08',
10371039
false,
10381040
),
10391041
array(

0 commit comments

Comments
 (0)