IBX-12530: Built IbexaKernelTestTrait schema from SchemaBuilderEvent - #823
IBX-12530: Built IbexaKernelTestTrait schema from SchemaBuilderEvent#823Steveb-p wants to merge 3 commits into
Conversation
loadSchema() pushed raw schema.yaml files listed by getSchemaFiles() through LegacySchemaImporter, which never dispatches SchemaBuilderEvent. That left two different schema-building paths in the test stack once ibexa/test-core#43 moved DatabaseSchemaHook onto the event, and it is the only reason a package still has to keep a getSchemaFiles() override alive. It now builds through SchemaBuilderInterface and applies the result with doctrine-schema's new SchemaApplier, keeping the drop-then-create ordering LegacySchemaImporter had, since loadSchema() runs per test case. IbexaTestKernel gains DoctrineSchemaBundle and IbexaRepositoryInstallerBundle, without which the event is not reachable — core's own kernel does not extend ibexa/test-core's, so it does not inherit them. getSchemaFiles() is deprecated on both IbexaTestKernelInterface and the trait. LegacySchemaImporter stays: SetupFactory\Legacy and Persistence\Legacy\TestCase still use it.
…ema#49 Points CI at the branch that adds SchemaApplier, so this PR's tests can run before that PR merges. Must be removed before merging.
…r TestKernel It registered DoctrineSchemaBundle and IbexaRepositoryInstallerBundle itself and extends IbexaTestKernel, which now yields both, so booting it threw "Trying to register two bundles with the same name". Its registerBundles() override did nothing else, so it goes entirely.
|
|
Blast-radius note for reviewers — org-wide audit of who actually calls All 483 non-archived
Why the four downstream ones are safe:
|
…maApplier DatabaseSchemaHook reimplemented the toSql()-and-execute loop that ibexa/core's LegacySchemaImporter also has; both now use doctrine-schema's SchemaApplier. The hook needs no dropping, since Bootstrapper always hands it a freshly created database. DefaultSchemaFilesProvider and IbexaTestKernel::getSchemaFiles() are deprecated. Nothing in this package reads them any more: the schema comes from SchemaBuilderEvent, so whichever bundles a kernel registers is what the schema contains. They stay because IbexaTestKernelInterface still mandates getSchemaFiles(), and ibexa/core's IbexaKernelTestTrait kept reading it until ibexa/core#823.
| $schemaImporter = self::getContainer()->get(LegacySchemaImporter::class); | ||
| foreach (static::getSchemaFiles() as $schemaFile) { | ||
| $schemaImporter->importSchema($schemaFile); | ||
| } | ||
| $schemaBuilder = self::getContainer()->get(SchemaBuilderInterface::class); |
There was a problem hiding this comment.
Don't we have already some helper method to get service correctly typed/recognized by phpstan (based on passed class-string value)? If so, we coud use it and remove asert here.



Warning
This branch includes a temporary commit (
dependencies.json) that points CI atibexa/doctrine-schema#49 so tests can run before that PR merges. Must be removed before
merging this PR.
Related PRs:
SchemaApplierused hereDatabaseSchemaHookonto the event; this is the same move for the traitDescription:
IbexaKernelTestTrait::loadSchema()pushed rawschema.yamlfiles — listed bygetSchemaFiles()— throughLegacySchemaImporter, which never dispatchesSchemaBuilderEvent.Since ibexa/test-core#43 moved
DatabaseSchemaHookonto the event, that left two differentschema-building paths in the test stack, and it is the only remaining reason a package has to
keep a
getSchemaFiles()override alive.loadSchema()now builds throughSchemaBuilderInterfaceand applies the result withdoctrine-schema's new
SchemaApplier, keeping the drop-then-create orderingLegacySchemaImporterhad — it runs per test case, so the tables are normally already there.
Three things worth flagging for review:
IbexaTestKernelgainsDoctrineSchemaBundle+IbexaRepositoryInstallerBundle. Withoutthem the event isn't reachable. Note this is core's own
Ibexa\Contracts\Core\Test\IbexaTestKernel,which does not extend ibexa/test-core's same-named-but-different-namespace kernel, so it does
not inherit them from Merge IBX-1182: Added cache invalidation to liip:imagine:cache:remove command #43. It is the kernel
phpunit-integration-legacy.xmlboots, and thereforethe one
TokenServiceTest— the onlyloadSchema()caller in this repo — actually runs on.SchemaApplieris constructed, not fetched from the container. Its service is private andunreferenced in a plain test kernel, so the compiler removes it and
TestContainercannotresolve it. It is a stateless helper over a
Connection, so constructing it is simpler thanmaking a production service public for tests' sake.
LegacySchemaImporterstays.SetupFactory\LegacyandPersistence\Legacy\TestCasestilluse it directly; only the trait stops.
getSchemaFiles()is deprecated on bothIbexaTestKernelInterfaceand the trait. It is notremoved — ibexa/test-core's
DefaultSchemaFilesProviderand every downstream override stillimplement it, and the interface is
@internal/@experimentalbut widely implemented. Removal isa 6.0 job.
One
phpstan-baseline.neonentry is dropped: it ignoredCannot call method importSchema() on object|null, and that call no longer exists. The replacement call is narrowed with anassert()rather than baselined, matching how
getServiceByClassName()already does it.For QA:
All against this branch with doctrine-schema#49 symlinked in:
phpunit-integration-legacy.xmlintegration_core(includesTokenServiceTest)TokenServiceTestalone — the onlyloadSchema()callerphpunit-integration.xmlphpunit.xml(unit)