mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-06 17:29:05 +00:00
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
This commit is contained in:
@@ -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 ) );
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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' );
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 ) );
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user