From 903e1428c1c568fa4a278fd617fbc88f3b9fa6a6 Mon Sep 17 00:00:00 2001 From: thiemowmde Date: Thu, 8 Feb 2024 12:07:29 +0100 Subject: [PATCH] Use streamlined upstream createMock in PHPUnit tests Change-Id: I3920819a97d05771f54687dab99ea9657371ac53 --- tests/phpunit/ApiQueryPageImagesTest.php | 12 +++--------- .../Hooks/ParserFileProcessingHookHandlersTest.php | 8 ++------ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/tests/phpunit/ApiQueryPageImagesTest.php b/tests/phpunit/ApiQueryPageImagesTest.php index 31697e0..7a685f6 100644 --- a/tests/phpunit/ApiQueryPageImagesTest.php +++ b/tests/phpunit/ApiQueryPageImagesTest.php @@ -34,16 +34,12 @@ class ApiQueryPageImagesTest extends TestCase { $context->method( 'getConfig' ) ->willReturn( $config ); - $main = $this->getMockBuilder( \ApiMain::class ) - ->disableOriginalConstructor() - ->getMock(); + $main = $this->createMock( \ApiMain::class ); $main->expects( $this->once() ) ->method( 'getContext' ) ->willReturn( $context ); - $query = $this->getMockBuilder( \ApiQuery::class ) - ->disableOriginalConstructor() - ->getMock(); + $query = $this->createMock( \ApiQuery::class ); $query->expects( $this->once() ) ->method( 'getMain' ) ->willReturn( $main ); @@ -84,9 +80,7 @@ class ApiQueryPageImagesTest extends TestCase { * @dataProvider provideGetTitles */ public function testGetTitles( $titles, $missingTitlesByNamespace, $expected ) { - $pageSet = $this->getMockBuilder( \ApiPageSet::class ) - ->disableOriginalConstructor() - ->getMock(); + $pageSet = $this->createMock( \ApiPageSet::class ); $pageSet->method( 'getGoodTitles' ) ->willReturn( $titles ); $pageSet->method( 'getMissingTitlesByNamespace' ) diff --git a/tests/phpunit/Hooks/ParserFileProcessingHookHandlersTest.php b/tests/phpunit/Hooks/ParserFileProcessingHookHandlersTest.php index a3c344d..cd81b99 100644 --- a/tests/phpunit/Hooks/ParserFileProcessingHookHandlersTest.php +++ b/tests/phpunit/Hooks/ParserFileProcessingHookHandlersTest.php @@ -68,16 +68,12 @@ class ParserFileProcessingHookHandlersTest extends MediaWikiIntegrationTestCase * @return RepoGroup */ private function getRepoGroup() { - $file = $this->getMockBuilder( File::class ) - ->disableOriginalConstructor() - ->getMock(); + $file = $this->createMock( File::class ); // ugly hack to avoid all the unmockable crap in FormatMetadata $file->method( 'isDeleted' ) ->willReturn( true ); - $repoGroup = $this->getMockBuilder( RepoGroup::class ) - ->disableOriginalConstructor() - ->getMock(); + $repoGroup = $this->createMock( RepoGroup::class ); $repoGroup->method( 'findFile' ) ->willReturn( $file );