Merge "Add missing @param and @return to documentation in tests"

This commit is contained in:
jenkins-bot 2021-01-30 15:22:33 +00:00 committed by Gerrit Code Review
commit eb4b304ed8
49 changed files with 146 additions and 16 deletions

View file

@ -576,6 +576,8 @@ class ParserTestRunner {
* isn't used because it doesn't alter the result of
* Interwiki::getAllPrefixes() and so is incompatible with some users,
* including Parsoid.)
* @param array &$setup
* @param array &$teardown
*/
private function appendInterwikiSetup( &$setup, &$teardown ) {
static $testInterwikis = [

View file

@ -158,6 +158,8 @@ class ParserFuzzTest extends Maintenance {
/**
* Estimate the size of the input variable
* @param mixed $var
* @return int
*/
public function guessVarSize( $var ) {
$length = 0;

View file

@ -157,6 +157,9 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
/**
* @stable for calling
* @param string|null $name
* @param array $data
* @param string $dataName
*/
public function __construct( $name = null, array $data = [], $dataName = '' ) {
parent::__construct( $name, $data, $dataName );
@ -1725,6 +1728,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
* Applies the schema overrides returned by getSchemaOverrides(),
* after undoing any previously applied schema overrides.
* Called once per test class, just before addDataOnce().
* @param IMaintainableDatabase $db
*/
private function setUpSchema( IMaintainableDatabase $db ) {
// Undo any active overrides.

View file

@ -11,7 +11,10 @@ class MultiHttpClientTest extends MediaWikiIntegrationTestCase {
/** @var MultiHttpClient|MockObject */
protected $client;
/** @return MultiHttpClient|MockObject */
/**
* @param array $options
* @return MultiHttpClient|MockObject
*/
private function createClient( $options = [] ) {
$client = $this->getMockBuilder( MultiHttpClient::class )
->setConstructorArgs( [ $options ] )

View file

@ -648,6 +648,9 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
/**
* Shorthand for getting the text of a message, in content language.
* @param MessageLocalizer $op
* @param mixed ...$msgParams
* @return string
*/
private static function getMsgText( MessageLocalizer $op, ...$msgParams ) {
return $op->msg( ...$msgParams )->inContentLanguage()->text();
@ -1172,6 +1175,9 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
* We allow different expectations for different tests as an associative array, like
* [ 'set' => [ ... ], 'default' => [ ... ] ] if setCategoryLinks() will give a different
* result.
* @param array $expected
* @param string $key
* @return array
*/
private function extractExpectedCategories( array $expected, $key ) {
if ( !$expected || isset( $expected[0] ) ) {
@ -1472,6 +1478,8 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
/**
* Call either with arguments $methodName, $returnValue; or an array
* [ $methodName => $returnValue, $methodName => $returnValue, ... ]
* @param mixed ...$args
* @return ParserOutput
*/
private function createParserOutputStub( ...$args ) : ParserOutput {
if ( count( $args ) === 0 ) {

View file

@ -130,6 +130,7 @@ class RenderedRevisionTest extends MediaWikiIntegrationTestCase {
* @param Title $title
* @param null|int $id
* @param int $visibility
* @param Content[]|null $content
* @return RevisionRecord
*/
private function getMockRevision(

View file

@ -281,7 +281,7 @@ class RevisionArchiveRecordTest extends MediaWikiIntegrationTestCase {
* @param CommentStoreComment $comment
* @param stdClass $row
* @param RevisionSlots $slots
* @param bool $wikiId,
* @param bool $wikiId
* @param string|null $expectedException
*/
public function testConstructorFailure(

View file

@ -396,6 +396,7 @@ class RevisionQueryInfoTest extends MediaWikiIntegrationTestCase {
*
* @param array $expected
* @param array $actual
* @param string|null $message
*/
private function assertArrayEqualsIgnoringIntKeyOrder(
array $expected,

View file

@ -107,6 +107,8 @@ class RevisionRendererTest extends MediaWikiIntegrationTestCase {
}
/**
* @param int $maxRev
* @param bool $useMaster
* @return RevisionRenderer
*/
private function newRevisionRenderer( $maxRev = 100, $useMaster = false ) {

View file

@ -122,6 +122,7 @@ abstract class RevisionStoreDbTestBase extends MediaWikiIntegrationTestCase {
}
/**
* @param array $server
* @return LoadBalancer|MockObject
*/
private function getLoadBalancerMock( array $server ) {
@ -144,6 +145,7 @@ abstract class RevisionStoreDbTestBase extends MediaWikiIntegrationTestCase {
}
/**
* @param array $params
* @return Database|MockObject
*/
private function getDatabaseMock( array $params ) {

View file

@ -17,6 +17,7 @@ use Wikimedia\Rdbms\ILoadBalancer;
*/
class NameTableStoreFactoryTest extends MediaWikiIntegrationTestCase {
/**
* @param string $localDomain
* @return MockObject|ILoadBalancer
*/
private function getMockLoadBalancer( $localDomain ) {
@ -31,6 +32,7 @@ class NameTableStoreFactoryTest extends MediaWikiIntegrationTestCase {
}
/**
* @param string $expectedWiki
* @return MockObject|ILBFactory
*/
private function getMockLoadBalancerFactory( $expectedWiki ) {

View file

@ -62,6 +62,7 @@ class ApiMainTest extends ApiTestCase {
*
* @param array $requestData Query parameters for the WebRequest
* @param array $headers Headers for the WebRequest
* @return ApiMain
*/
private function getNonInternalApiMain( array $requestData, array $headers = [] ) {
$req = $this->getMockBuilder( WebRequest::class )

View file

@ -266,6 +266,7 @@ class ApiUserrightsTest extends ApiTestCase {
* error in the way we construct the mock.
*
* @param bool $canProcessExpiries
* @return ApiUserrights
*/
private function getMockForProcessingExpiries( $canProcessExpiries ) {
$sysop = $this->getTestSysop()->getUser();

View file

@ -200,6 +200,8 @@ class EnhancedChangesListTest extends MediaWikiLangTestCase {
}
/**
* @param string $timestamp
* @param string $pageTitle
* @return RecentChange
*/
private function getEditChange( $timestamp, $pageTitle = 'Cat' ) {
@ -221,6 +223,9 @@ class EnhancedChangesListTest extends MediaWikiLangTestCase {
}
/**
* @param string $timestamp
* @param int $thisId
* @param int $lastId
* @return RecentChange
*/
private function getCategorizationChange( $timestamp, $thisId, $lastId ) {

View file

@ -7,6 +7,7 @@ class FallbackContentTest extends MediaWikiLangTestCase {
/**
* @param string $data
* @param string $type
*
* @return FallbackContent
*/

View file

@ -189,6 +189,7 @@ class TextboxBuilderTest extends MediaWikiIntegrationTestCase {
}
/**
* @param string[] $methodsToReturnTrue
* @return Title
*/
private function mockProtectedTitle( $methodsToReturnTrue ) {

View file

@ -9,6 +9,7 @@ use MediaWiki\MediaWikiServices;
class LocalRepoTest extends MediaWikiIntegrationTestCase {
/**
* @param array $extraInfo To pass to LocalRepo constructor
* @return LocalRepo
*/
private function newRepo( array $extraInfo = [] ) {
return new LocalRepo( $extraInfo + [

View file

@ -11,6 +11,7 @@ use Wikimedia\TestingAccessWrapper;
class HttpRequestFactoryTest extends MediaWikiIntegrationTestCase {
/**
* @param array|null $options
* @return HttpRequestFactory
*/
private function newFactory( $options = null ) {
@ -29,6 +30,9 @@ class HttpRequestFactoryTest extends MediaWikiIntegrationTestCase {
}
/**
* @param MWHttpRequest $req
* @param string $expectedUrl
* @param array $expectedOptions
* @return HttpRequestFactory
*/
private function newFactoryWithFakeRequest(
@ -61,6 +65,7 @@ class HttpRequestFactoryTest extends MediaWikiIntegrationTestCase {
}
/**
* @param Status|string $result
* @return MWHttpRequest
*/
private function newFakeRequest( $result ) {

View file

@ -158,6 +158,7 @@ class ImportExportTest extends MediaWikiLangTestCase {
}
/**
* @param string $schemaVersion
* @return string[]
*/
private function getSiteVars( $schemaVersion ) {

View file

@ -44,6 +44,7 @@ class ImportFailureTest extends MediaWikiLangTestCase {
/**
* @param string $prefix
* @param string[] $keys
*
* @return string[]
*/

View file

@ -26,6 +26,7 @@ class ExifRotationTest extends MediaWikiMediaTestCase {
/**
* Mark this test as creating thumbnail files.
* @inheritDoc
*/
protected function createsThumbnails() {
return true;

View file

@ -12,6 +12,7 @@ class JpegPixelFormatTest extends MediaWikiMediaTestCase {
/**
* Mark this test as creating thumbnail files.
* @inheritDoc
*/
protected function createsThumbnails() {
return true;

View file

@ -151,12 +151,20 @@ class MagicVariableTest extends MediaWikiIntegrationTestCase {
# ############## HELPERS ############################################
/** assertion helper expecting a magic output which is zero padded */
/**
* assertion helper expecting a magic output which is zero padded
* @param string $magic
* @param string $value
*/
public function assertZeroPadded( $magic, $value ) {
$this->assertMagicPadding( $magic, $value, '%02d' );
}
/** assertion helper expecting a magic output which is unpadded */
/**
* assertion helper expecting a magic output which is unpadded
* @param string $magic
* @param string $value
*/
public function assertUnPadded( $magic, $value ) {
$this->assertMagicPadding( $magic, $value, '%d' );
}

View file

@ -37,6 +37,7 @@ class SignatureValidatorTest extends MediaWikiIntegrationTestCase {
/**
* Get a basic SignatureValidator for testing with.
* @return SignatureValidator
*/
protected function getSignatureValidator() {
$lang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'en' );

View file

@ -306,6 +306,7 @@ TEXT
class ResourceLoaderImageModuleTestable extends ResourceLoaderImageModule {
/**
* Replace with a stub to make test cases easier to write.
* @inheritDoc
*/
protected function getCssDeclarations( $primary, $fallback ) : array {
return [ '...' ];

View file

@ -10,6 +10,8 @@ use PHPUnit\Framework\MockObject\MockObject;
class SkinMustacheTest extends MediaWikiIntegrationTestCase {
/**
* @param string $html
* @param Title $title
* @return MockObject|OutputPage
*/
private function getMockOutputPage( $html, $title ) {

View file

@ -46,6 +46,8 @@ class SkinTemplateTest extends MediaWikiIntegrationTestCase {
}
/**
* @param bool $isSyndicated
* @param string $html
* @return OutputPage
*/
private function getMockOutputPage( $isSyndicated, $html ) {

View file

@ -82,7 +82,13 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase
return $queryConditions;
}
/** helper to test SpecialRecentchanges::buildQuery() */
/**
* helper to test SpecialRecentchanges::buildQuery()
* @param array $expected
* @param array|null $requestOptions
* @param string $message
* @param User|null $user
*/
private function assertConditions(
$expected,
$requestOptions = null,
@ -115,7 +121,10 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase
return $normalized;
}
/** return false if condition begins with 'rc_timestamp ' */
/**
* @param array|string $var
* @return bool false if condition begins with 'rc_timestamp '
*/
private static function filterOutRcTimestampCondition( $var ) {
return ( is_array( $var ) || strpos( $var, 'rc_timestamp ' ) === false );
}

View file

@ -4,7 +4,7 @@ use MediaWiki\MediaWikiServices;
class SpecialPasswordResetTest extends FormSpecialPageTestCase {
/**
* {@inheritdoc}
* @inheritDoc
*/
protected function newSpecialPage() {
return new SpecialPasswordReset(

View file

@ -136,6 +136,7 @@ class SpecialSearchTest extends MediaWikiIntegrationTestCase {
* Helper to create a new User object with given options
* User remains anonymous though
* @param array|null $opt
* @return User
*/
protected function newUserWithSearchNS( $opt = null ) {
$u = User::newFromId( 0 );

View file

@ -640,6 +640,8 @@ class UploadTestHandler extends UploadBase {
* Almost the same as UploadBase::detectScriptInSvg, except it's
* public, works on an xml string instead of filename, and returns
* the result instead of interpreting them.
* @param string $svg
* @return array
*/
public function checkSvgString( $svg ) {
$check = new XmlTypeCheck(
@ -656,6 +658,7 @@ class UploadTestHandler extends UploadBase {
/**
* Same as parent function, but override visibility to 'public'.
* @inheritDoc
*/
public function detectScriptInSvg( $filename, $partial ) {
return parent::detectScriptInSvg( $filename, $partial );

View file

@ -55,6 +55,7 @@ class UserGroupManagerTest extends MediaWikiIntegrationTestCase {
/**
* @param array $configOverrides
* @param UserEditTracker|null $userEditTrackerOverride
* @param callable|null $callback
* @return UserGroupManager
*/
private function getManager(

View file

@ -30,6 +30,8 @@ class WatchedItemStoreUnitTest extends MediaWikiIntegrationTestCase {
}
/**
* @param IDatabase $mockDb
* @param string|null $expectedConnectionType
* @return MockObject|LoadBalancer
*/
private function getMockLoadBalancer(
@ -53,6 +55,8 @@ class WatchedItemStoreUnitTest extends MediaWikiIntegrationTestCase {
}
/**
* @param IDatabase $mockDb
* @param string|null $expectedConnectionType
* @return MockObject|LBFactory
*/
private function getMockLBFactory(
@ -106,6 +110,7 @@ class WatchedItemStoreUnitTest extends MediaWikiIntegrationTestCase {
}
/**
* @param bool $readOnly
* @return MockObject|ReadOnlyMode
*/
private function getMockReadOnlyMode( $readOnly = false ) {
@ -121,6 +126,7 @@ class WatchedItemStoreUnitTest extends MediaWikiIntegrationTestCase {
/**
* Assumes that only getSubjectPage and getTalkPage will ever be called, and everything passed
* to them will have namespace 0.
* @return NamespaceInfo
*/
private function getMockNsInfo() : NamespaceInfo {
$mock = $this->createMock( NamespaceInfo::class );
@ -141,6 +147,7 @@ class WatchedItemStoreUnitTest extends MediaWikiIntegrationTestCase {
* @param array $callbacks Keys are method names, values are callbacks
* @param array $counts Keys are method names, values are expected number of times to be called
* (default is any number is okay)
* @return RevisionLookup
*/
private function getMockRevisionLookup(
array $callbacks = [], array $counts = []
@ -158,6 +165,7 @@ class WatchedItemStoreUnitTest extends MediaWikiIntegrationTestCase {
}
/**
* @param IDatabase $mockDb
* @return MockObject|LinkBatchFactory
*/
private function getMockLinkBatchFactory( $mockDb ) {

View file

@ -20,13 +20,13 @@ class DatabaseBlockStoreTest extends MediaWikiIntegrationTestCase {
/** @var User */
private $sysop;
/** @var integer */
/** @var int */
private $expiredBlockId = 11111;
/** @var integer */
/** @var int */
private $unexpiredBlockId = 22222;
/** @var integer */
/** @var int */
private $autoblockId = 33333;
/**

View file

@ -291,7 +291,12 @@ class LanguageSrTest extends LanguageClassesTestCase {
$this->assertConverted( $text, 'sr-ec', $msg );
}
/** Wrapper for converter::convertTo() method */
/**
* Wrapper for converter::convertTo() method
* @param string $text
* @param string $variant
* @return string
*/
protected function convertTo( $text, $variant ) {
return $this->getLang()
->getConverter()

View file

@ -103,7 +103,12 @@ class BanConverterTest extends MediaWikiIntegrationTestCase {
$this->assertConverted( $text, 'ban', $msg );
}
/** Wrapper for converter::convertTo() method */
/**
* Wrapper for converter::convertTo() method
* @param string $text
* @param string $variant
* @return string
*/
protected function convertTo( $text, $variant ) {
return $this->getLanguageConverter()->convertTo( $text, $variant );
}

View file

@ -191,7 +191,12 @@ class SrConverterTest extends MediaWikiIntegrationTestCase {
$this->assertConverted( $text, 'sr-ec', $msg );
}
/** Wrapper for converter::convertTo() method */
/**
* Wrapper for converter::convertTo() method
* @param string $text
* @param string $variant
* @return string
*/
protected function convertTo( $text, $variant ) {
return $this->getLanguageConverter()->convertTo( $text, $variant );
}

View file

@ -112,7 +112,12 @@ class LanguageUzTest extends LanguageClassesTestCase {
$this->assertConverted( $text, 'uz-cyrl', $msg );
}
/** Wrapper for converter::convertTo() method */
/**
* Wrapper for converter::convertTo() method
* @param string $text
* @param string $variant
* @return string
*/
protected function convertTo( $text, $variant ) {
return $this->getLang()->getConverter()->convertTo( $text, $variant );
}

View file

@ -25,7 +25,12 @@ WIKITEXT;
/** @var HookContainer */
private $hookContainer;
/** Shared with GlobalWithDBTest */
/**
* Shared with GlobalWithDBTest
* @param string $name
* @param bool &$bad
* @return bool
*/
public static function badImageHook( $name, &$bad ) {
switch ( $name ) {
case 'Hook_bad.jpg':
@ -71,6 +76,7 @@ WIKITEXT;
/**
* Just returns null for every findFile().
* @return RepoGroup
*/
private function getMockRepoGroupNull() {
$mock = $this->createMock( RepoGroup::class );

View file

@ -28,6 +28,9 @@ class WfUrlencodeTest extends MediaWikiUnitTestCase {
/**
* Internal helper that actually run the test.
* Called by the public methods testEncodingUrlWith...()
* @param string $server
* @param string $input
* @param array|string $expectations
*/
private function verifyEncodingFor( $server, $input, $expectations ) {
$expected = $this->extractExpect( $server, $expectations );
@ -56,6 +59,9 @@ class WfUrlencodeTest extends MediaWikiUnitTestCase {
/**
* Interprets the provider array. Return expected value depending
* the HTTP server name.
* @param string $server
* @param string|array $expectations
* @return string
*/
private function extractExpect( $server, $expectations ) {
if ( is_string( $expectations ) ) {

View file

@ -72,6 +72,7 @@ trait ActionModuleBasedHandlerTestTrait {
}
/**
* @param bool $csrfSafe
* @return ApiMain
*/
private function getApiMain( $csrfSafe = false ) {

View file

@ -23,7 +23,12 @@ use Wikimedia\ObjectFactory;
class RouterTest extends \MediaWikiUnitTestCase {
use MockAuthorityTrait;
/** @return Router */
/**
* @param RequestInterface $request
* @param string|null $authError
* @param string[] $additionalRouteFiles
* @return Router
*/
private function createRouter(
RequestInterface $request,
$authError = null,

View file

@ -90,6 +90,9 @@ class SiteConfigurationTest extends \MediaWikiUnitTestCase {
/**
* This function is used as a callback within the tests below
* @param SiteConfiguration $conf
* @param string $wiki
* @return array
*/
public static function getSiteParamsCallback( $conf, $wiki ) {
$site = null;

View file

@ -49,6 +49,7 @@ class FileBackendGroupTest extends MediaWikiUnitTestCase {
/**
* @param string $domain Expected argument that LockManagerGroupFactory::getLockManagerGroup
* will receive
* @return LockManagerGroupFactory
*/
private function getLockManagerGroupFactory( $domain = 'mywiki' ) : LockManagerGroupFactory {
if ( !$this->lmgFactory ) {
@ -79,6 +80,7 @@ class FileBackendGroupTest extends MediaWikiUnitTestCase {
* * 'lmgFactory'
* * 'mimeAnalyzer'
* * 'tmpFileFactory'
* @return FileBackendGroup
*/
private function newObj( array $options = [] ) : FileBackendGroup {
return new FileBackendGroup(

View file

@ -17,6 +17,7 @@ class LanguageNameUtilsTest extends MediaWikiUnitTestCase {
/**
* @param array $optionsArray
* @return LanguageNameUtils
*/
private function newObj( array $optionsArray = [] ) : LanguageNameUtils {
// TODO Why is hookContainer unset here sometimes?

View file

@ -206,6 +206,7 @@ class XhprofDataTest extends PHPUnit\Framework\TestCase {
* var_export( $x );
* @endcode
*
* @param array $opts
* @return Xhprof
*/
protected function getXhprofDataFixture( array $opts = [] ) {

View file

@ -63,6 +63,7 @@ class DBConnRefTest extends PHPUnit\Framework\TestCase {
}
/**
* @param ILoadBalancer|null $lb
* @return IDatabase
*/
private function getDBConnRef( ILoadBalancer $lb = null ) {

View file

@ -428,6 +428,7 @@ class DatabaseTest extends PHPUnit\Framework\TestCase {
* that assert behaviour when the name is a mismatch, we need to
* catch the error here instead of there).
*
* @param string[] $methods
* @return Database
*/
private function getMockDB( $methods = [] ) {

View file

@ -12,6 +12,7 @@ class LanguageTest extends MediaWikiUnitTestCase {
* @param array $options Valid keys:
* 'code'
* 'grammarTransformCache'
* @return Language
*/
private function getObj( array $options = [] ) {
return new Language(