Symfony LiipFunctionalTestBundle loadFixtures duplicate entry

188 Views Asked by At

I'm struggling again with the Liip/LiipFunctionalTestBundle in Symfony v2.7. I have two tests, which do nothing but load fixtures via this bundle. If I load the same fixture class in both classes, the second one tries to commit his fixtures twice! If the fixtures are different, everything is fine.

Does someone have experience with this bundle?

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

There are 1 best solutions below

0
On

I switched to the recommended SQLite DB, which worked well, besides the described error. BUT to enable cache_sqlite_db solved my problem. This seems to be a bug to me, but at least it's working now.