PHPUnit - Class '/path/to/my/class.php' 在 '' 中找不到

PHPUnit - Class '/path/to/my/class.php' could not be found in ''

我已经在 Windows 上设置了 PHPUnit,以便在我的 Moodle 应用程序中进行单元测试。我的php版本是7.2.10,PHPUnit的版本是7.5.

我能够成功安装 composer,然后安装 PEAR 和 PHPUnit。

然后我可以通过 运行ning 初始化 Moodle PHPUnit 测试环境:

php ../phpunit/cli/init.php

这成功地设置了测试环境和 运行 应用程序中的所有单元测试。

我遇到的问题是当我尝试 运行 单个测试时,使用

vendor\bin\phpunit /mod/quiz/tests/event_test.php

这给了我以下错误:

Class '/mod/quiz/tests/event_test.php' could not be found in ''.

类似问题的解决方案 PHPUnit error - Class could not be found 并未解决问题。我不得不修改解决方案,因为 StandardTestSuiteLoader class 已更改 - 我尝试对 realpath($suiteClassFile) 进行所有比较,不区分大小写,但这没有用。

我不太熟悉 运行 phpunit 针对文件路径而不是 class 名称,但这是否需要绝对路径?

/mod/quiz/tests/event_test.php

可能正在尝试从根目录加载。要么尝试删除前导 /,要么提供完整的 windows 文件路径,包括 C: