我正在使用以下代码在 Prophecy 中编写一些 PHPUnit 测试:
public function testItBuildsAndPersistsEnclosure()
{
$em = $this->prophesize(EntityManagerInterface::class);
}
这产生了以下输出:
Sebastian Bergmann 和贡献者的 PHPUnit 6.5.14。
测试项目测试套件 E.
2 / 2 (100%)时间:105 毫秒,内存:6.00MB
有 1 个错误:
1) Tests\AppBundle\Service\EnclosureBuilderServiceProphecyTest::testItBuildsAndPersistsEnclosure 错误:找不到类“Prophecy\Prophet”
我对 PHPUnit 和一般测试有点陌生,但据我了解,PHPUnit 应该具有对使用 Prophecy 的内置支持,这使得上述错误非常令人惊讶。
我尝试安装phpspec/prophecy但该过程失败,如下所示:
composer require phpspec/prophecy
Using version ^1.10 for phpspec/prophecy
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: don't install phpunit/phpunit 9.0.1
- Conclusion: remove doctrine/instantiator 1.1.0
- Installation request for phpunit/phpunit ^9.0 -> satisfiable by phpunit/phpunit[9.0.0, 9.0.1].
- Conclusion: don't install doctrine/instantiator 1.1.0
- phpunit/phpunit 9.0.0 requires doctrine/instantiator ^1.2.0 -> satisfiable by doctrine/instantiator[1.2.0, 1.3.0].
- Can only install one of: doctrine/instantiator[1.2.0, 1.1.0].
- Can only install one of: doctrine/instantiator[1.3.0, 1.1.0].
- Installation request for doctrine/instantiator (locked at 1.1.0) -> satisfiable by doctrine/instantiator[1.1.0].
Installation failed, reverting ./composer.json to its original content.