Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#29781 closed enhancement (fixed)

Unit tests for WP_Date_Query

Reported by: boonebgorges's profile boonebgorges Owned by: boonebgorges's profile boonebgorges
Milestone: 4.1 Priority: normal
Severity: normal Version: 4.1
Component: Date/Time Keywords:
Focuses: Cc:


WP_Date_Query has pretty decent integration tests (in the form of the posts queries in /tests/phpunit/tests/query/dateQuery.php, but it has no coverage at all of the class itself. The attached patch covers pretty much all publicly available functionality in WP_Date_Query.

In writing the tests, I found a couple bugs - places where passing a certain kind of value can result in getting integer-cast to 1, which will return improper results rather than no results at all. But for this patch, I've opted to write all the tests so that they pass, ie so that they describe how WP_Date_Query currently works. I'll submit fixes for the bugs once these tests have been committed.

Attachments (2)

29781.patch (448 bytes) - added by boonebgorges 10 years ago.
29781.2.patch (17.6 KB) - added by boonebgorges 10 years ago.

Download all attachments as: .zip

Change History (8)

10 years ago

#1 @boonebgorges
10 years ago

Never mind that first patch. Forgot how to use git for a second.

#2 @boonebgorges
10 years ago

  • Milestone changed from Awaiting Review to 4.1
  • Owner set to boonebgorges
  • Status changed from new to assigned

#3 @boonebgorges
10 years ago

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

In 29793:

Improved unit test coverage for WP_Date_Query

  • Unit tests for all publicly available functionality in WP_Date_Query
  • Improve performance of date_query tests that use WP_Query

Fixes #29781

#4 @boonebgorges
10 years ago

In 29794:

Fix file location for WP_Date_Query tests introduced in r29793.

See #29781

#5 @Viper007Bond
10 years ago


#6 @boonebgorges
10 years ago

In 29885:

Don't create dummy data for each date query test.

The integration tests for using date_query in WP_Query require the creation of
dummy post data, much of which is common between a number of tests. However,
newer tests do not require as much data, so to reduce overhead we create the
data explicitly only when we need it, instead of in the setUp() method.

See #29781.

Note: See TracTickets for help on using tickets.