2016-12-09 96 views
0

我在一个sylius项目工作,我有一些功能测试工作。它发生了sylius已经切换到symfony 3.2和很多我的测试不再工作了之后。phpunit找不到教义注释

每当我试图运行测试,我得到这样的错误

Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The annotation "@Doctrine\ORM\Mapping\Entity" in class ...\Entity\Block does not exist, or could not be auto-loaded. 

我phpunit.xml看起来像

<?xml version="1.0" encoding="UTF-8"?> 
<phpunit colors="true" 
    bootstrap="var/bootstrap.php.cache"> 
<php> 
    <server name="KERNEL_DIR" value="./app" /> 
</php> 
<testsuites> 
    <testsuite name="Application Test Suite"> 
     <directory>./src/AppBundle/Tests/</directory> 
    </testsuite> 
</testsuites> 

最后,我测试了这种设置

abstract class BaseTestCase extends KernelTestCase { 
... 
protected function setUp() 
{ 
    static::bootKernel(); 
} 
} 

关于我的设置中可能出现错误的任何想法?

回答

1

找到了修复程序。我决定看看标准回购协议中的phpunit.xml,并将我的“boostrap”选项改为“app/autoload.php”。这解决了我得到的那种错误。

<?xml version="1.0" encoding="UTF-8"?> 
<phpunit colors="true" 
    bootstrap="app/autoload.php"> 
<php> 
    <server name="KERNEL_DIR" value="./app" /> 
</php> 
<testsuites> 
    <testsuite name="Application Test Suite"> 
     <directory>./src/AppBundle/Tests/</directory> 
    </testsuite> 
</testsuites>