Make WordPress Core


Ignore:
Timestamp:
10/16/2014 05:06:22 AM (10 years ago)
Author:
jeremyfelt
Message:

Split and organize multisite unit tests

  • Move ms.php to multisite.php
  • Create multisite.php under directories option/ and user/ to better match existing structure.
  • Create a multisite/ directory containing bootstrap.php, site.php, and network.php for very multisite specific testing.
  • Add unit test groups ms-site, ms-user, ms-option, ms-network, and ms-bootstrap.

Fixes #29896

File:
1 moved

Legend:

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

    r29881 r29916  
    22
    33if ( is_multisite() ) :
     4
    45/**
     6 * Tests specific to network and site options in Multisite.
     7 *
    58 * @group option
     9 * @group ms-option
     10 * @group multisite
    611 */
    7 class Tests_Option_BlogOption extends WP_UnitTestCase {
     12class Tests_Multisite_Option extends WP_UnitTestCase {
    813    protected $suppress = false;
    914
     
    151156        //$this->assertFalse( get_option( $key2 ) ); // check get_option()
    152157    }
     158
     159    /**
     160     * @group multisite
     161     */
     162    function test_site_notoptions() {
     163        global $wpdb;
     164        $notoptions_key = "{$wpdb->siteid}:notoptions";
     165
     166        $_notoptions = wp_cache_get( 'notoptions', 'site-options' );
     167        $this->assertEmpty( $_notoptions );
     168        $_notoptions1 = wp_cache_get( $notoptions_key, 'site-options' );
     169        $this->assertEmpty( $_notoptions1 );
     170
     171        get_site_option( 'burrito' );
     172
     173        $notoptions = wp_cache_get( 'notoptions', 'site-options' );
     174        $this->assertEmpty( $notoptions );
     175        $notoptions1 = wp_cache_get( $notoptions_key, 'site-options' );
     176        $this->assertNotEmpty( $notoptions1 );
     177    }
     178
     179    function test_users_can_register_signup_filter() {
     180
     181        $registration = get_site_option('registration');
     182        $this->assertFalse( users_can_register_signup_filter() );
     183
     184        update_site_option('registration', 'all');
     185        $this->assertTrue( users_can_register_signup_filter() );
     186
     187        update_site_option('registration', 'user');
     188        $this->assertTrue( users_can_register_signup_filter() );
     189
     190        update_site_option('registration', 'none');
     191        $this->assertFalse( users_can_register_signup_filter() );
     192    }
     193
     194    /**
     195     * @ticket 21552
     196     * @ticket 23418
     197     */
     198    function test_sanitize_ms_options() {
     199        update_site_option( 'illegal_names', array( '', 'Woo', '' ) );
     200        update_site_option( 'limited_email_domains', array(  'woo', '', 'boo.com', 'foo.net.biz..'  ) );
     201        update_site_option( 'banned_email_domains', array(  'woo', '', 'boo.com', 'foo.net.biz..'  ) );
     202
     203        $this->assertEquals( array( 'Woo' ), get_site_option( 'illegal_names' ) );
     204        $this->assertEquals( array( 'woo', 'boo.com' ), get_site_option( 'limited_email_domains' ) );
     205        $this->assertEquals( array( 'woo', 'boo.com' ), get_site_option( 'banned_email_domains' ) );
     206
     207        update_site_option( 'illegal_names', 'foo bar' );
     208        update_site_option( 'limited_email_domains', "foo\nbar" );
     209        update_site_option( 'banned_email_domains', "foo\nbar" );
     210
     211        $this->assertEquals( array( 'foo', 'bar' ), get_site_option( 'illegal_names' ) );
     212        $this->assertEquals( array( 'foo', 'bar' ), get_site_option( 'limited_email_domains' ) );
     213        $this->assertEquals( array( 'foo', 'bar' ), get_site_option( 'banned_email_domains' ) );
     214
     215        foreach ( array( 'illegal_names', 'limited_email_domains', 'banned_email_domains' ) as $option ) {
     216            update_site_option( $option, array() );
     217            $this->assertSame( '', get_site_option( $option ) );
     218        }
     219    }
    153220}
     221
    154222endif;
Note: See TracChangeset for help on using the changeset viewer.