用symfony2测试,负责实体错误

时间:2014-03-06 13:46:53

标签: php unit-testing symfony testing phpunit

我有这样的单元测试:

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();
        ...
    }
}

但是当我尝试用PHP单元测试时,我收到了这个错误:

  

Class'My \ WebBundle \ Entity \ Users;'在第13行的...... \ MyControllerTest.php中找不到

第13行是:

$user1 = new Users();

¿在我的测试用例中使用实体有什么问题?当然我的实体用户在这条路径中,我已经在很多类中使用过这条路径。

感谢!!!

1 个答案:

答案 0 :(得分:0)

确保您的phpunit.xml文件定义良好,尤其是bootstrap属性。它应该指向 app/bootstrap.php.cache文件负责使用正确的自动加载器

require_once __DIR__.'/autoload.php';