From 916561457b692346151528e03393cf47bf799e44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Thu, 30 Jul 2026 23:22:40 +0200 Subject: [PATCH] Skip base test_data.yaml fixture when Doctrine Migrations already imported it Ibexa\Bundle\RepositoryInstaller\Migration\ImportDataMigration (run via ibexa:doctrine:migrations:migrate when the SchemaBuilderEvent path is disabled) inserts the same baseline content that IbexaTestKernel's default getFixtures() also unconditionally imports via test_data.yaml, causing a UniqueConstraintViolationException on the second import. Package-specific fixtures added by subclasses (`yield from parent::getFixtures(); yield new Fixture(...)`) are unaffected and still run in both modes, since they're additive rather than overlapping with ImportDataMigration's output. --- src/contracts/IbexaTestKernel.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/contracts/IbexaTestKernel.php b/src/contracts/IbexaTestKernel.php index bc91560..41b8a7d 100644 --- a/src/contracts/IbexaTestKernel.php +++ b/src/contracts/IbexaTestKernel.php @@ -123,10 +123,21 @@ public function getSchemaFiles(): iterable } /** + * When the Doctrine Migrations schema-install path is active (as opposed to the legacy, + * event-driven SchemaBuilderEvent path), core's own ImportDataMigration already inserts this + * same baseline content as part of schema install -- importing it again here would violate + * unique constraints. Package-specific fixtures added by subclasses (via + * `yield from parent::getFixtures(); yield new Fixture(...)`) are unaffected and still run in + * both modes, since they're additive rather than overlapping with ImportDataMigration's output. + * * @return iterable<\Ibexa\Contracts\Core\Test\Persistence\Fixture> */ public function getFixtures(): iterable { + if (getenv('IBEXA_TEST_SCHEMA_BUILDER_EVENT_ENABLED') === '0') { + return; + } + yield from (new DefaultFixtureProvider())->getFixtures(); }