WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/23/2017 09:57:31 PM (2 years ago)
Author:
johnbillion
Message:

Build/Test Tools: Introduce skipWithoutMultisite() and skipWithMultisite() methods into the test suite.

This brings much needed uniformity to test skipping when a test requires Multisite or when a test should be excluded from running when Multisite is enabled.

Used in conjunction with the @group ms-required and @group ms-excluded notation, this removes a significant number of skipped tests from the default test suite run.

Fixes #40531

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/adminbar.php

    r40520 r40543  
    7676     */
    7777    public function test_admin_bar_contains_correct_links_for_users_with_no_role() {
    78         if ( is_multisite() ) {
    79             $this->markTestSkipped( 'Test does not run in multisite' );
    80         }
     78        $this->skipWithMultisite();
    8179
    8280        $this->assertFalse( user_can( self::$no_role_id, 'read' ) );
     
    105103     */
    106104    public function test_admin_bar_contains_correct_links_for_users_with_role() {
    107         if ( is_multisite() ) {
    108             $this->markTestSkipped( 'Test does not run in multisite' );
    109         }
     105        $this->skipWithMultisite();
    110106
    111107        $this->assertTrue( user_can( self::$editor_id, 'read' ) );
     
    137133     */
    138134    public function test_admin_bar_contains_correct_links_for_users_with_no_role_on_blog() {
    139         if ( ! is_multisite() ) {
    140             $this->markTestSkipped( 'Test only runs in multisite' );
    141         }
     135        $this->skipWithoutMultisite();
    142136
    143137        $blog_id = self::factory()->blog->create( array(
     
    188182     */
    189183    public function test_admin_bar_contains_correct_links_for_users_with_no_role_on_network() {
    190         if ( ! is_multisite() ) {
    191             $this->markTestSkipped( 'Test only runs in multisite' );
    192         }
     184        $this->skipWithoutMultisite();
    193185
    194186        $this->assertTrue( user_can( self::$admin_id, 'read' ) );
     
    433425     */
    434426    public function test_admin_bar_contains_correct_about_link_for_users_with_role() {
    435         if ( is_multisite() ) {
    436             $this->markTestSkipped( 'Test does not run in multisite' );
    437         }
     427        $this->skipWithMultisite();
    438428
    439429        wp_set_current_user( self::$editor_id );
     
    454444     */
    455445    public function test_admin_bar_contains_correct_about_link_for_users_with_no_role() {
    456         if ( is_multisite() ) {
    457             $this->markTestSkipped( 'Test does not run in multisite' );
    458         }
     446        $this->skipWithMultisite();
    459447
    460448        wp_set_current_user( self::$no_role_id );
     
    477465     */
    478466    public function test_admin_bar_contains_correct_about_link_for_users_with_no_role_in_multisite() {
    479         if ( ! is_multisite() ) {
    480             $this->markTestSkipped( 'Test only runs in multisite' );
    481         }
     467        $this->skipWithoutMultisite();
    482468
    483469        // User is not a member of a site.
     
    597583     */
    598584    public function test_my_sites_network_menu_for_regular_user() {
    599         if ( ! is_multisite() ) {
    600             $this->markTestSkipped( 'Test only runs in multisite' );
    601         }
     585        $this->skipWithoutMultisite();
    602586
    603587        wp_set_current_user( self::$editor_id );
     
    616600     */
    617601    public function test_my_sites_network_menu_for_super_admin() {
    618         if ( ! is_multisite() ) {
    619             $this->markTestSkipped( 'Test only runs in multisite' );
    620         }
     602        $this->skipWithoutMultisite();
    621603
    622604        wp_set_current_user( self::$editor_id );
     
    637619     */
    638620    public function test_my_sites_network_menu_for_regular_user_with_network_caps() {
     621        $this->skipWithoutMultisite();
     622
    639623        global $current_user;
    640 
    641         if ( ! is_multisite() ) {
    642             $this->markTestSkipped( 'Test only runs in multisite' );
    643         }
    644624
    645625        $network_user_caps = array( 'manage_network', 'manage_network_themes', 'manage_network_plugins' );
Note: See TracChangeset for help on using the changeset viewer.