WordPress.org

Make WordPress Core

Changeset 35236


Ignore:
Timestamp:
10/17/2015 04:43:27 AM (4 years ago)
Author:
westonruter
Message:

Customizer: Add unit test for WP_Customize_Widgets::is_panel_active().

See #33052.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/customize/widgets.php

    r35225 r35236  
    1212     */
    1313    protected $manager;
     14
     15    /**
     16     * Stored global variable in setUp for restoration in tearDown.
     17     *
     18     * @see $wp_registered_sidebars
     19     * @var array
     20     */
     21    protected $backup_registered_sidebars;
    1422
    1523    function setUp() {
     
    3341        $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
    3442        wp_set_current_user( $user_id );
     43
     44        $this->backup_registered_sidebars = $GLOBALS['wp_registered_sidebars'];
    3545    }
    3646
     
    3949        unset( $GLOBALS['wp_customize'] );
    4050        unset( $GLOBALS['wp_scripts'] );
     51        $GLOBALS['wp_registered_sidebars'] = $this->backup_registered_sidebars;
    4152        parent::tearDown();
    4253    }
     
    264275        $this->assertArrayHasKey( 'height', $params );
    265276        $this->assertInternalType( 'bool', $params['is_wide'] );
    266 
     277    }
     278
     279    /**
     280     * @see WP_Customize_Widgets::is_panel_active()
     281     */
     282    function test_is_panel_active() {
     283        global $wp_registered_sidebars;
     284        $this->do_customize_boot_actions();
     285
     286        $this->assertNotEmpty( $wp_registered_sidebars );
     287        $this->assertTrue( $this->manager->widgets->is_panel_active() );
     288        $this->assertTrue( $this->manager->get_panel( 'widgets' )->active() );
     289
     290        $wp_registered_sidebars = array();
     291        $this->assertFalse( $this->manager->widgets->is_panel_active() );
     292        $this->assertFalse( $this->manager->get_panel( 'widgets' )->active() );
    267293    }
    268294}
Note: See TracChangeset for help on using the changeset viewer.