WordPress.org

Make WordPress Core

Changeset 37238


Ignore:
Timestamp:
04/18/2016 03:18:51 AM (4 years ago)
Author:
jeremyfelt
Message:

Tests: Use a data provider to test multisite's bootstrap

This also helps to get things in order before the introduction of a more testable multisite bootstrap function in #34941.

A @todo has been temporarily removed, to be re-introduced as a working test.

See #36566.

File:
1 edited

Legend:

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

    r37237 r37238  
    139139    /**
    140140     * @ticket 27884
    141      */
    142     function test_multisite_bootstrap() {
     141     * @dataProvider data_multisite_bootstrap
     142     */
     143    function test_multisite_bootstrap( $site_key, $network_key, $domain, $path ) {
    143144        global $current_blog;
    144145
    145         $this->_setup_host_request( 'wordpress.org', '/' );
    146         $this->assertEquals( self::$site_ids['wordpress.org/'], $current_blog->blog_id );
    147         $this->assertEquals( self::$network_ids['wordpress.org/'], $current_blog->site_id );
    148 
    149         $this->_setup_host_request( 'wordpress.org', '/2014/04/23/hello-world/' );
    150         $this->assertEquals( self::$site_ids['wordpress.org/'], $current_blog->blog_id );
    151         $this->assertEquals( self::$network_ids['wordpress.org/'], $current_blog->site_id );
    152 
    153         $this->_setup_host_request( 'wordpress.org', '/sample-page/' );
    154         $this->assertEquals( self::$site_ids['wordpress.org/'], $current_blog->blog_id );
    155         $this->assertEquals( self::$network_ids['wordpress.org/'], $current_blog->site_id );
    156 
    157         $this->_setup_host_request( 'wordpress.org', '/?p=1' );
    158         $this->assertEquals( self::$site_ids['wordpress.org/'], $current_blog->blog_id );
    159         $this->assertEquals( self::$network_ids['wordpress.org/'], $current_blog->site_id );
    160 
    161         $this->_setup_host_request( 'wordpress.org', '/wp-admin/' );
    162         $this->assertEquals( self::$site_ids['wordpress.org/'], $current_blog->blog_id );
    163         $this->assertEquals( self::$network_ids['wordpress.org/'], $current_blog->site_id );
    164 
    165         $this->_setup_host_request( 'wordpress.org', '/foo/' );
    166         $this->assertEquals( self::$site_ids['wordpress.org/foo/'], $current_blog->blog_id );
    167         $this->assertEquals( self::$network_ids['wordpress.org/'], $current_blog->site_id );
    168 
    169         $this->_setup_host_request( 'wordpress.org', '/FOO/' );
    170         $this->assertEquals( self::$site_ids['wordpress.org/foo/'], $current_blog->blog_id );
    171         $this->assertEquals( self::$network_ids['wordpress.org/'], $current_blog->site_id );
    172 
    173         $this->_setup_host_request( 'wordpress.org', '/foo/2014/04/23/hello-world/' );
    174         $this->assertEquals( self::$site_ids['wordpress.org/foo/'], $current_blog->blog_id );
    175         $this->assertEquals( self::$network_ids['wordpress.org/'], $current_blog->site_id );
    176 
    177         $this->_setup_host_request( 'wordpress.org', '/foo/sample-page/' );
    178         $this->assertEquals( self::$site_ids['wordpress.org/foo/'], $current_blog->blog_id );
    179         $this->assertEquals( self::$network_ids['wordpress.org/'], $current_blog->site_id );
    180 
    181         $this->_setup_host_request( 'wordpress.org', '/foo/?p=1' );
    182         $this->assertEquals( self::$site_ids['wordpress.org/foo/'], $current_blog->blog_id );
    183         $this->assertEquals( self::$network_ids['wordpress.org/'], $current_blog->site_id );
    184 
    185         $this->_setup_host_request( 'wordpress.org', '/foo/wp-admin/' );
    186         $this->assertEquals( self::$site_ids['wordpress.org/foo/'], $current_blog->blog_id );
    187         $this->assertEquals( self::$network_ids['wordpress.org/'], $current_blog->site_id );
    188 
    189         // @todo not currently passing.
    190         //$this->_setup_host_request( 'wordpress.org', '/foo/bar/' );
    191         //$this->assertEquals( $ids['wordpress.org/foo/bar/'], $current_blog->blog_id );
    192         //$this->assertEquals( $network_ids['wordpress.org/'], $current_blog->site_id );
    193 
    194         $this->_setup_host_request( 'make.wordpress.org', '/' );
    195         $this->assertEquals( self::$site_ids['make.wordpress.org/'], $current_blog->blog_id );
    196         $this->assertEquals( self::$network_ids['make.wordpress.org/'], $current_blog->site_id );
    197 
    198         $this->_setup_host_request( 'make.wordpress.org', '/foo/' );
    199         $this->assertEquals( self::$site_ids['make.wordpress.org/foo/'], $current_blog->blog_id );
    200         $this->assertEquals( self::$network_ids['make.wordpress.org/'], $current_blog->site_id );
    201 
    202         // Request the original tests domain and path to unpollute the stack.
     146        $expected = array(
     147            'network_id' => self::$network_ids[ $network_key ],
     148            'site_id' => self::$site_ids[ $site_key ],
     149        );
     150
     151        $this->_setup_host_request( $domain, $path );
     152        $actual = array(
     153            'network_id' => $current_blog->site_id,
     154            'site_id' => $current_blog->blog_id,
     155        );
    203156        $this->_setup_host_request( WP_TESTS_DOMAIN, '/' );
     157
     158        $this->assertEqualSetsWithIndex( $expected, $actual );
     159    }
     160
     161    public function data_multisite_bootstrap() {
     162        return array(
     163            array( 'wordpress.org/',          'wordpress.org/',      'wordpress.org',      '/' ),
     164            array( 'wordpress.org/',          'wordpress.org/',      'wordpress.org',      '/2014/04/23/hello-world/' ),
     165            array( 'wordpress.org/',          'wordpress.org/',      'wordpress.org',      '/sample-page/' ),
     166            array( 'wordpress.org/',          'wordpress.org/',      'wordpress.org',      '/?p=1' ),
     167            array( 'wordpress.org/',          'wordpress.org/',      'wordpress.org',      '/wp-admin/' ),
     168            array( 'wordpress.org/foo/',      'wordpress.org/',      'wordpress.org',      '/foo/' ),
     169            array( 'wordpress.org/foo/',      'wordpress.org/',      'wordpress.org',      '/FOO/' ),
     170            array( 'wordpress.org/foo/',      'wordpress.org/',      'wordpress.org',      '/foo/2014/04/23/hello-world/' ),
     171            array( 'wordpress.org/foo/',      'wordpress.org/',      'wordpress.org',      '/foo/sample-page/' ),
     172            array( 'wordpress.org/foo/',      'wordpress.org/',      'wordpress.org',      '/foo/?p=1' ),
     173            array( 'wordpress.org/foo/',      'wordpress.org/',      'wordpress.org',      '/foo/wp-admin/' ),
     174            array( 'make.wordpress.org/',     'make.wordpress.org/', 'make.wordpress.org', '/' ),
     175            array( 'make.wordpress.org/foo/', 'make.wordpress.org/', 'make.wordpress.org', '/foo/' ),
     176        );
    204177    }
    205178
Note: See TracChangeset for help on using the changeset viewer.