简体   繁体   English

用symfony2测试,收费实体有误

[英]Test with symfony2, error in charge entities

I have a unit test like this: 我有这样的单元测试:

namespace My\WebBundle\Tests\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use My\WebBundle\Controller\SynMCController;
use My\WebBundle\Entity\Users;

class MyControllerTest extends \PHPUnit_Framework_TestCase
{
public function testFunction()
    {
        $user1 = new Users();
        ...
    }
}

But when I try to test it with PHP Unit, I get this error: 但是,当我尝试使用PHP Unit对其进行测试时,出现此错误:

Class 'My\\WebBundle\\Entity\\Users;' 类“ My \\ WebBundle \\ Entity \\ Users;” not found in ...\\MyControllerTest.php on line 13 在第13行的... \\ MyControllerTest.php中找不到

Line 13 is: 第13行是:

$user1 = new Users();

¿What is the problem to use a Entity in my Test Case? ¿在我的测试用例中使用实体有什么问题? Of course my entity Users is in this path, I have used this path in lots of classes. 当然,我的实体用户在该路径中,我在很多类中都使用了此路径。

Thanks!!! 谢谢!!!

Make sure your phpunit.xml file is well defined, especially the bootstrap attribute. 确保您的phpunit.xml文件定义正确,尤其是bootstrap属性。 It should point to the app/bootstrap.php.cache file which is in charge of using the right autoloader 它应该指向负责使用正确的自动加载器的app/bootstrap.php.cache文件

require_once __DIR__.'/autoload.php';

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

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