Introduce nested query support to WP_Date_Query.

This enhancement makes it possible to filter post, comment, and other queries
by date in ways that are arbitrarily complex, using mixed AND and OR relations.

Includes unit tests for the new syntax. In a few places, the existing unit
tests were slightly too strict (such as when checking the exact syntax of a SQL
string); these existing tests have been narrowed.

Props boonebgorges.
Fixes #29822.

git-svn-id: https://develop.svn.wordpress.org/trunk@29923 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2014-10-16 19:33:24 +00:00
parent c845692fb4
commit a3e0c08f2f
3 changed files with 468 additions and 61 deletions
+14 -3
View File
@@ -55,7 +55,13 @@ class Tests_WP_Date_Query extends WP_UnitTestCase {
'year' => 2008,
'month' => 6,
),
'column' => 'post_date',
'compare' => '=',
'relation' => 'AND',
),
'column' => 'post_date',
'compare' => '=',
'relation' => 'AND',
);
$this->assertSame( $expected, $q->queries );
@@ -73,17 +79,22 @@ class Tests_WP_Date_Query extends WP_UnitTestCase {
),
) );
// Note: WP_Date_Query does not reset indexes
$expected = array(
2 => array(
array(
'before' => array(
'year' => 2008,
'month' => 6,
),
'column' => 'post_date',
'compare' => '=',
'relation' => 'AND',
),
'column' => 'post_date',
'compare' => '=',
'relation' => 'AND',
);
$this->assertSame( $expected, $q->queries );
$this->assertEquals( $expected, $q->queries );
}
public function test_get_compare_empty() {