WordPress.org

Make WordPress Core

Changeset 43005


Ignore:
Timestamp:
04/25/2018 10:37:08 PM (3 years ago)
Author:
flixos90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase.php

    r42836 r43005  
    655655        $annotations = $this->getAnnotations();
    656656
    657         if ( ! empty( $annotations['group'] ) ) {
    658             if ( in_array( 'ms-required', $annotations['group'], true ) ) {
     657        $groups = array();
     658        if ( ! empty( $annotations['class']['group'] ) ) {
     659            $groups = array_merge( $groups, $annotations['class']['group'] );
     660        }
     661        if ( ! empty( $annotations['method']['group'] ) ) {
     662            $groups = array_merge( $groups, $annotations['method']['group'] );
     663        }
     664
     665        if ( ! empty( $groups ) ) {
     666            if ( in_array( 'ms-required', $groups, true ) ) {
    659667                $this->skipWithoutMultisite();
    660668            }
    661             if ( in_array( 'ms-excluded', $annotations['group'], true ) ) {
     669
     670            if ( in_array( 'ms-excluded', $groups, true ) ) {
    662671                $this->skipWithMultisite();
    663672            }
Note: See TracChangeset for help on using the changeset viewer.