mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-05 05:04:31 +00:00
Allow ORDER BY in WP_Comment_Query::query() to be disabled.
Disable ORDER BY by passing boolean false, an empty array, or the string 'none' to the 'orderby parameter. This mirrors the behavior of `WP_Query`. Props psycleuk. Fixes #29902. git-svn-id: https://develop.svn.wordpress.org/trunk@30004 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -577,4 +577,40 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
|
||||
$this->assertContains( 'ORDER BY comment_date_gmt', $q->request );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 29902
|
||||
*/
|
||||
public function test_orderby_none() {
|
||||
$q = new WP_Comment_Query();
|
||||
$q->query( array(
|
||||
'orderby' => 'none',
|
||||
) );
|
||||
|
||||
$this->assertNotContains( 'ORDER BY', $q->request );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 29902
|
||||
*/
|
||||
public function test_orderby_empty_array() {
|
||||
$q = new WP_Comment_Query();
|
||||
$q->query( array(
|
||||
'orderby' => array(),
|
||||
) );
|
||||
|
||||
$this->assertNotContains( 'ORDER BY', $q->request );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 29902
|
||||
*/
|
||||
public function test_orderby_false() {
|
||||
$q = new WP_Comment_Query();
|
||||
$q->query( array(
|
||||
'orderby' => false,
|
||||
) );
|
||||
|
||||
$this->assertNotContains( 'ORDER BY', $q->request );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user