From c759785cea3579e092ff2fb9bf81280cde8542fa Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Mon, 1 May 2017 20:34:10 +0000 Subject: [PATCH] Build/Test Tools: Automatically skip tests in the `ms-required` and `ms-excluded` groups. This removes the need to manually call `$this->skipWithMultisite()` and `$this->skipWithoutMultisite()` from within the test when the test only runs without Multisite or only runs on Multisite, respectively. Props jdgrimes for the suggestion. Fixes #40531 git-svn-id: https://develop.svn.wordpress.org/trunk@40564 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/testcase.php | 11 ++++++++++ tests/phpunit/tests/adminbar.php | 20 ----------------- tests/phpunit/tests/customize/setting.php | 2 -- tests/phpunit/tests/functions.php | 4 ---- tests/phpunit/tests/general/template.php | 16 -------------- tests/phpunit/tests/l10n/getLocale.php | 2 -- tests/phpunit/tests/link/getDashboardUrl.php | 4 ---- tests/phpunit/tests/oembed/controller.php | 2 -- tests/phpunit/tests/option/networkOption.php | 10 --------- tests/phpunit/tests/option/siteTransient.php | 2 -- .../tests/rest-api/rest-users-controller.php | 22 ------------------- tests/phpunit/tests/rewrite.php | 4 ---- tests/phpunit/tests/theme/WPTheme.php | 8 ------- tests/phpunit/tests/user.php | 2 -- tests/phpunit/tests/user/capabilities.php | 16 -------------- tests/phpunit/tests/user/countUsers.php | 4 ---- tests/phpunit/tests/user/query.php | 20 ----------------- .../tests/user/wpAuthenticateSpamCheck.php | 6 ----- tests/phpunit/tests/user/wpDeleteUser.php | 4 ---- .../tests/user/wpGetUsersWithNoRole.php | 4 ---- 20 files changed, 11 insertions(+), 152 deletions(-) diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index 95feba846c..ba1c47ffdb 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -577,6 +577,17 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { protected function checkRequirements() { parent::checkRequirements(); + $annotations = $this->getAnnotations(); + + if ( ! empty( $annotations['group'] ) ) { + if ( in_array( 'ms-required', $annotations['group'], true ) ) { + $this->skipWithoutMultisite(); + } + if ( in_array( 'ms-excluded', $annotations['group'], true ) ) { + $this->skipWithMultisite(); + } + } + // Core tests no longer check against open Trac tickets, but others using WP_UnitTestCase may do so. if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) { return; diff --git a/tests/phpunit/tests/adminbar.php b/tests/phpunit/tests/adminbar.php index a7cdbaf398..b6ec315df3 100644 --- a/tests/phpunit/tests/adminbar.php +++ b/tests/phpunit/tests/adminbar.php @@ -75,8 +75,6 @@ class Tests_AdminBar extends WP_UnitTestCase { * @group ms-excluded */ public function test_admin_bar_contains_correct_links_for_users_with_no_role() { - $this->skipWithMultisite(); - $this->assertFalse( user_can( self::$no_role_id, 'read' ) ); wp_set_current_user( self::$no_role_id ); @@ -102,8 +100,6 @@ class Tests_AdminBar extends WP_UnitTestCase { * @group ms-excluded */ public function test_admin_bar_contains_correct_links_for_users_with_role() { - $this->skipWithMultisite(); - $this->assertTrue( user_can( self::$editor_id, 'read' ) ); wp_set_current_user( self::$editor_id ); @@ -132,8 +128,6 @@ class Tests_AdminBar extends WP_UnitTestCase { * @group ms-required */ public function test_admin_bar_contains_correct_links_for_users_with_no_role_on_blog() { - $this->skipWithoutMultisite(); - $blog_id = self::factory()->blog->create( array( 'user_id' => self::$admin_id, ) ); @@ -181,8 +175,6 @@ class Tests_AdminBar extends WP_UnitTestCase { * @group ms-required */ public function test_admin_bar_contains_correct_links_for_users_with_no_role_on_network() { - $this->skipWithoutMultisite(); - $this->assertTrue( user_can( self::$admin_id, 'read' ) ); $this->assertFalse( user_can( self::$no_role_id, 'read' ) ); @@ -424,8 +416,6 @@ class Tests_AdminBar extends WP_UnitTestCase { * @group ms-excluded */ public function test_admin_bar_contains_correct_about_link_for_users_with_role() { - $this->skipWithMultisite(); - wp_set_current_user( self::$editor_id ); $wp_admin_bar = $this->get_standard_admin_bar(); @@ -443,8 +433,6 @@ class Tests_AdminBar extends WP_UnitTestCase { * @group ms-excluded */ public function test_admin_bar_contains_correct_about_link_for_users_with_no_role() { - $this->skipWithMultisite(); - wp_set_current_user( self::$no_role_id ); $wp_admin_bar = $this->get_standard_admin_bar(); @@ -464,8 +452,6 @@ class Tests_AdminBar extends WP_UnitTestCase { * @group ms-required */ public function test_admin_bar_contains_correct_about_link_for_users_with_no_role_in_multisite() { - $this->skipWithoutMultisite(); - // User is not a member of a site. remove_user_from_blog( self::$no_role_id, get_current_blog_id() ); @@ -582,8 +568,6 @@ class Tests_AdminBar extends WP_UnitTestCase { * @group ms-required */ public function test_my_sites_network_menu_for_regular_user() { - $this->skipWithoutMultisite(); - wp_set_current_user( self::$editor_id ); $wp_admin_bar = $this->get_standard_admin_bar(); @@ -599,8 +583,6 @@ class Tests_AdminBar extends WP_UnitTestCase { * @group ms-required */ public function test_my_sites_network_menu_for_super_admin() { - $this->skipWithoutMultisite(); - wp_set_current_user( self::$editor_id ); grant_super_admin( self::$editor_id ); @@ -618,8 +600,6 @@ class Tests_AdminBar extends WP_UnitTestCase { * @group ms-required */ public function test_my_sites_network_menu_for_regular_user_with_network_caps() { - $this->skipWithoutMultisite(); - global $current_user; $network_user_caps = array( 'manage_network', 'manage_network_themes', 'manage_network_plugins' ); diff --git a/tests/phpunit/tests/customize/setting.php b/tests/phpunit/tests/customize/setting.php index cb0cdf8296..2450ec2547 100644 --- a/tests/phpunit/tests/customize/setting.php +++ b/tests/phpunit/tests/customize/setting.php @@ -564,8 +564,6 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { * @group ms-required */ function test_previewing_with_switch_to_blog() { - $this->skipWithoutMultisite(); - wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); $type = 'option'; $name = 'blogdescription'; diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index 8400720026..252d890bbb 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -938,8 +938,6 @@ class Tests_Functions extends WP_UnitTestCase { * @group ms-excluded */ function test_wp_check_filetype_and_ext_with_filtered_svg() { - $this->skipWithMultisite(); - if ( ! extension_loaded( 'fileinfo' ) ) { $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' ); } @@ -965,8 +963,6 @@ class Tests_Functions extends WP_UnitTestCase { * @group ms-excluded */ function test_wp_check_filetype_and_ext_with_filtered_woff() { - $this->skipWithMultisite(); - if ( ! extension_loaded( 'fileinfo' ) ) { $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' ); } diff --git a/tests/phpunit/tests/general/template.php b/tests/phpunit/tests/general/template.php index 3001c04eef..4d47a4d46a 100644 --- a/tests/phpunit/tests/general/template.php +++ b/tests/phpunit/tests/general/template.php @@ -75,8 +75,6 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required */ function test_has_site_icon_returns_true_when_called_for_other_site_with_site_icon_set() { - $this->skipWithoutMultisite(); - $blog_id = $this->factory->blog->create(); switch_to_blog( $blog_id ); $this->_set_site_icon(); @@ -91,8 +89,6 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required */ function test_has_site_icon_returns_false_when_called_for_other_site_without_site_icon_set() { - $this->skipWithoutMultisite(); - $blog_id = $this->factory->blog->create(); $this->assertFalse( has_site_icon( $blog_id ) ); @@ -265,8 +261,6 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required */ function test_has_custom_logo_returns_true_when_called_for_other_site_with_custom_logo_set() { - $this->skipWithoutMultisite(); - $blog_id = $this->factory->blog->create(); switch_to_blog( $blog_id ); $this->_set_custom_logo(); @@ -281,8 +275,6 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required */ function test_has_custom_logo_returns_false_when_called_for_other_site_without_custom_logo_set() { - $this->skipWithoutMultisite(); - $blog_id = $this->factory->blog->create(); $this->assertFalse( has_custom_logo( $blog_id ) ); @@ -311,8 +303,6 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required */ function test_get_custom_logo_returns_logo_when_called_for_other_site_with_custom_logo_set() { - $this->skipWithoutMultisite(); - $blog_id = $this->factory->blog->create(); switch_to_blog( $blog_id ); @@ -532,8 +522,6 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required */ function test_get_site_icon_url_preserves_switched_state() { - $this->skipWithoutMultisite(); - $blog_id = $this->factory->blog->create(); switch_to_blog( $blog_id ); @@ -553,8 +541,6 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required */ function test_has_custom_logo_preserves_switched_state() { - $this->skipWithoutMultisite(); - $blog_id = $this->factory->blog->create(); switch_to_blog( $blog_id ); @@ -574,8 +560,6 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required */ function test_get_custom_logo_preserves_switched_state() { - $this->skipWithoutMultisite(); - $blog_id = $this->factory->blog->create(); switch_to_blog( $blog_id ); diff --git a/tests/phpunit/tests/l10n/getLocale.php b/tests/phpunit/tests/l10n/getLocale.php index 513bc92aac..ac9e429691 100644 --- a/tests/phpunit/tests/l10n/getLocale.php +++ b/tests/phpunit/tests/l10n/getLocale.php @@ -21,8 +21,6 @@ class Tests_L10n_GetLocale extends WP_UnitTestCase { * @group ms-required */ public function test_local_option_should_take_precedence_on_multisite() { - $this->skipWithoutMultisite(); - global $locale; $old_locale = $locale; $locale = null; diff --git a/tests/phpunit/tests/link/getDashboardUrl.php b/tests/phpunit/tests/link/getDashboardUrl.php index 07c2711ca3..8557be1e27 100644 --- a/tests/phpunit/tests/link/getDashboardUrl.php +++ b/tests/phpunit/tests/link/getDashboardUrl.php @@ -41,8 +41,6 @@ class Tests_Link_GetDashboardUrl extends WP_UnitTestCase { * @group ms-required */ public function test_get_dashboard_url_for_network_administrator_with_no_sites() { - $this->skipWithoutMultisite(); - grant_super_admin( self::$user_id ); add_filter( 'get_blogs_of_user', '__return_empty_array' ); @@ -60,8 +58,6 @@ class Tests_Link_GetDashboardUrl extends WP_UnitTestCase { * @group ms-required */ public function test_get_dashboard_url_for_administrator_of_different_site() { - $this->skipWithoutMultisite(); - $site_id = self::factory()->blog->create( array( 'user_id' => self::$user_id ) ); remove_user_from_blog( self::$user_id, get_current_blog_id() ); diff --git a/tests/phpunit/tests/oembed/controller.php b/tests/phpunit/tests/oembed/controller.php index aa9b3418d7..de41b0d058 100644 --- a/tests/phpunit/tests/oembed/controller.php +++ b/tests/phpunit/tests/oembed/controller.php @@ -256,8 +256,6 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { * @group ms-required */ function test_request_ms_child_in_root_blog() { - $this->skipWithoutMultisite(); - $child = self::factory()->blog->create(); switch_to_blog( $child ); diff --git a/tests/phpunit/tests/option/networkOption.php b/tests/phpunit/tests/option/networkOption.php index 8aec0d7408..656fcab0ba 100644 --- a/tests/phpunit/tests/option/networkOption.php +++ b/tests/phpunit/tests/option/networkOption.php @@ -16,8 +16,6 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { * @group ms-required */ function test_add_network_option_not_available_on_other_network() { - $this->skipWithoutMultisite(); - $id = self::factory()->network->create(); $option = __FUNCTION__; $value = __FUNCTION__; @@ -30,8 +28,6 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { * @group ms-required */ function test_add_network_option_available_on_same_network() { - $this->skipWithoutMultisite(); - $id = self::factory()->network->create(); $option = __FUNCTION__; $value = __FUNCTION__; @@ -44,8 +40,6 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { * @group ms-required */ function test_delete_network_option_on_only_one_network() { - $this->skipWithoutMultisite(); - $id = self::factory()->network->create(); $option = __FUNCTION__; $value = __FUNCTION__; @@ -61,8 +55,6 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { * @group ms-excluded */ public function test_add_network_option_is_not_stored_as_autoload_option() { - $this->skipWithMultisite(); - $key = __FUNCTION__; add_network_option( null, $key, 'Not an autoload option' ); @@ -77,8 +69,6 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { * @group ms-excluded */ public function test_update_network_option_is_not_stored_as_autoload_option() { - $this->skipWithMultisite(); - $key = __FUNCTION__; update_network_option( null, $key, 'Not an autoload option' ); diff --git a/tests/phpunit/tests/option/siteTransient.php b/tests/phpunit/tests/option/siteTransient.php index d7da947285..8a2965f9d4 100644 --- a/tests/phpunit/tests/option/siteTransient.php +++ b/tests/phpunit/tests/option/siteTransient.php @@ -47,8 +47,6 @@ class Tests_Option_SiteTransient extends WP_UnitTestCase { * @group ms-excluded */ public function test_set_site_transient_is_not_stored_as_autoload_option() { - $this->skipWithMultisite(); - $key = 'not_autoloaded'; set_site_transient( $key, 'Not an autoload option' ); diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php index 062a90e770..44853aa13a 100644 --- a/tests/phpunit/tests/rest-api/rest-users-controller.php +++ b/tests/phpunit/tests/rest-api/rest-users-controller.php @@ -996,8 +996,6 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { * @group ms-required */ public function test_create_new_network_user_on_site_does_not_add_user_to_sub_site() { - $this->skipWithoutMultisite(); - $this->allow_user_to_manage_multisite(); $params = array( @@ -1026,8 +1024,6 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { * @group ms-required */ public function test_create_new_network_user_on_sub_site_adds_user_to_site() { - $this->skipWithoutMultisite(); - $this->allow_user_to_manage_multisite(); $params = array( @@ -1060,8 +1056,6 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { * @group ms-required */ public function test_create_existing_network_user_on_sub_site_has_error() { - $this->skipWithoutMultisite(); - $this->allow_user_to_manage_multisite(); $params = array( @@ -1448,8 +1442,6 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { * @group ms-excluded */ public function test_update_user_role_invalid_privilege_deescalation() { - $this->skipWithMultisite(); - $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); wp_set_current_user( $user_id ); @@ -1479,8 +1471,6 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { * @group ms-required */ public function test_update_user_role_privilege_deescalation_multisite() { - $this->skipWithoutMultisite(); - $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); wp_set_current_user( $user_id ); @@ -2228,8 +2218,6 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { * @group ms-required */ public function test_get_item_from_different_site_as_site_administrator() { - $this->skipWithoutMultisite(); - switch_to_blog( self::$site ); $user_id = $this->factory->user->create( array( 'role' => 'author', @@ -2248,8 +2236,6 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { * @group ms-required */ public function test_get_item_from_different_site_as_network_administrator() { - $this->skipWithoutMultisite(); - switch_to_blog( self::$site ); $user_id = $this->factory->user->create( array( 'role' => 'author', @@ -2268,8 +2254,6 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { * @group ms-required */ public function test_update_item_from_different_site_as_site_administrator() { - $this->skipWithoutMultisite(); - switch_to_blog( self::$site ); $user_id = $this->factory->user->create( array( 'role' => 'author', @@ -2290,8 +2274,6 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { * @group ms-required */ public function test_update_item_from_different_site_as_network_administrator() { - $this->skipWithoutMultisite(); - switch_to_blog( self::$site ); $user_id = $this->factory->user->create( array( 'role' => 'author', @@ -2312,8 +2294,6 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { * @group ms-required */ public function test_delete_item_from_different_site_as_site_administrator() { - $this->skipWithoutMultisite(); - switch_to_blog( self::$site ); $user_id = $this->factory->user->create( array( 'role' => 'author', @@ -2334,8 +2314,6 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { * @group ms-required */ public function test_delete_item_from_different_site_as_network_administrator() { - $this->skipWithoutMultisite(); - switch_to_blog( self::$site ); $user_id = $this->factory->user->create( array( 'role' => 'author', diff --git a/tests/phpunit/tests/rewrite.php b/tests/phpunit/tests/rewrite.php index e740f21b0a..5f7514915e 100644 --- a/tests/phpunit/tests/rewrite.php +++ b/tests/phpunit/tests/rewrite.php @@ -122,8 +122,6 @@ class Tests_Rewrite extends WP_UnitTestCase { * @group ms-required */ function test_url_to_postid_of_http_site_when_current_site_uses_https() { - $this->skipWithoutMultisite(); - $_SERVER['HTTPS'] = 'on'; $network_home = home_url(); @@ -317,8 +315,6 @@ class Tests_Rewrite extends WP_UnitTestCase { * @group ms-required */ function test_url_to_postid_ms_home_url_collision() { - $this->skipWithoutMultisite(); - $blog_id = self::factory()->blog->create( array( 'path' => '/example' ) ); switch_to_blog( $blog_id ); diff --git a/tests/phpunit/tests/theme/WPTheme.php b/tests/phpunit/tests/theme/WPTheme.php index b379d3b044..da7374e090 100644 --- a/tests/phpunit/tests/theme/WPTheme.php +++ b/tests/phpunit/tests/theme/WPTheme.php @@ -148,8 +148,6 @@ class Tests_Theme_WPTheme extends WP_UnitTestCase { * @group ms-required */ function test_wp_theme_network_enable_single_theme() { - $this->skipWithoutMultisite(); - $theme = 'testtheme-1'; $current_allowed_themes = get_site_option( 'allowedthemes' ); WP_Theme::network_enable_theme( $theme ); @@ -167,8 +165,6 @@ class Tests_Theme_WPTheme extends WP_UnitTestCase { * @group ms-required */ function test_wp_theme_network_enable_multiple_themes() { - $this->skipWithoutMultisite(); - $themes = array( 'testtheme-2', 'testtheme-3' ); $current_allowed_themes = get_site_option( 'allowedthemes' ); WP_Theme::network_enable_theme( $themes ); @@ -186,8 +182,6 @@ class Tests_Theme_WPTheme extends WP_UnitTestCase { * @group ms-required */ function test_network_disable_single_theme() { - $this->skipWithoutMultisite(); - $current_allowed_themes = get_site_option( 'allowedthemes' ); $allowed_themes = array( 'existing-1' => true, 'existing-2' => true, 'existing-3' => true ); @@ -209,8 +203,6 @@ class Tests_Theme_WPTheme extends WP_UnitTestCase { * @group ms-required */ function test_network_disable_multiple_themes() { - $this->skipWithoutMultisite(); - $current_allowed_themes = get_site_option( 'allowedthemes' ); $allowed_themes = array( 'existing-4' => true, 'existing-5' => true, 'existing-6' => true ); diff --git a/tests/phpunit/tests/user.php b/tests/phpunit/tests/user.php index c36002c68f..b2b87d19d2 100644 --- a/tests/phpunit/tests/user.php +++ b/tests/phpunit/tests/user.php @@ -652,8 +652,6 @@ class Tests_User extends WP_UnitTestCase { * @group ms-required */ function test_illegal_user_logins_multisite() { - $this->skipWithoutMultisite(); - $user_data = array( 'user_login' => 'testuser', 'user_email' => 'testuser@example.com', diff --git a/tests/phpunit/tests/user/capabilities.php b/tests/phpunit/tests/user/capabilities.php index ca73ab3929..241270495c 100644 --- a/tests/phpunit/tests/user/capabilities.php +++ b/tests/phpunit/tests/user/capabilities.php @@ -615,8 +615,6 @@ class Tests_User_Capabilities extends WP_UnitTestCase { * @group ms-required */ function test_super_admin_caps() { - $this->skipWithoutMultisite(); - $caps = $this->getAllCapsAndRoles(); $user = self::$super_admin; @@ -1360,8 +1358,6 @@ class Tests_User_Capabilities extends WP_UnitTestCase { * @group ms-required */ function test_borked_current_user_can_for_blog() { - $this->skipWithoutMultisite(); - $orig_blog_id = get_current_blog_id(); $blog_id = self::factory()->blog->create(); @@ -1421,8 +1417,6 @@ class Tests_User_Capabilities extends WP_UnitTestCase { * @group ms-required */ function test_multisite_administrator_can_not_edit_users() { - $this->skipWithoutMultisite(); - $user = self::$users['administrator']; $other_user = self::$users['subscriber']; @@ -1455,8 +1449,6 @@ class Tests_User_Capabilities extends WP_UnitTestCase { * @group ms-required */ public function test_only_super_admins_can_delete_users_on_multisite() { - $this->skipWithoutMultisite(); - $this->assertTrue( user_can( self::$super_admin->ID, 'delete_user', self::$users['subscriber']->ID ) ); $this->assertFalse( user_can( self::$users['administrator']->ID, 'delete_user', self::$users['subscriber']->ID ) ); @@ -1470,8 +1462,6 @@ class Tests_User_Capabilities extends WP_UnitTestCase { * @group ms-excluded */ public function test_only_admins_can_delete_users_on_single_site() { - $this->skipWithMultisite(); - $this->assertTrue( user_can( self::$users['administrator']->ID, 'delete_user', self::$users['subscriber']->ID ) ); $this->assertFalse( user_can( self::$users['editor']->ID, 'delete_user', self::$users['subscriber']->ID ) ); @@ -1529,8 +1519,6 @@ class Tests_User_Capabilities extends WP_UnitTestCase { * @group ms-required */ function test_multisite_administrator_with_manage_network_users_can_edit_users() { - $this->skipWithoutMultisite(); - $user = self::$users['administrator']; $user->add_cap( 'manage_network_users' ); $other_user = self::$users['subscriber']; @@ -1548,8 +1536,6 @@ class Tests_User_Capabilities extends WP_UnitTestCase { * @group ms-required */ function test_multisite_administrator_with_manage_network_users_can_not_edit_super_admin() { - $this->skipWithoutMultisite(); - $user = self::$users['administrator']; $user->add_cap( 'manage_network_users' ); @@ -1774,8 +1760,6 @@ class Tests_User_Capabilities extends WP_UnitTestCase { * @group ms-required */ public function test_only_super_admins_can_remove_themselves_on_multisite() { - $this->skipWithoutMultisite(); - $this->assertTrue( user_can( self::$super_admin->ID, 'remove_user', self::$super_admin->ID ) ); $this->assertFalse( user_can( self::$users['administrator']->ID, 'remove_user', self::$users['administrator']->ID ) ); diff --git a/tests/phpunit/tests/user/countUsers.php b/tests/phpunit/tests/user/countUsers.php index 08e74e7a54..f5fa6b9356 100644 --- a/tests/phpunit/tests/user/countUsers.php +++ b/tests/phpunit/tests/user/countUsers.php @@ -12,8 +12,6 @@ class Tests_User_CountUsers extends WP_UnitTestCase { * @group ms-excluded */ public function test_count_users_is_accurate( $strategy ) { - $this->skipWithMultisite(); - // Setup users $admin = self::factory()->user->create( array( 'role' => 'administrator', @@ -60,8 +58,6 @@ class Tests_User_CountUsers extends WP_UnitTestCase { * @dataProvider data_count_users_strategies */ public function test_count_users_multisite_is_accurate( $strategy ) { - $this->skipWithoutMultisite(); - // Setup users $admin = self::factory()->user->create( array( 'role' => 'administrator', diff --git a/tests/phpunit/tests/user/query.php b/tests/phpunit/tests/user/query.php index 5ac9a0b352..ee2f3d8309 100644 --- a/tests/phpunit/tests/user/query.php +++ b/tests/phpunit/tests/user/query.php @@ -555,8 +555,6 @@ class Tests_User_Query extends WP_UnitTestCase { * @group ms-excluded */ public function test_roles_and_caps_should_be_populated_for_explicit_value_of_blog_id_on_nonms() { - $this->skipWithMultisite(); - $query = new WP_User_Query( array( 'include' => self::$author_ids[0], 'blog_id' => get_current_blog_id(), @@ -574,8 +572,6 @@ class Tests_User_Query extends WP_UnitTestCase { * @group ms-required */ public function test_roles_and_caps_should_be_populated_for_explicit_value_of_current_blog_id_on_ms() { - $this->skipWithoutMultisite(); - $query = new WP_User_Query( array( 'include' => self::$author_ids[0], 'blog_id' => get_current_blog_id(), @@ -593,8 +589,6 @@ class Tests_User_Query extends WP_UnitTestCase { * @group ms-required */ public function test_roles_and_caps_should_be_populated_for_explicit_value_of_different_blog_id_on_ms_when_fields_all_with_meta() { - $this->skipWithoutMultisite(); - $b = self::factory()->blog->create(); add_user_to_blog( $b, self::$author_ids[0], 'author' ); @@ -618,8 +612,6 @@ class Tests_User_Query extends WP_UnitTestCase { * @group ms-required */ public function test_roles_and_caps_should_be_populated_for_explicit_value_of_different_blog_id_on_ms_when_fields_all() { - $this->skipWithoutMultisite(); - $b = self::factory()->blog->create(); add_user_to_blog( $b, self::$author_ids[0], 'author' ); @@ -642,8 +634,6 @@ class Tests_User_Query extends WP_UnitTestCase { * @group ms-required */ public function test_who_authors() { - $this->skipWithoutMultisite(); - $b = self::factory()->blog->create(); add_user_to_blog( $b, self::$author_ids[0], 'subscriber' ); @@ -667,8 +657,6 @@ class Tests_User_Query extends WP_UnitTestCase { * @group ms-required */ public function test_who_authors_should_work_alongside_meta_query() { - $this->skipWithoutMultisite(); - $b = self::factory()->blog->create(); add_user_to_blog( $b, self::$author_ids[0], 'subscriber' ); @@ -701,8 +689,6 @@ class Tests_User_Query extends WP_UnitTestCase { * @group ms-required */ public function test_who_authors_should_work_alongside_meta_params() { - $this->skipWithoutMultisite(); - $b = self::factory()->blog->create(); add_user_to_blog( $b, self::$author_ids[0], 'subscriber' ); @@ -793,8 +779,6 @@ class Tests_User_Query extends WP_UnitTestCase { * @group ms-required */ public function test_has_published_posts_should_respect_blog_id() { - $this->skipWithoutMultisite(); - $blogs = self::factory()->blog->create_many( 2 ); add_user_to_blog( $blogs[0], self::$author_ids[0], 'author' ); @@ -1359,8 +1343,6 @@ class Tests_User_Query extends WP_UnitTestCase { * @group ms-required */ public function test_blog_id_should_restrict_by_blog_without_requiring_a_named_role() { - $this->skipWithoutMultisite(); - $sites = self::factory()->blog->create_many( 2 ); add_user_to_blog( $sites[0], self::$author_ids[0], 'author' ); @@ -1380,8 +1362,6 @@ class Tests_User_Query extends WP_UnitTestCase { * @group ms-required */ public function test_calling_prepare_query_a_second_time_should_not_add_another_cap_query_on_multisite() { - $this->skipWithoutMultisite(); - $site_id = get_current_blog_id(); add_user_to_blog( $site_id, self::$author_ids[0], 'author' ); diff --git a/tests/phpunit/tests/user/wpAuthenticateSpamCheck.php b/tests/phpunit/tests/user/wpAuthenticateSpamCheck.php index 7e3cd13c51..78cbdcd2c3 100644 --- a/tests/phpunit/tests/user/wpAuthenticateSpamCheck.php +++ b/tests/phpunit/tests/user/wpAuthenticateSpamCheck.php @@ -9,8 +9,6 @@ class Tests_User_WpAuthenticateSpamCheck extends WP_UnitTestCase { * @group ms-excluded */ function test_wp_authenticate_spam_check_returns_user_when_single_site() { - $this->skipWithMultisite(); - $user_id = self::factory()->user->create( array( 'role' => 'contributor' ) ); $user = new WP_User( $user_id ); $actual_user = wp_authenticate_spam_check( $user ); @@ -23,8 +21,6 @@ class Tests_User_WpAuthenticateSpamCheck extends WP_UnitTestCase { * @group ms-required */ function test_wp_authenticate_spam_check_returns_user_when_not_flagged() { - $this->skipWithoutMultisite(); - $user_id = self::factory()->user->create( array( 'role' => 'contributor' ) ); $user = new WP_User( $user_id ); $actual_user = wp_authenticate_spam_check( $user ); @@ -37,8 +33,6 @@ class Tests_User_WpAuthenticateSpamCheck extends WP_UnitTestCase { * @group ms-required */ function test_wp_authenticate_spam_check_returns_wp_error_when_flagged() { - $this->skipWithoutMultisite(); - $user_id = self::factory()->user->create( array( 'role' => 'contributor' ) ); update_user_status( $user_id, 'spam', 1 ); $user = new WP_User( $user_id ); diff --git a/tests/phpunit/tests/user/wpDeleteUser.php b/tests/phpunit/tests/user/wpDeleteUser.php index ddcec2cd18..7f7e9024db 100644 --- a/tests/phpunit/tests/user/wpDeleteUser.php +++ b/tests/phpunit/tests/user/wpDeleteUser.php @@ -127,8 +127,6 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase { * @group ms-excluded */ public function test_numeric_string_user_id() { - $this->skipWithMultisite(); - $u = self::factory()->user->create(); $u_string = (string) $u; @@ -148,8 +146,6 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase { * @group ms-excluded */ public function test_should_return_false_for_object_user_id() { - $this->skipWithMultisite(); - $u_obj = self::factory()->user->create_and_get(); $this->assertFalse( wp_delete_user( $u_obj ) ); $this->assertEquals( $u_obj->ID, username_exists( $u_obj->user_login ) ); diff --git a/tests/phpunit/tests/user/wpGetUsersWithNoRole.php b/tests/phpunit/tests/user/wpGetUsersWithNoRole.php index 3346f1869a..82c0da73bf 100644 --- a/tests/phpunit/tests/user/wpGetUsersWithNoRole.php +++ b/tests/phpunit/tests/user/wpGetUsersWithNoRole.php @@ -10,8 +10,6 @@ class Tests_User_GetUsersWithNoRole extends WP_UnitTestCase { * @group ms-excluded */ public function test_get_users_with_no_role_is_accurate() { - $this->skipWithMultisite(); - // Setup users $admin = self::factory()->user->create( array( 'role' => 'administrator', @@ -42,8 +40,6 @@ class Tests_User_GetUsersWithNoRole extends WP_UnitTestCase { * @group ms-required */ public function test_get_users_with_no_role_multisite_is_accurate() { - $this->skipWithoutMultisite(); - // Setup users $admin = self::factory()->user->create( array( 'role' => 'administrator',