symfonydoctrine-ormliiptestfixturesbundle

excluding tables with setExcludedDoctrineTables when loading fixtures with liip TestFixturesBundle


I'm trying to use Liip test bundle to load fixtures from code using the loadFixtures() method from FixturesTrait However, I need to exclude the RESOURCE table that I don't want to be dropped in the process. If I understand correctly, this should be easy using the setExcludedDoctrineTables method according to the doc https://github.com/liip/LiipTestFixturesBundle/blob/master/doc/database.md

Unfortunately, when I run this code, the table RESOURCES gets dropped with all the others.

Can anybody see why ?


Solution

  • Answering my own question as I just found out the issue. Sometimes a good night of sleep is all you need :)

    So this code is actually working. The table RESOURCES got dropped because the setUp method was redefined in the concrete class implementing the test and that redefinition included another call to loadFixtures, but for a different data class and without the exclusion :

    <?php
    
    namespace App\Tests\Controller;
    
    use App\DataFixtures\DiscountFixtures;
    
    class DiscountControllerWebTest extends AbstractPantherTest
    {
    
        function setUp():void
        {
            parent::setUp();
    
            $this->loadFixtures([
                DiscountFixtures::class,
            ]);
    
        }