WordPress.org

Make WordPress Core

Changeset 37660


Ignore:
Timestamp:
06/08/2016 10:46:38 PM (4 years ago)
Author:
jeremyfelt
Message:

Tests: Move wp_get_sites() tests to their own file

See #36566.

Location:
trunk/tests/phpunit/tests/multisite
Files:
1 added
1 edited

Legend:

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

    r37653 r37660  
    575575
    576576        remove_action( 'update_blog_public', array( $this, '_action_counter_cb' ), 10 );
    577     }
    578 
    579     /**
    580      * Test the default arguments for wp_get_sites, which should return only
    581      * public sites from the current network.
    582      *
    583      * @ticket 14511
    584      * @expectedDeprecated wp_get_sites
    585      */
    586     function test_wp_get_sites_with_default_arguments() {
    587         self::factory()->blog->create( array( 'site_id' => 2 ) );
    588 
    589         $this->assertCount( 1, wp_get_sites() );
    590     }
    591 
    592     /**
    593      * No sites should match a query that specifies an invalid network ID.
    594      *
    595      * @expectedDeprecated wp_get_sites
    596      */
    597     function test_wp_get_sites_with_invalid_network_id() {
    598         $this->assertcount( 0, wp_get_sites( array( 'network_id' => 999 ) ) );
    599     }
    600 
    601     /**
    602      * A network ID of null should query for all public sites on all networks.
    603      *
    604      * @expectedDeprecated wp_get_sites
    605      */
    606     function test_wp_get_sites_with_network_id_null() {
    607         self::factory()->blog->create( array( 'site_id' => 2 ) );
    608 
    609         $this->assertCount( 2, wp_get_sites( array( 'network_id' => null ) ) );
    610     }
    611 
    612     /**
    613      * Expect only sites on the specified network ID to be returned.
    614      *
    615      * @expectedDeprecated wp_get_sites
    616      */
    617     function test_wp_get_sites_with_specific_network_id() {
    618         self::factory()->blog->create( array( 'site_id' => 2 ) );
    619 
    620         $this->assertCount( 1, wp_get_sites( array( 'network_id' => 2 ) ) );
    621     }
    622 
    623     /**
    624      * Expect sites from both networks if both network IDs are specified.
    625      *
    626      * @expectedDeprecated wp_get_sites
    627      */
    628     function test_wp_get_sites_with_multiple_network_ids() {
    629         self::factory()->blog->create( array( 'site_id' => 2 ) );
    630 
    631         $this->assertCount( 2, wp_get_sites( array( 'network_id' => array( 1, 2 ) ) ) );
    632     }
    633 
    634     /**
    635      * Queries for public or non public sites should work across all networks if network ID is null.
    636      *
    637      * @expectedDeprecated wp_get_sites
    638      */
    639     function test_wp_get_sites_with_public_meta_on_all_networks() {
    640         self::factory()->blog->create( array( 'site_id' => 2, 'meta' => array( 'public' => 0 ) ) );
    641 
    642         $this->assertCount( 1, wp_get_sites( array( 'public' => 1, 'network_id' => null ) ) );
    643         $this->assertcount( 1, wp_get_sites( array( 'public' => 0, 'network_id' => null ) ) );
    644     }
    645 
    646     /**
    647      * If a network ID is specified, queries for public sites should be restricted to that network.
    648      *
    649      * @expectedDeprecated wp_get_sites
    650      */
    651     function test_wp_get_sites_with_public_meta_restrict_to_one_network() {
    652         self::factory()->blog->create( array( 'site_id' => 1, 'meta' => array( 'public' => 0 ) ) );
    653 
    654         $this->assertCount( 1, wp_get_sites( array( 'public' => 1, 'network_id' => 1 ) ) );
    655         $this->assertCount( 0, wp_get_sites( array( 'public' => 1, 'network_id' => 2 ) ) );
    656     }
    657 
    658     /**
    659      * Test the limit and offset arguments for wp_get_sites when multiple sites are available.
    660      *
    661      * @expectedDeprecated wp_get_sites
    662      */
    663     function test_wp_get_sites_limit_offset() {
    664         // Create 2 more sites (in addition to the default one)
    665         self::factory()->blog->create_many( 2 );
    666 
    667         // Expect first 2 sites when using limit
    668         $this->assertCount( 2, wp_get_sites( array( 'limit' => 2 ) ) );
    669 
    670         // Expect only the last 2 sites when using offset of 1 (limit will default to 100)
    671         $this->assertCount( 2, wp_get_sites( array( 'offset' => 1 ) ) );
    672 
    673         // Expect only the last 1 site when using offset of 2 and limit of 2
    674         $this->assertCount( 1, wp_get_sites( array( 'limit' => 2, 'offset' => 2 ) ) );
    675     }
    676 
    677     /**
    678      * Expect 0 sites when using an offset larger than the total number of sites.
    679      *
    680      * @expectedDeprecated wp_get_sites
    681      */
    682     function test_wp_get_sites_offset_greater_than_available_sites() {
    683         $this->assertCount( 0, wp_get_sites( array( 'offset' => 20 ) ) );
    684577    }
    685578
Note: See TracChangeset for help on using the changeset viewer.