Force the integration-test bootstrap for MediaWiki 1.46+#97
Merged
Conversation
8230e8b to
26a3315
Compare
MediaWiki 1.46 replaced tests/phpunit/phpunit.php with vendor/bin/phpunit, whose bootstrap decides between unit and integration mode from the test path: a path under "/unit" is treated as unit-only, and in that mode MediaWiki settings and the service container are not loaded. The tests under tests/phpunit/Unit are not strictly unit tests, they construct objects that use MediaWiki services, so under the new runner they all error with "Premature access to service container". Force the integration-test bootstrap with MEDIAWIKI_HAS_INTEGRATION_TESTS so those tests run. This is a temporary workaround; the proper fix is to reclassify the service-using tests as integration tests (MediaWikiIntegrationTestCase, outside the unit path), after which MediaWiki selects the right bootstrap on its own. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
26a3315 to
94dbdb2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
MediaWiki 1.46 replaced
tests/phpunit/phpunit.phpwithvendor/bin/phpunit, whosebootstrap treats a
/unittest path as unit-only and skips loading MediaWiki settingsand the service container. BootstrapComponents'
tests/phpunit/Unit/tests are notstrictly unit tests (they use MediaWiki services), so under the new runner they error
with
Premature access to service container.Forcing the integration-test bootstrap via
MEDIAWIKI_HAS_INTEGRATION_TESTS=1lets themrun. The pre-1.46 rows are unaffected; the
1.46/masterrows stayexperimental.Temporary
This is a workaround. The proper fix, reclassifying the service-using tests as
integration tests so the override is no longer needed, is tracked in #98.