Merge "Use streamlined upstream createMock in PHPUnit tests"

This commit is contained in:
jenkins-bot 2024-02-10 14:48:59 +00:00 committed by Gerrit Code Review
commit 87e257dd27
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 );