Composer php phpunit错误:类';预言家';找不到
我正在用以下代码编写一些预言中的PHPUnit测试:Composer php phpunit错误:类';预言家';找不到,composer-php,phpunit,prophecy,Composer Php,Phpunit,Prophecy,我正在用以下代码编写一些预言中的PHPUnit测试: public function testItBuildsAndPersistsEnclosure() { $em = $this->prophesize(EntityManagerInterface::class); } 这将产生以下输出: PHPUnit 6.5.14由塞巴斯蒂安·伯格曼和贡献者撰写 测试项目测试套件E. 2/2(100%) 时间:105毫秒,内存:6.00MB 有1个错误: (一) Tests\AppBund
public function testItBuildsAndPersistsEnclosure()
{
$em = $this->prophesize(EntityManagerInterface::class);
}
这将产生以下输出:
PHPUnit 6.5.14由塞巴斯蒂安·伯格曼和贡献者撰写
测试项目测试套件E.2/2(100%) 时间:105毫秒,内存:6.00MB 有1个错误: (一) Tests\AppBundle\Service\EnclosureBuilderServiceProphecTest::TestBuildAndPersistsenClosure 错误:未找到类“Prophecy\Prophet” 一般来说,我对PHPUnit和测试有点陌生,但据我所知,PHPUnit应该具有使用预言的能力,这使得上面的错误非常令人惊讶 我尝试安装,但该过程失败,如下所示:
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.
当控制台输出列出v6.5.14时,为什么要在v9.0中安装PHPUnit over Composer?你确定给定的测试行(没有实例化Prophet)会触发该错误吗?@NicoHaase:是的,我非常确定Prophet是导致该错误的原因。我可以问你为什么不升级你的条令/实例化器吗?