Fix remaining php sniffs

* Separate the ApiQueryPageImages mock into its own file

Bug: T170583
Change-Id: I3db5de11618f952eb7974c456445eaa1d5e4e6a4
This commit is contained in:
jdlrobson 2017-12-21 12:50:27 +08:00 committed by Piotr Miazga
parent d29c0d6585
commit fcc96696d5
3 changed files with 37 additions and 28 deletions

View file

@ -1,11 +1,10 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<exclude name="Generic.Files.OneObjectStructurePerFile.MultipleFound" />
<exclude name="MediaWiki.Files.ClassMatchesFilename.NotMatch" />
<exclude name="MediaWiki.Files.ClassMatchesFilename.WrongCase" />
</rule>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki" />
<file>.</file>
<rule ref="MediaWiki.Files.ClassMatchesFilename.WrongCase">
<exclude-pattern>maintenance/initImageData.php</exclude-pattern>
</rule>
<arg name="extensions" value="php,php5,inc" />
<arg name="encoding" value="UTF-8" />
<exclude-pattern>vendor</exclude-pattern>

View file

@ -0,0 +1,29 @@
<?php
namespace PageImages\Tests;
use ApiPageSet;
use ApiQueryPageImages;
class ApiQueryPageImagesProxyMock extends ApiQueryPageImages {
/** @inheritDoc */
public function __construct( ApiPageSet $pageSet ) {
$this->pageSet = $pageSet;
}
/** @inheritDoc */
public function getPageSet() {
return $this->pageSet;
}
/** @inheritDoc */
public function getTitles() {
return parent::getTitles();
}
/** @inheritDoc */
public static function getPropNames( $license ) {
return parent::getPropNames( $license );
}
}

View file

@ -2,33 +2,14 @@
namespace PageImages\Tests;
use ApiPageSet;
require_once 'ApiQueryPageImagesProxyMock.php';
use ApiQueryPageImages;
use PageImages;
use Title;
use Wikimedia\Rdbms\FakeResultWrapper;
use Wikimedia\TestingAccessWrapper;
class ApiQueryPageImagesProxy extends ApiQueryPageImages {
public function __construct( ApiPageSet $pageSet ) {
$this->pageSet = $pageSet;
}
public function getPageSet() {
return $this->pageSet;
}
public function getTitles() {
return parent::getTitles();
}
/** inheritdoc */
public static function getPropNames( $license ) {
return parent::getPropNames( $license );
}
}
/**
* @covers ApiQueryPageImages
*
@ -111,7 +92,7 @@ class ApiQueryPageImagesTest extends \PHPUnit\Framework\TestCase {
$pageSet->expects( $this->any() )
->method( 'getMissingTitlesByNamespace' )
->will( $this->returnValue( $missingTitlesByNamespace ) );
$queryPageImages = new ApiQueryPageImagesProxy( $pageSet );
$queryPageImages = new ApiQueryPageImagesProxyMock( $pageSet );
$this->assertEquals( $expected, $queryPageImages->getTitles() );
}
@ -306,7 +287,7 @@ class ApiQueryPageImagesTest extends \PHPUnit\Framework\TestCase {
* @param string $expected
*/
public function testGetPropName( $license, $expected ) {
$this->assertEquals( $expected, ApiQueryPageImagesProxy::getPropNames( $license ) );
$this->assertEquals( $expected, ApiQueryPageImagesProxyMock::getPropNames( $license ) );
}
public function provideGetPropName() {