From 15a9304bc5c3044ae33a3aa1577a87b211024c67 Mon Sep 17 00:00:00 2001 From: thiemowmde Date: Sat, 22 Jun 2024 00:16:26 +0200 Subject: [PATCH] Reduce unused mocks in CommentFormatterTest For example, in case nothing is ever called it's sometimes helpful to use "NoOp" mocks to make this more visible. There is also no actual OutputPage needed, just the much more narrow interface. Change-Id: I44522276726786abd75c85c02a7003c33a5602bb --- tests/phpunit/CommentFormatterTest.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/CommentFormatterTest.php b/tests/phpunit/CommentFormatterTest.php index 3bfdf36a5..9d1f8e914 100644 --- a/tests/phpunit/CommentFormatterTest.php +++ b/tests/phpunit/CommentFormatterTest.php @@ -4,7 +4,7 @@ namespace MediaWiki\Extension\DiscussionTools\Tests; use FormatJson; use MediaWiki\Cache\GenderCache; -use MediaWiki\Config\Config; +use MediaWiki\Context\IContextSource; use MediaWiki\MainConfigNames; use MediaWiki\MediaWikiServices; use MediaWiki\Output\OutputPage; @@ -55,7 +55,7 @@ class CommentFormatterTest extends IntegrationTestCase { string $name, string $titleText, string $dom, string $expected, string $config, string $data, bool $isMobile, bool $useButtons ): void { - $this->setService( 'GenderCache', $this->createMock( GenderCache::class ) ); + $this->setService( 'GenderCache', $this->createNoOpMock( GenderCache::class ) ); $dom = static::getHtml( $dom ); $expectedPath = $expected; $expected = static::getText( $expectedPath ); @@ -77,8 +77,7 @@ class CommentFormatterTest extends IntegrationTestCase { $qqxLang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'qqx' ); $skin = $this->createMock( Skin::class ); $skin->method( 'getSkinName' )->willReturn( 'minerva' ); - $outputPage = $this->createMock( OutputPage::class ); - $outputPage->method( 'getConfig' )->willReturn( $this->createMock( Config::class ) ); + $outputPage = $this->createMock( IContextSource::class ); $outputPage->method( 'getTitle' )->willReturn( $title ); $outputPage->method( 'getUser' )->willReturn( $user ); $outputPage->method( 'getLanguage' )->willReturn( $qqxLang );