2020 年 11 月更新:Drupal 9 与 PhpUnit 8 兼容。
-> 我建议升级到 Drupal 9。
下面的旧答案:
Drupal 8.8 还不支持 PhpUnit 8。
PHPUnit 7 将于 2020 年 2 月 7 日终止支持
https://www.drupal.org/project/drupal/issues/3063887
但是,如果您从 stacktrace core/tests/bootstrap.php 查看位置,您会发现:
// PHPUnit 4 to PHPUnit 6 bridge. Tests written for PHPUnit 4 need to work on
// PHPUnit 6 with a minimum of fuss.
// @todo provided for BC; remove in Drupal 9.
class_alias(AssertionFailedError::class, '\PHPUnit_Framework_AssertionFailedError');
class_alias(Count::class, '\PHPUnit_Framework_Constraint_Count');
class_alias(Error::class, '\PHPUnit_Framework_Error');
class_alias(Warning::class, '\PHPUnit_Framework_Error_Warning');
class_alias(ExpectationFailedException::class, '\PHPUnit_Framework_ExpectationFailedException');
class_alias(Exception::class, '\PHPUnit_Framework_Exception');
class_alias(InvokedRecorder::class, '\PHPUnit_Framework_MockObject_Matcher_InvokedRecorder');
class_alias(SkippedTestError::class, '\PHPUnit_Framework_SkippedTestError');
class_alias(TestCase::class, '\PHPUnit_Framework_TestCase');
class_alias(Test::class, '\PHPUnit_Util_Test');
class_alias(Xml::class, '\PHPUnit_Util_XML');
因此您可以简单地手动删除InvokedRecorder 行或应用问题#3063887 中的补丁之一(见上文)。
现在,我创建了一个最小的补丁来删除这个引用...
diff --git a/core/tests/bootstrap.php b/core/tests/bootstrap.php
index 467e6af6e6..ca3b579b6c 100644
--- a/core/tests/bootstrap.php
+++ b/core/tests/bootstrap.php
@@ -14,7 +14,6 @@
use PHPUnit\Framework\Error\Warning;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\Exception;
-use PHPUnit\Framework\MockObject\Matcher\InvokedRecorder;
use PHPUnit\Framework\SkippedTestError;
use PHPUnit\Framework\TestCase;
use PHPUnit\Util\Test;
@@ -194,7 +193,6 @@ class_alias(Error::class, '\PHPUnit_Framework_Error');
class_alias(Warning::class, '\PHPUnit_Framework_Error_Warning');
class_alias(ExpectationFailedException::class, '\PHPUnit_Framework_ExpectationFailedException');
class_alias(Exception::class, '\PHPUnit_Framework_Exception');
-class_alias(InvokedRecorder::class, '\PHPUnit_Framework_MockObject_Matcher_InvokedRecorder');
class_alias(SkippedTestError::class, '\PHPUnit_Framework_SkippedTestError');
class_alias(TestCase::class, '\PHPUnit_Framework_TestCase');
class_alias(Test::class, '\PHPUnit_Util_Test');
...可以添加到composer.json:
{
"patches": {
"drupal/core": {
"Remove InvokedRecorder for PhpUnit 8": "src/patches/3063887-InvokedRecorder.patch"
}
}
}