Use streamlined upstream createMock in PHPUnit tests

Change-Id: I3920819a97d05771f54687dab99ea9657371ac53
This commit is contained in:
thiemowmde 2024-02-08 12:07:29 +01:00
parent 2277abbb00
commit 903e1428c1
2 changed files with 5 additions and 15 deletions

View file

@ -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' )

View file

@ -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 );