Skip to content

RFC: Showcase ibexa/test-core Bootstrapper in BasicKernelTest - #810

Open
Steveb-p wants to merge 11 commits into
4.6from
kernel-test-bootstrap-v2
Open

RFC: Showcase ibexa/test-core Bootstrapper in BasicKernelTest#810
Steveb-p wants to merge 11 commits into
4.6from
kernel-test-bootstrap-v2

Conversation

@Steveb-p

Copy link
Copy Markdown
Contributor

Warning

This branch includes a temporary commit (dependencies.json) that points CI at ibexa/test-core#38 so tests can run before that PR merges. Must be removed before merging this PR.

🎫 Issue N/A

Related PRs:

Description:

Switches BasicKernelTest over to the new ibexa/test-core Bootstrapper instead of the per-test self::loadSchema()/self::loadFixtures() calls it used before. Schema and fixtures now get imported once, in tests/integration/bootstrap.php, via (new Bootstrapper())()->shutdown() — the test itself just boots the kernel and asserts.

Pulled BasicKernelTest.php out of phpunit-integration-legacy.xml's integration_core suite (via <exclude>) into a new phpunit-integration.xml, since it now needs a different bootstrap/KERNEL_CLASS than the rest of that legacy suite. Everything else in tests/integration/Core is untouched.

BasicKernelTest no longer calls self::loadSchema()/self::loadFixtures()
per test; tests/integration/bootstrap.php now does it once via the new
Bootstrapper class from ibexa/test-core. Moved to its own
phpunit-integration.xml since it needs a different KERNEL_CLASS/bootstrap
than the rest of the legacy integration suite.
Points CI at the kernel-test-bootstrap-v2 branch that adds the Bootstrapper
class this PR depends on, so tests can run before that PR merges. Must be
removed before merging.
Both were read-only (no content/user/role mutations), the safe subset
of RepositoryTestCase's 16 leaf classes to move off the per-test
self::loadSchema()/loadFixtures() pattern without needing per-test
transactional isolation first - the other 14 mutate repository data and
have nothing (no DAMADoctrineTestBundle or similar) to roll that back
between tests today.

Added tests/integration/Core/TestKernel.php, overriding getFixtures()
to keep loading the same Legacy/data/test_data.yaml fixture set these
tests were already calibrated against (25 content types, specific
admin user field values, etc.) instead of the shared kernel's own
smaller generic default - otherwise their assertions would fail on a
mismatched fixture set despite the migration itself being safe.
… tests

Mutating tests couldn't use the Bootstrapper before, since it only imports
schema/fixtures once per suite run rather than per test. DAMA wraps each
test in a transaction rolled back afterwards, so RepositoryTestCase no
longer needs to reimport schema/fixtures in setUp().

TestKernel also needed to set the ibexa.kernel.root_dir container
parameter itself: the shared ibexa/test-core kernel has no knowledge of
it, so without an override it fell back to the production default
(vendor/ibexa/core), breaking TransformationProcessor's .tr/.tr.result
fixture paths when running ibexa-core's own suite standalone.
Converts self::getXxxService()/self::setAdministratorUser() calls to
$this->getIbexaTestCore()->getXxxService() now that RepositoryTestCase
no longer boots through the legacy per-test schema/fixture loading.

TrashService and URLAliasService have no dedicated getter on
IbexaTestCoreInterface, so DeleteContentTest and UrlAliasLookupTest fall
back to getServiceByClassName() for those two.
@Steveb-p
Steveb-p force-pushed the kernel-test-bootstrap-v2 branch from 34bca01 to 7a5098f Compare August 24, 2026 10:11
Comment thread tests/integration/Core/Repository/ContentTypeService/FindContentTypesTest.php Outdated
Comment thread tests/integration/Core/Repository/SerializationTest.php Outdated
Comment thread tests/integration/bootstrap.php Outdated
Comment thread phpunit-integration.xml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea on splitting. Wondering if we should stick to legacy naming pattern or we should use the new one: phpunit.integration.xml? Not sure myself, given the old files still exist and might create confusion 🤔

…ce calls

RepositoryTestCase's parent class was swapped from the old
IbexaKernelTestCase (which provided static getXxxService() methods) to
the new one earlier in this branch, breaking this file's inherited
static calls at the PHPStan level even though its own migration was
deliberately deferred. LegacyTestKernel already implements the same
IbexaTestKernelInterface getIbexaTestCore() requires, so no other
change is needed here.
Its parent RepositoryTestCase no longer imports schema/fixtures per
test (that moved to the Bootstrapper mechanism earlier in this
branch), so this test — which was left out of that migration because
it boots its own dedicated LegacyTestKernel — was failing at runtime
under both phpunit-integration-legacy.xml (never excluded there) and
phpunit-integration-legacy-solr.xml (only its own excluded
Repository/Filtering directory covered it, not the 15 already-migrated
sibling files under other directories that were also still reachable
there).

Excluded it from phpunit-integration-legacy.xml, added the same 15
missing exclude entries to phpunit-integration-legacy-solr.xml, moved
the file into phpunit-integration.xml's file list, and registered
DAMADoctrineTestBundle on LegacyTestKernel so it gets the same
per-test transaction isolation as its new siblings there.
…Case

Both extended IbexaKernelTestCase directly with a setUp() that was just
a copy of RepositoryTestCase::setUp() — no deliberate reason for the
inconsistency with the other 13 migrated tests, so extending
RepositoryTestCase removes the duplication.
ibexa/test-core renamed __invoke() to bootstrap() and now shuts the kernel
down itself by default, so the explicit ->shutdown() call here is no longer
needed.
ibexa/test-core reverted its shared kernel to not auto-register this bundle
anymore (it broke downstream kernels that already register it themselves),
so a kernel that goes through Bootstrapper - this one does, via
tests/integration/bootstrap.php - needs to register it itself again.
@sonarqubecloud

Copy link
Copy Markdown

@Steveb-p Steveb-p changed the title PoC: Showcase ibexa/test-core Bootstrapper in BasicKernelTest RFC: Showcase ibexa/test-core Bootstrapper in BasicKernelTest Aug 25, 2026
@Steveb-p
Steveb-p marked this pull request as ready for review August 25, 2026 08:32
@Steveb-p Steveb-p added Feature New feature request Ready for review labels Aug 25, 2026
@Steveb-p
Steveb-p requested a review from a team August 25, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New feature request Ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants