Return a ParserOutput from the mocked getOutput#103
Merged
Conversation
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>
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.
Why
MediaWiki master declares
Parser::getOutput(): ParserOutput.ParserOutputHelperTest::testCanAddErrorTrackingCategoryandtestCanAddTrackingCategorystub it with->willReturn( false ), which PHPUnit's typed mock rejects:The
falseonly existed to drive an internal "no ParserOutput" guard inParserOutputHelperthat the code comments mark as test-only; the realgetOutput()always returns aParserOutput.What
Return a
ParserOutputfrom the two mocks, matching the method's contract (andsetUp()'s existingnew ParserOutput( 'ParserOutputMockText' )). The tests' load-bearing idempotency assertions are unchanged; the error-category test now actually reachesaddCategory()rather than being short-circuited by the test-only guard.Verification
Test-only change. On MediaWiki master the two
getOutputerrors clear andParserOutputHelperTestpasses; the pre-1.46 rows are unaffected.