diff --git a/dependencies.json b/dependencies.json new file mode 100644 index 0000000000..838a86c0ec --- /dev/null +++ b/dependencies.json @@ -0,0 +1,11 @@ +{ + "recipesEndpoint": "", + "packages": [ + { + "requirement": "dev-feature/schema-applier-4.6 as 4.6.x-dev", + "repositoryUrl": "https://github.com/ibexa/doctrine-schema.git", + "package": "ibexa/doctrine-schema", + "shouldBeAddedAsVCS": false + } + ] +} diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9b8ac82db4..6fbeac101b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -8910,12 +8910,6 @@ parameters: count: 1 path: src/contracts/Test/IbexaKernelTestCase.php - - - message: '#^Cannot call method importSchema\(\) on object\|null\.$#' - identifier: method.nonObject - count: 1 - path: src/contracts/Test/IbexaKernelTestCase.php - - message: '#^Method Ibexa\\Contracts\\Core\\Test\\Persistence\\Fixture\:\:load\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue diff --git a/src/contracts/Test/IbexaKernelTestTrait.php b/src/contracts/Test/IbexaKernelTestTrait.php index c40329634d..4c8a04a55d 100644 --- a/src/contracts/Test/IbexaKernelTestTrait.php +++ b/src/contracts/Test/IbexaKernelTestTrait.php @@ -23,8 +23,9 @@ use Ibexa\Contracts\Core\Repository\URLAliasService; use Ibexa\Contracts\Core\Repository\UserService; use Ibexa\Contracts\Core\Test\Persistence\Fixture\FixtureImporter; +use Ibexa\Contracts\DoctrineSchema\Builder\SchemaBuilderInterface; use Ibexa\Core\Repository\Values\User\UserReference; -use Ibexa\Tests\Core\Repository\LegacySchemaImporter; +use Ibexa\DoctrineSchema\Builder\SchemaApplier; use RuntimeException; /** @@ -34,14 +35,23 @@ trait IbexaKernelTestTrait { final protected static function loadSchema(): void { - $schemaImporter = self::getContainer()->get(LegacySchemaImporter::class); - foreach (static::getSchemaFiles() as $schemaFile) { - $schemaImporter->importSchema($schemaFile); - } + $schemaBuilder = self::getContainer()->get(SchemaBuilderInterface::class); + assert($schemaBuilder instanceof SchemaBuilderInterface); + $schema = $schemaBuilder->buildSchema(); + + // Constructed rather than fetched: SchemaApplier is a stateless helper, and its service is + // private and unreferenced in a plain test kernel, so the compiler removes it. + // drop first: this runs per test case, so the tables are normally already present + (new SchemaApplier(self::getDoctrineConnection()))->applySchema($schema, true); } /** * @return iterable + * + * @deprecated since Ibexa 4.6.x, no longer used. {@see loadSchema()} now builds the schema from + * {@see \Ibexa\Contracts\DoctrineSchema\Event\SchemaBuilderEvent} instead of reading + * raw schema files, so a bundle contributes its tables through its own + * BuildSchemaSubscriber and nothing needs to list files. Will be removed in 6.0. */ protected static function getSchemaFiles(): iterable { diff --git a/src/contracts/Test/IbexaTestKernel.php b/src/contracts/Test/IbexaTestKernel.php index 5c89768f84..b02b40f594 100644 --- a/src/contracts/Test/IbexaTestKernel.php +++ b/src/contracts/Test/IbexaTestKernel.php @@ -12,7 +12,9 @@ use Doctrine\DBAL\Connection; use FOS\JsRoutingBundle\FOSJsRoutingBundle; use Ibexa\Bundle\Core\IbexaCoreBundle; +use Ibexa\Bundle\DoctrineSchema\DoctrineSchemaBundle; use Ibexa\Bundle\LegacySearchEngine\IbexaLegacySearchEngineBundle; +use Ibexa\Bundle\RepositoryInstaller\IbexaRepositoryInstallerBundle; use Ibexa\Contracts\Core\Persistence\Handler; use Ibexa\Contracts\Core\Persistence\TransactionHandler; use Ibexa\Contracts\Core\Repository; @@ -139,6 +141,8 @@ public function registerBundles(): iterable { yield new SecurityBundle(); yield new IbexaCoreBundle(); + yield new DoctrineSchemaBundle(); + yield new IbexaRepositoryInstallerBundle(); yield new IbexaLegacySearchEngineBundle(); yield new JMSTranslationBundle(); yield new FOSJsRoutingBundle(); diff --git a/src/contracts/Test/IbexaTestKernelInterface.php b/src/contracts/Test/IbexaTestKernelInterface.php index 55f6e42186..460f27fa4d 100644 --- a/src/contracts/Test/IbexaTestKernelInterface.php +++ b/src/contracts/Test/IbexaTestKernelInterface.php @@ -21,6 +21,12 @@ public static function getAliasServiceId(string $id): string; /** * @return iterable + * + * @deprecated since Ibexa 4.6.x. Test schema is built from + * {@see \Ibexa\Contracts\DoctrineSchema\Event\SchemaBuilderEvent} — the same path + * `ibexa:install` uses — so a kernel no longer declares which schema files to load; + * whichever bundles it registers is what the schema contains. Implementations may + * return an empty iterable. Will be removed in 6.0. */ public function getSchemaFiles(): iterable; diff --git a/tests/integration/RepositoryInstaller/TestKernel.php b/tests/integration/RepositoryInstaller/TestKernel.php index 6cee2d1315..b70e79cf72 100644 --- a/tests/integration/RepositoryInstaller/TestKernel.php +++ b/tests/integration/RepositoryInstaller/TestKernel.php @@ -8,21 +8,11 @@ namespace Ibexa\Tests\Integration\RepositoryInstaller; -use Ibexa\Bundle\DoctrineSchema\DoctrineSchemaBundle; -use Ibexa\Bundle\RepositoryInstaller\IbexaRepositoryInstallerBundle; use Ibexa\Bundle\RepositoryInstaller\Installer\CoreInstaller; use Ibexa\Contracts\Core\Test\IbexaTestKernel; final class TestKernel extends IbexaTestKernel { - public function registerBundles(): iterable - { - yield from parent::registerBundles(); - - yield new DoctrineSchemaBundle(); - yield new IbexaRepositoryInstallerBundle(); - } - protected static function getExposedServicesByClass(): iterable { yield from parent::getExposedServicesByClass();