我正在尝试使用 Liip 测试包使用 FixturesTrait 中的 loadFixtures() 方法从代码中加载夹具但是,我需要排除我不想在此过程中删除的 RESOURCE 表。如果我理解正确,这应该很容易根据文档https://github.com/liip/LiipTestFixturesBundle/blob/master/doc/database.md使用 setExcludedDoctrineTables 方法
不幸的是,当我运行此代码时,表 RESOURCES 与所有其他表一起被删除。
任何人都可以看到为什么?
不确定这是否相关,但我在单独的 docker 容器中使用 mysql db。
<?php namespace App\Tests\Controller; use Symfony\Component\Panther\PantherTestCase; use Symfony\Component\Panther\Client; use Facebook\WebDriver\WebDriverBy as By; use Facebook\WebDriver\Exception\TimeoutException; use Liip\FunctionalTestBundle\Test\WebTestCase; use Symfony\Component\Panther\PantherTestCaseTrait; use Liip\TestFixturesBundle\Test\FixturesTrait; use App\Repository\UserRepository; use App\DataFixtures\UserFixtures; use App\DataFixtures\AccountFixtures; abstract class AbstractPantherTest extends WebTestCase{ // use trait so we can combine Liip and Panther features use PantherTestCaseTrait; // this is the magic. Panther is now available. // provide fixtures loading feature use FixturesTrait; // @var Symfony\Component\Panther\Client protected static $client; //Initialize the test case function setUp():void { static::bootKernel(); if(self::$client === null){ self::$client = self::createPantherClient(['browser' => PantherTestCase::FIREFOX]); $this->setExcludedDoctrineTables(["RESOURCES"]); $this->loadFixtures([ UserFixtures::class, ]); // retrieve the test user $userRepository = static::$container->get(UserRepository::class); // retrieve the test user $testUser = $userRepository->findOneByUsername('Administrator'); // simulate $testUser being logged in self::doLogin($testUser->getUsername(), 'xxx'); } }
}