Multisite: Correct default values for `orderby` and `order` in `WP_Site_Query::__construct()`.
Add a unit test. Props ramiy, SergeyBiryukov. See #35791. git-svn-id: https://develop.svn.wordpress.org/trunk@38085 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
7b833f38a6
commit
38bcf065df
|
@ -155,8 +155,8 @@ class WP_Site_Query {
|
||||||
'number' => 100,
|
'number' => 100,
|
||||||
'offset' => '',
|
'offset' => '',
|
||||||
'no_found_rows' => true,
|
'no_found_rows' => true,
|
||||||
'orderby' => 'ids',
|
'orderby' => 'id',
|
||||||
'order' => 'DESC',
|
'order' => 'ASC',
|
||||||
'network_id' => 0,
|
'network_id' => 0,
|
||||||
'network__in' => '',
|
'network__in' => '',
|
||||||
'network__not_in' => '',
|
'network__not_in' => '',
|
||||||
|
|
|
@ -163,6 +163,33 @@ class Tests_Multisite_Site_Query extends WP_UnitTestCase {
|
||||||
$this->assertEqualSets( $expected, $found );
|
$this->assertEqualSets( $expected, $found );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_wp_site_query_by_network_id_with_order() {
|
||||||
|
$q = new WP_Site_Query();
|
||||||
|
$found = $q->query( array(
|
||||||
|
'fields' => 'ids',
|
||||||
|
'network_id' => self::$network_ids['wordpress.org/'],
|
||||||
|
'number' => 3,
|
||||||
|
'order' => 'ASC',
|
||||||
|
) );
|
||||||
|
|
||||||
|
$expected = array(
|
||||||
|
self::$site_ids['wordpress.org/'],
|
||||||
|
self::$site_ids['wordpress.org/foo/'],
|
||||||
|
self::$site_ids['wordpress.org/foo/bar/'],
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals( $expected, $found );
|
||||||
|
|
||||||
|
$found = $q->query( array(
|
||||||
|
'fields' => 'ids',
|
||||||
|
'network_id' => self::$network_ids['wordpress.org/'],
|
||||||
|
'number' => 3,
|
||||||
|
'order' => 'DESC',
|
||||||
|
) );
|
||||||
|
|
||||||
|
$this->assertEquals( array_reverse( $expected ), $found );
|
||||||
|
}
|
||||||
|
|
||||||
public function test_wp_site_query_by_network_id_with_existing_sites() {
|
public function test_wp_site_query_by_network_id_with_existing_sites() {
|
||||||
$q = new WP_Site_Query();
|
$q = new WP_Site_Query();
|
||||||
$found = $q->query( array(
|
$found = $q->query( array(
|
||||||
|
|
Loading…
Reference in New Issue