简体   繁体   English

嘲讽,Codeception和Symfony-无法重新声明课程

[英]Mockery, Codeception and Symfony - Cannot redeclare class

I have the following part of an existing unit test (with Mockery as enabled module): 我具有现有单元测试的以下部分(将Mockery作为启用的模块):

$mockedEvent = \Mockery::mock('\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent');

This test runs fine and is successful, but as soon as Codeception reaches my functional tests with Symfony2 module I get the following error: 该测试运行良好且成功,但是一旦Codeception通过Symfony2模块达到我的功能测试,我将收到以下错误:

PHP Fatal error:  Cannot declare class Symfony\Component\HttpFoundation\Request, because the name is already in use in /projectDir/var/bootstrap.php.cache on line 365

Somehow the declared classes in my unit tests are causing problems in my functional tests, which leads to me not being able to use Mockery as intended. 单元测试中声明的类以某种方式在功能测试中引起了问题,这导致我无法按预期使用Mockery。 How do I avoid this error? 如何避免此错误?

This error disappeared when upgrading Codeception to 2.2. 将Codeception升级到2.2时,此错误消失了。 - although now Codeception often segfaults when reaching the functional tests, and only works again when running the functional tests only (which works) and then the whole test suite runs fine again. -尽管现在Codeception在进行功能测试时经常会出现段错误,并且仅在仅运行功能测试时才起作用(有效),然后整个测试套件可以再次正常运行。 Always something weird going on with Codeception in my experience. 根据我的经验,Codeception总是发生一些奇怪的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM