Symfony LiipFunctionalTestBundle loadFixtures重复条目

时间:2015-10-25 12:02:54

标签: symfony functional-testing liipfunctionaltestbundle

我在Symfony v2.7中再次与Liip / LiipFunctionalTestBundle挣扎。我有两个测试,除了通过这个包加载灯具什么也没做。如果我在两个类中加载相同的fixture类,第二个尝试两次提交他的灯具!如果灯具不同,一切都很好。

有人有使用此套装的经验吗?

use Liip\FunctionalTestBundle\Test\WebTestCase as WebTestCase;

class AgencyControllerTest extends WebTestCase
{    
    public function testOne()
    {
        $this->loadFixtures([
            'Barra\AdminBundle\DataFixtures\ORM\LoadUserData',
        ]);
    }

    public function testTwo()
    {
        $this->loadFixtures([
            'Barra\AdminBundle\DataFixtures\ORM\LoadUserData',
            'Barra\AdminBundle\DataFixtures\ORM\LoadAgencyData',
        ]);
    }

test.log extract

doctrine.DEBUG: DELETE FROM Agency [] []
doctrine.DEBUG: DELETE FROM AppUser [] []
[...]
doctrine.DEBUG: "START TRANSACTION" [] []
doctrine.DEBUG: INSERT INTO AppUser (...) {..1..} []
doctrine.DEBUG: INSERT INTO AppUser (...) {..2..} []
doctrine.DEBUG: INSERT INTO AppUser (...) {..3..} []
doctrine.DEBUG: "COMMIT" [] []

doctrine.DEBUG: DELETE FROM Agency [] []
doctrine.DEBUG: DELETE FROM AppUser [] []
[...]
doctrine.DEBUG: "START TRANSACTION" [] []
doctrine.DEBUG: INSERT INTO Agency (...) {..1..} []
doctrine.DEBUG: INSERT INTO Agency (...) {..2..} []
doctrine.DEBUG: INSERT INTO Agency (...) {..3..} []
doctrine.DEBUG: INSERT INTO AppUser (...) {..1..} []
doctrine.DEBUG: INSERT INTO AppUser (...) {..2..} []
doctrine.DEBUG: INSERT INTO AppUser (...) {..3..} []
doctrine.DEBUG: INSERT INTO AppUser (...) {..1..} [] <---
[2015-10-25 11:39:09] doctrine.DEBUG: "ROLLBACK" [] []

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'UNIQ_8105EAD692FC23A8'

1 个答案:

答案 0 :(得分:1)

我切换到推荐的SQLite DB,除了描述的错误之外,它运行良好。但是启用cache_sqlite_db解决了我的问题。这对我来说似乎是一个错误,但至少它现在正在发挥作用。