Make WordPress Core


Ignore:
Timestamp:
09/19/2013 01:46:03 AM (13 years ago)
Author:
SergeyBiryukov
Message:

Introduce 'offset' parameter for wp_get_sites().

props jamescollins.
see #14511.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ms.php

    r25446 r25488  
    10341034         */
    10351035        function test_wp_get_sites() {
    1036                 global $wpdb;
    10371036                $this->factory->blog->create_many( 2, array( 'site_id' => 2, 'meta' => array( 'public' => 1 ) ) );
    10381037                $this->factory->blog->create_many( 3, array( 'site_id' => 3, 'meta' => array( 'public' => 0 ) ) );
     
    10671066                $this->assertCount( 0, wp_get_sites( array( 'network_id' => 3, 'public' => 1 ) ) );
    10681067                $this->assertCount( 3, wp_get_sites( array( 'network_id' => 3, 'public' => 0 ) ) );
     1068        }
     1069
     1070        /**
     1071         * @ticket 14511
     1072         */
     1073        function test_wp_get_sites_limit_offset() {
     1074                // Create 4 more sites (in addition to the default one)
     1075                $this->factory->blog->create_many( 4, array( 'meta' => array( 'public' => 1 ) ) );
     1076
     1077                // Expect all 5 sites when no limit/offset is specified
     1078                $this->assertCount( 5, wp_get_sites() );
     1079
     1080                // Expect first 2 sites when using limit
     1081                $this->assertCount( 2, wp_get_sites( array( 'limit' => 2 ) ) );
     1082
     1083                // Expect only the last 3 sites when using offset of 2 (limit will default to 100)
     1084                $this->assertCount( 3, wp_get_sites( array( 'offset' => 2 ) ) );
     1085
     1086                // Expect only the last 1 site when using offset of 4 and limit of 2
     1087                $this->assertCount( 1, wp_get_sites( array( 'limit' => 2, 'offset' => 4 ) ) );
     1088
     1089                // Expect 0 sites when using an offset larger than the number of sites
     1090                $this->assertCount( 0, wp_get_sites( array( 'offset' => 20 ) ) );
    10691091        }
    10701092
Note: See TracChangeset for help on using the changeset viewer.