WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/17/2016 11:29:11 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Multisite: Correct default values for orderby and order in WP_Site_Query::__construct().

Add a unit test.

Props ramiy, SergeyBiryukov.
See #35791.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/siteQuery.php

    r37735 r38085  
    164164    }
    165165
     166    public function test_wp_site_query_by_network_id_with_order() {
     167        $q = new WP_Site_Query();
     168        $found = $q->query( array(
     169            'fields'     => 'ids',
     170            'network_id' => self::$network_ids['wordpress.org/'],
     171            'number'     => 3,
     172            'order'      => 'ASC',
     173        ) );
     174
     175        $expected = array(
     176            self::$site_ids['wordpress.org/'],
     177            self::$site_ids['wordpress.org/foo/'],
     178            self::$site_ids['wordpress.org/foo/bar/'],
     179        );
     180
     181        $this->assertEquals( $expected, $found );
     182
     183        $found = $q->query( array(
     184            'fields'     => 'ids',
     185            'network_id' => self::$network_ids['wordpress.org/'],
     186            'number'     => 3,
     187            'order'      => 'DESC',
     188        ) );
     189
     190        $this->assertEquals( array_reverse( $expected ), $found );
     191    }
     192
    166193    public function test_wp_site_query_by_network_id_with_existing_sites() {
    167194        $q = new WP_Site_Query();
Note: See TracChangeset for help on using the changeset viewer.