mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-09-29 12:16:59 +00:00
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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user