diff --git a/core/tests/Drupal/Tests/Phpunit5FCTrait.php b/core/tests/Drupal/Tests/Phpunit5FCTrait.php index 8eddcbe30c..17f7b73577 100644 --- a/core/tests/Drupal/Tests/Phpunit5FCTrait.php +++ b/core/tests/Drupal/Tests/Phpunit5FCTrait.php @@ -98,10 +98,12 @@ public function createMock($originalClassName, $methods = array(), array $argume private function isPhpunit5() { // Get the parent class of the currently running test class. $parent = get_parent_class($this); - // Ensure that we do the method exists check of the first parent of $this - // that does not use this trait. Most often the check will be made on - // \PHPUnit\Framework\TestCase.; - while (in_array(__TRAIT__, class_uses($parent), TRUE)) { + // Ensure that the method_exists() check on PHPUnit 5's createMock method is + // carried out on the first parent of $this that does not have access to + // this trait's methods. This is because the trait also has a method called + // createMock(). Most often the check will be made on + // \PHPUnit\Framework\TestCase. + while (method_exists($parent, 'isPhpunit5')) { $parent = get_parent_class($parent); } return method_exists($parent, 'createMock');