diff options
Diffstat (limited to 'tests/phpunit/tests/customize/panel.php')
-rw-r--r-- | tests/phpunit/tests/customize/panel.php | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/tests/phpunit/tests/customize/panel.php b/tests/phpunit/tests/customize/panel.php index 40f198675a..bd191e65d7 100644 --- a/tests/phpunit/tests/customize/panel.php +++ b/tests/phpunit/tests/customize/panel.php @@ -8,6 +8,22 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { /** + * ID of the administrator user. + * + * @var int + */ + public static $administrator_id; + + /** + * Set up the shared fixture. + * + * @param WP_UnitTest_Factory $factory Factory instance. + */ + public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { + self::$administrator_id = $factory->user->create( array( 'role' => 'administrator' ) ); + } + + /** * @var WP_Customize_Manager */ protected $manager; @@ -131,8 +147,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { * @see WP_Customize_Panel::check_capabilities() */ public function test_check_capabilities() { - $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); - wp_set_current_user( $user_id ); + wp_set_current_user( self::$administrator_id ); $panel = new WP_Customize_Panel( $this->manager, 'foo' ); $this->assertTrue( $panel->check_capabilities() ); @@ -157,7 +172,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { * @see WP_Customize_Panel::maybe_render() */ public function test_maybe_render() { - wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$administrator_id ); $panel = new WP_Customize_Panel( $this->manager, 'bar' ); $customize_render_panel_count = did_action( 'customize_render_panel' ); add_action( 'customize_render_panel', array( $this, 'action_customize_render_panel_test' ) ); @@ -182,7 +197,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { * @see WP_Customize_Panel::print_template() */ public function test_print_templates_standard() { - wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$administrator_id ); $panel = new WP_Customize_Panel( $this->manager, 'baz' ); ob_start(); @@ -200,7 +215,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { * @see WP_Customize_Panel::print_template() */ public function test_print_templates_custom() { - wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$administrator_id ); $panel = new Custom_Panel_Test( $this->manager, 'baz' ); ob_start(); |