Skip to content

Return a ParserOutput from the mocked getOutput#103

Merged
malberts merged 1 commit into
masterfrom
tests/getoutput-mock-type
Jun 12, 2026
Merged

Return a ParserOutput from the mocked getOutput#103
malberts merged 1 commit into
masterfrom
tests/getoutput-mock-type

Conversation

@malberts

Copy link
Copy Markdown
Collaborator

Why

MediaWiki master declares Parser::getOutput(): ParserOutput. ParserOutputHelperTest::testCanAddErrorTrackingCategory and testCanAddTrackingCategory stub it with ->willReturn( false ), which PHPUnit's typed mock rejects:

IncompatibleReturnValueException: Method getOutput may not return value of type boolean, its declared return type is "MediaWiki\Parser\ParserOutput"

The false only existed to drive an internal "no ParserOutput" guard in ParserOutputHelper that the code comments mark as test-only; the real getOutput() always returns a ParserOutput.

What

Return a ParserOutput from the two mocks, matching the method's contract (and setUp()'s existing new ParserOutput( 'ParserOutputMockText' )). The tests' load-bearing idempotency assertions are unchanged; the error-category test now actually reaches addCategory() rather than being short-circuited by the test-only guard.

Verification

Test-only change. On MediaWiki master the two getOutput errors clear and ParserOutputHelperTest passes; the pre-1.46 rows are unaffected.

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>
@malberts malberts marked this pull request as ready for review June 12, 2026 11:15
@malberts malberts merged commit a28b499 into master Jun 12, 2026
4 of 6 checks passed
@malberts malberts deleted the tests/getoutput-mock-type branch June 12, 2026 11:48
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