As the title says, I'd like to know how to load the data fixtures in the method setUpBeforeClass
. The test class extends Liip\FunctionalTestBundle\Test\WebTestCase
.
At the moment I have this:
public function setUp()
{
$this->client = $this->createClient();
$this->fixtures = $this->loadFixtures([
'App\DataFixtures\MyFixtures',
// more fixtures
])->getReferenceRepository();
}
However the tests seem to take too long and there is really no need for the fixtures to be loaded before each test.
When I tried to load the fixtures in setUpBeforeClass
I've got an error:
Error: Using $this when not in object context in /home/cezar/phpprojects/livegene/vendor/liip/functional-test-bundle/src/Test/WebTestCase.php:252
A look into the source code of LiipFunctionalTestBundle revealed this snippet:
protected function loadFixtures(array $classNames = [], bool $append = false, ?string $omName = null, string $registryName = 'doctrine', ?int $purgeMode = null): ?AbstractExecutor
{
$container = $this->getContainer();
$dbToolCollection = $container->get('liip_functional_test.services.database_tool_collection');
$dbTool = $dbToolCollection->get($omName, $registryName, $purgeMode, $this);
$dbTool->setExcludedDoctrineTables($this->excludedDoctrineTables);
return $dbTool->loadFixtures($classNames, $append);
}
Is it possible to do this, what I wish, and if yes, how could it be achieved?