IBX-12358: Introduced Bootstrapper / Hooks for integration tests - #810
IBX-12358: Introduced Bootstrapper / Hooks for integration tests#810Steveb-p wants to merge 11 commits into
Conversation
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.
34bca01 to
7a5098f
Compare
There was a problem hiding this comment.
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.
|
ViniTou
left a comment
There was a problem hiding this comment.
not a fan of those tripled list of test cases (twice excluded and once included) in phpunit xml files, but guess there is no other way without moving them to separate namespace.
| <php> | ||
| <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/> | ||
| <ini name="error_reporting" value="-1" /> | ||
| <env name="DATABASE_URL" value="sqlite://i@i/var/test-bootstrapper.db" /> |
There was a problem hiding this comment.
Shouldn't we force here to avoid prioritising existing DATABASE_URL which could cause some nasty overrides (local development)?



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.Related PRs:
Description:
Switches
BasicKernelTestover to the newibexa/test-coreBootstrapper instead of the per-testself::loadSchema()/self::loadFixtures()calls it used before. Schema and fixtures now get imported once, intests/integration/bootstrap.php, via(new Bootstrapper())()->shutdown()— the test itself just boots the kernel and asserts.Pulled
BasicKernelTest.phpout ofphpunit-integration-legacy.xml'sintegration_coresuite (via<exclude>) into a newphpunit-integration.xml, since it now needs a different bootstrap/KERNEL_CLASS than the rest of that legacy suite. Everything else intests/integration/Coreis untouched.