Build/Test Tools: Introduce ms-required and ms-excluded groups for tests.

Tests in the `ms-excluded` group are now excluded when running tests with multisite enabled, and tests in the `ms-required` group are excluded when running tests without multisite enabled. The end result is a significantly reduced number of skipped tests polluting PHPUnit's output, which means verbose mode can be used to more easily see which tests are skipped or incomplete, and why.

See #40531


git-svn-id: https://develop.svn.wordpress.org/trunk@40520 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn
2017-04-22 18:58:46 +00:00
parent c717bfbba9
commit 4f8057f7d5
20 changed files with 131 additions and 8 deletions

View File

@@ -992,6 +992,9 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
$this->assertEquals( 'Sorry, that username is not allowed.', $errors['username'] );
}
/**
* @group ms-required
*/
public function test_create_new_network_user_on_site_does_not_add_user_to_sub_site() {
if ( ! is_multisite() ) {
$this->markTestSkipped( 'Test requires multisite.' );
@@ -1021,6 +1024,9 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
$this->assertFalse( $user_is_member );
}
/**
* @group ms-required
*/
public function test_create_new_network_user_on_sub_site_adds_user_to_site() {
if ( ! is_multisite() ) {
$this->markTestSkipped( 'Test requires multisite.' );
@@ -1054,6 +1060,9 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
$this->assertTrue( $user_is_member );
}
/**
* @group ms-required
*/
public function test_create_existing_network_user_on_sub_site_has_error() {
if ( ! is_multisite() ) {
$this->markTestSkipped( 'Test requires multisite.' );
@@ -1441,6 +1450,9 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
$this->assertArrayNotHasKey( 'administrator', $user->caps );
}
/**
* @group ms-excluded
*/
public function test_update_user_role_invalid_privilege_deescalation() {
if ( is_multisite() ) {
return $this->markTestSkipped( 'Test only intended for single site.' );
@@ -1471,6 +1483,9 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
$this->assertArrayNotHasKey( 'editor', $user->caps );
}
/**
* @group ms-required
*/
public function test_update_user_role_privilege_deescalation_multisite() {
if ( ! is_multisite() ) {
return $this->markTestSkipped( 'Test only intended for multisite.' );
@@ -2220,6 +2235,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
/**
* @ticket 39701
* @group ms-required
*/
public function test_get_item_from_different_site_as_site_administrator() {
if ( ! is_multisite() ) {
@@ -2241,6 +2257,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
/**
* @ticket 39701
* @group ms-required
*/
public function test_get_item_from_different_site_as_network_administrator() {
if ( ! is_multisite() ) {
@@ -2262,6 +2279,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
/**
* @ticket 39701
* @group ms-required
*/
public function test_update_item_from_different_site_as_site_administrator() {
if ( ! is_multisite() ) {
@@ -2285,6 +2303,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
/**
* @ticket 39701
* @group ms-required
*/
public function test_update_item_from_different_site_as_network_administrator() {
if ( ! is_multisite() ) {
@@ -2308,6 +2327,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
/**
* @ticket 39701
* @group ms-required
*/
public function test_delete_item_from_different_site_as_site_administrator() {
if ( ! is_multisite() ) {
@@ -2331,6 +2351,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
/**
* @ticket 39701
* @group ms-required
*/
public function test_delete_item_from_different_site_as_network_administrator() {
if ( ! is_multisite() ) {