[wp-trac] [WordPress Trac] #43863: Fix broken check in testcase class to prevent multisite-only or single site-only tests from being executed

WordPress Trac noreply at wordpress.org
Wed Apr 25 22:22:51 UTC 2018


#43863: Fix broken check in testcase class to prevent multisite-only or single
site-only tests from being executed
------------------------------+-------------------------
 Reporter:  flixos90          |      Owner:  flixos90
     Type:  defect (bug)      |     Status:  assigned
 Priority:  normal            |  Milestone:  5.0
Component:  Build/Test Tools  |    Version:
 Severity:  normal            |   Keywords:  needs-patch
  Focuses:  multisite         |
------------------------------+-------------------------
 There have been issues reported (for example
 https://wordpress.slack.com/archives/C18723MQ8/p1524646274000249) about
 multisite-only tests incorrectly being executed in single site context and
 vice-versa.

 While core's PHPUnit configuration for single-site ignores tests with a
 group of `ms-required` and its multisite configuration ignores tests with
 a group of `ms-excluded`, there is also a check present in the
 `WP_UnitTestCase` class itself to skip those tests appropriately. This is
 for cases where the PHPUnit configuration doesn't ignore the respective
 groups, which is common in many plugins, most of which don't include a
 multisite-specific `phpunit.xml` file (and even if they did, the `ms-
 required` and `ms-excluded` groups are a relatively recent change that
 don't necessarily have to be excluded in the PHPUnit configuration).
 Long story short, if you run into this error, your PHPUnit configuration
 probably doesn't ignore the groups correctly. However, the actual problem
 is that the check in `WP_UnitTestCase` doesn't work correctly at all,
 making the "fallback" unusable and broken.

 `WP_UnitTestCase` overrides the `checkRequirements()` method from
 PHPUnit's test case class, retrieves the current test's doc annotations
 and checks against `$annotations['group']` whether one of `ms-required` or
 `ms-excluded` is present to then appropriately skip the test. However, the
 "group" key in the `$annotations` array (which comes from PHPUnit's
 `getAnnotations()` method) will never be present since `$annotations`
 always contains a "class" and a "method" key only - those then each
 contain a "group" key. So the code needs to be adjusted to reflect the
 correct format of the annotations array.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/43863>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list