タイトルの通り、メソッドでデータフィクスチャをロードする方法を知りたいsetUpBeforeClass
です。テストクラスは拡張しLiip\FunctionalTestBundle\Test\WebTestCase
ます。
現時点で私はこれを持っています:
public function setUp()
{
$this->client = $this->createClient();
$this->fixtures = $this->loadFixtures([
'App\DataFixtures\MyFixtures',
// more fixtures
])->getReferenceRepository();
}
ただし、テストには時間がかかりすぎるようで、各テストの前にフィクスチャをロードする必要はありません。
フィクスチャをロードしようとするとsetUpBeforeClass
、エラーが発生しました:
エラー: /home/cezar/phpprojects/livegene/vendor/liip/functional-test-bundle/src/Test/WebTestCase.php:252 のオブジェクト コンテキストではないときに $this を使用する
LiipFunctionalTestBundleのソース コードを調べると、次のスニペットが明らかになりました。
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);
}
これを行うことは可能ですか?私が望むことは可能ですか?可能である場合、どのようにそれを達成できますか?