Backport MW 1.46 PHPUnit runner support to 5.x#106
Conversation
MediaWiki 1.46 removed tests/phpunit/phpunit.php in favour of generating a config with `composer phpunit:config` and running vendor/bin/phpunit. Pick the runner by detecting whether the old entry point still exists, so every current and future MediaWiki version is covered without per-version bookkeeping. Force the integration-test bootstrap with MEDIAWIKI_HAS_INTEGRATION_TESTS so the path-based bootstrap selection (unit-only vs integration) doesn't drop MediaWiki settings on Unit-suite tests that construct objects using MediaWiki services. Add an experimental REL1_46 row; it exercises the new runner. Backported from master commits 6d36544 and 345595a. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Scribunto 1.46 requires each LuaEngineTestBase subclass to declare its engine via getEngineName(); the previous "one class exercises every engine" data-provider pattern is deprecated. Without it the LuaLibrary tests error on 1.46+ with "must implement getEngineName()". Target LuaStandalone, whose interpreter Scribunto bundles, so the tests run in CI without installing a Lua extension. Pre-1.46 MediaWiki does not call getEngineName() (it runs every configured engine through its own suite() machinery), so the method is inert there: the REL1_43 to REL1_45 rows are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
MediaWiki master declares Parser::recursiveTagParse() and recursiveTagParseFully() with a `string` return type. The component test mocks stub them with returnArgument(0), echoing the input verbatim. When a component passes a non-string attribute value (a bool or int) to the parser, the mock returns that non-string and PHPUnit's typed mock throws "Return value must be of type string". Cast the echoed value to string so the mocks honour the method's contract. Behaviour is unchanged for string inputs, and the renderErrorMessage mock is left as-is. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The three service-wiring construction tests lacked @Covers annotations, so MediaWiki's generated PHPUnit config (which sets forceCoversAnnotation) flagged them as risky. Annotate each test method with the class it exercises through the extension's service wiring: BootstrapComponentsService, ComponentLibrary, and NestingController. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
MediaWiki master declares Parser::getOutput(): ParserOutput, so the two ParserOutputHelper tests that stub it with willReturn( false ) trip PHPUnit's typed mock (IncompatibleReturnValueException). The false only ever drove a guard in ParserOutputHelper that the code comments mark as test-only; the real getOutput() always returns a ParserOutput. Return one from the mock, matching the contract and setUp's existing ParserOutput. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PHP 8.5 deprecates ReflectionMethod::setAccessible(); it has been a no-op since 8.1, so the reflective invokeArgs() in BootstrapComponentsServiceTest works without it. Drop the call to clear the deprecation on the master/PHP 8.5 row; it is a no-op on the older rows. Rename three test files whose names did not match the class they declare, which PHPUnit flags as "test case class not matching filename" (the class names are already correct and are left unchanged): - BootstrapComponentServiceTest.php -> BootstrapComponentsServiceTest.php - BootstrapComponentsJsonTestCaseScriptRunnerTest.php -> BootstrapComponentsJSONScriptTestCaseRunnerTest.php - readmeContentsBuilder.php -> ReadmeContentsBuilder.php Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
GitHub is removing the Node 20 runtime; actions/checkout@v4 and actions/cache@v4 run on it and emit a deprecation warning in the logs. Bump both to v5, which run on Node 24. shivammathur/setup-php stays on its current rolling major (v2), which already runs on Node 24 and was not flagged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Scribunto namespaced its Lua test base as MediaWiki\Extension\Scribunto\Tests\Engines\LuaCommon\LuaEngineTestBase and dropped the legacy Scribunto_LuaEngineTestBase alias on MediaWiki master. The namespaced class is present on every supported MediaWiki (1.43+), so use it directly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The MediaWiki REL1_39-REL1_42 rows have been bitrotting on the 5.x branch (the tarball install or composer step fails for reasons unrelated to this PR). With fail-fast on, those failures cancel the REL1_46 job mid-run before the new PHPUnit runner gets exercised. Disable fail-fast so each MW row reports its own result independently. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…unit calls Matches the master pattern; the step-level env block I had in the initial backport didn't take effect (the new-runner job hit "Class Title not found" on all 99 service-using unit tests). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Closing — investigation revealed the 9 CI/test commits I cherry-picked are necessary but not sufficient. 5.x's BC source code (e.g. use Html;
use Message;
use Parser;
use ParserOutput;
use Title;MediaWiki 1.46 removed those bare-name global aliases. PHPUnit on 1.46 produces 99 errors like The fix is master's commit Options:
Either way, the eight cherry-picks here aren't useful in isolation. |
Backport of the eight CI/test commits from master (66a..master, see commit list) that make BootstrapComponents test-runnable on MediaWiki 1.46 (which removed
tests/phpunit/phpunit.phpin favour ofcomposer phpunit:config+vendor/bin/phpunit).Scope
Eight cherry-picks (one —
6d36544— applied manually because 5.x's CI matrix is structurally different):The runner-detection logic + integration-bootstrap (from master
6d36544and345595a) is squashed into the first commit since 5.x's matrix shape doesn't accept the master cherry-pick cleanly.Verification
Local PHP-syntax check across all changed test files: clean. ci.yml parses as valid YAML.
Full test verification is deferred to CI (this host's container network can't bootstrap MW 1.46 locally).
Confirms 5.x is test-runnable on MediaWiki 1.46 with these eight backport commits.