Tests: Skip multisite-only or single site-only tests correctly based on test doc annotations.
Without the `ms-required` and `ms-excluded` groups being marked as excluded in the PHPUnit configurations for the project, those groups were still executed, causing fatal errors. Checking against the groups in the correct structure of the array returned from PHPUnit's `Testcase::getAnnotations()` ensures that those tests are skipped properly. Fixes #43863. git-svn-id: https://develop.svn.wordpress.org/trunk@43005 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f6c215c8bf
commit
79bf20d320
@ -654,11 +654,20 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
||||
|
||||
$annotations = $this->getAnnotations();
|
||||
|
||||
if ( ! empty( $annotations['group'] ) ) {
|
||||
if ( in_array( 'ms-required', $annotations['group'], true ) ) {
|
||||
$groups = array();
|
||||
if ( ! empty( $annotations['class']['group'] ) ) {
|
||||
$groups = array_merge( $groups, $annotations['class']['group'] );
|
||||
}
|
||||
if ( ! empty( $annotations['method']['group'] ) ) {
|
||||
$groups = array_merge( $groups, $annotations['method']['group'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $groups ) ) {
|
||||
if ( in_array( 'ms-required', $groups, true ) ) {
|
||||
$this->skipWithoutMultisite();
|
||||
}
|
||||
if ( in_array( 'ms-excluded', $annotations['group'], true ) ) {
|
||||
|
||||
if ( in_array( 'ms-excluded', $groups, true ) ) {
|
||||
$this->skipWithMultisite();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user