WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#34277 closed defect (bug) (fixed)

factory not setup correctly in unit test in test_validate_date_values_should_process_array_value_for_year

Reported by: pbearne Owned by: SergeyBiryukov
Milestone: 4.4 Priority: normal
Severity: normal Version: 4.4
Component: Build/Test Tools Keywords:
Focuses: Cc:

Description

In the unit test "test_validate_date_values_should_process_array_value_for_year"two posts are made inorder to do a query on them for the test but the post_date a set wrongly as "get_gmt_from_date()" needs the date passed to be in the format of 'Y-m-d H:i:s' inorder to mnatch the internal regex if the get_option( 'timezone_string' ); returns false

There are 2 ways to fix this pass the full date (as patched) or to set update_option( 'timezone_string', 'Europe/London' ); before calling the factory or change get_gmt_from_date() to work with incomplete dates

Attachments (1)

34277.patch (758 bytes) - added by pbearne 4 years ago.
set dates for factory to full format

Download all attachments as: .zip

Change History (4)

@pbearne
4 years ago

set dates for factory to full format

#1 @SergeyBiryukov
4 years ago

  • Milestone changed from Awaiting Review to 4.4
  • Owner set to SergeyBiryukov
  • Status changed from new to accepted

In my testing, post_date was correct and the test passed, but a var_dump() of posts revealed that post_date_gmt and post_modified_gmt were 1970-01-01 00:00:00.

34277.patch looks good.

I've reviewed all the other instances of using the factory, and the date format is correct there.

#2 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 35091:

Correct the post_date format in WP_Date_Query tests.

It should be 'Y-m-d H:i:s' in order to match the regex in get_gmt_from_date() if 'timezone_string' option is not set.

Props pbearne.
Fixes #34277.

Note: See TracTickets for help on using tickets.