Skip to content

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

Draft
Steveb-p wants to merge 6 commits into
4.6from
kernel-test-bootstrap-v2
Draft

PoC: Showcase ibexa/test-core Bootstrapper in BasicKernelTest#810
Steveb-p wants to merge 6 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.
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant