Bump codesniffer to 42.0.0
Most noisily, this enables MediaWiki.Arrays.OneSpaceInlineArray. Change-Id: I8ab11399c67ce7e3ab1b6249b591452774393428
This commit is contained in:
parent
b8afc45302
commit
f5abfb8d58
49 changed files with 99 additions and 100 deletions
|
|
@ -11,11 +11,15 @@
|
|||
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingVar" />
|
||||
<exclude name="MediaWiki.Commenting.PropertyDocumentation.SpacingAfter" />
|
||||
<exclude name="MediaWiki.Commenting.PropertyDocumentation.WrongStyle" />
|
||||
<exclude name="MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures" />
|
||||
<exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName" />
|
||||
<exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle" />
|
||||
<exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage" />
|
||||
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
|
||||
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact" />
|
||||
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
|
||||
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition" />
|
||||
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.Found" />
|
||||
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeClassBrace.BraceNotOnOwnLine" />
|
||||
<exclude name="PSR2.Classes.PropertyDeclaration.Multiple" />
|
||||
</rule>
|
||||
<rule ref="MediaWiki.NamingConventions.ValidGlobalName">
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ For notes on 1.40.x and older releases, see HISTORY.
|
|||
* Updated codex, codex-search, codex-design-tokens and codex-icons
|
||||
from v0.6.2 to v0.19.0.
|
||||
* Updated jQuery from v3.6.1 to v3.7.0.
|
||||
* Updated mediawiki/mediawiki-codesniffer from 41.0.0 to 42.0.0.
|
||||
* Updated Mustache from 3.0.1 to 4.2.0.
|
||||
* Updated OOjs from 6.0.0 to 7.0.1.
|
||||
* Updated OOUI from v0.46.3 to v0.48.1.
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@
|
|||
"giorgiosironi/eris": "^0.13.0",
|
||||
"hamcrest/hamcrest-php": "^2.0",
|
||||
"johnkary/phpunit-speedtrap": "^4.0",
|
||||
"mediawiki/mediawiki-codesniffer": "41.0.0",
|
||||
"mediawiki/mediawiki-codesniffer": "42.0.0",
|
||||
"mediawiki/mediawiki-phan-config": "0.13.0",
|
||||
"nikic/php-parser": "^4.10.2",
|
||||
"php-parallel-lint/php-console-highlighter": "1.0.0",
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ use Wikimedia\RemexHtml\Serializer\SerializerNode;
|
|||
use Wikimedia\RemexHtml\Tokenizer\Attributes;
|
||||
use Wikimedia\RemexHtml\Tokenizer\Tokenizer;
|
||||
use Wikimedia\RemexHtml\TreeBuilder\Dispatcher;
|
||||
use Wikimedia\RemexHtml\TreeBuilder\Element;
|
||||
use Wikimedia\RemexHtml\TreeBuilder\TreeBuilder;
|
||||
use Wikimedia\Zest\Zest;
|
||||
|
||||
|
|
|
|||
|
|
@ -941,7 +941,7 @@ class ChangesList extends ContextSource {
|
|||
$this->getUser()->getName(),
|
||||
$this->getLanguage()->getCode()
|
||||
),
|
||||
fn() => ChangeTags::formatSummaryRow(
|
||||
fn () => ChangeTags::formatSummaryRow(
|
||||
$rc->mAttribs['ts_tags'],
|
||||
'changeslist',
|
||||
$this->getContext()
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ class RCCacheEntryFactory {
|
|||
$this->context->getUser()->getName(),
|
||||
$this->context->getLanguage()->getCode()
|
||||
),
|
||||
static fn() => Linker::userToolLinks(
|
||||
static fn () => Linker::userToolLinks(
|
||||
$cacheEntry->mAttribs['rc_user'],
|
||||
$cacheEntry->mAttribs['rc_user_text'],
|
||||
// Should the contributions link be red if the user has no edits (using default)
|
||||
|
|
@ -330,7 +330,7 @@ class RCCacheEntryFactory {
|
|||
$this->context->getUser()->getName(),
|
||||
$this->context->getLanguage()->getCode()
|
||||
),
|
||||
static fn() => Linker::userLink(
|
||||
static fn () => Linker::userLink(
|
||||
$cacheEntry->mAttribs['rc_user'],
|
||||
$cacheEntry->mAttribs['rc_user_text'],
|
||||
ExternalUserNames::getLocal( $cacheEntry->mAttribs['rc_user_text'] )
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ class RecentChangesUpdateJob extends Job {
|
|||
->replaceInto( 'querycache_info' )
|
||||
->rows( [
|
||||
'qci_type' => 'activeusers',
|
||||
'qci_timestamp' => $dbw->timestamp( $asOfTimestamp ) , // not always $now
|
||||
'qci_timestamp' => $dbw->timestamp( $asOfTimestamp ), // not always $now
|
||||
] )
|
||||
->uniqueIndexFields( [ 'qci_type' ] )
|
||||
->caller( __METHOD__ )->execute();
|
||||
|
|
|
|||
|
|
@ -89,14 +89,14 @@ class ParsoidVirtualRESTService extends VirtualRESTService {
|
|||
foreach ( $reqs as $key => $req ) {
|
||||
$parts = explode( '/', $req['url'] );
|
||||
|
||||
list(
|
||||
[
|
||||
$targetWiki, // 'local'
|
||||
$version, // 'v3' ('v1' for restbase compatibility)
|
||||
$reqType, // 'page' or 'transform'
|
||||
$format, // 'html' or 'wikitext'
|
||||
// $title (optional)
|
||||
// $revision (optional)
|
||||
) = $parts;
|
||||
] = $parts;
|
||||
|
||||
if ( isset( $this->params['restbaseCompat'] ) && $this->params['restbaseCompat'] ) {
|
||||
if ( $version !== 'v1' ) {
|
||||
|
|
|
|||
|
|
@ -811,7 +811,7 @@ class ContribsPager extends RangeChronologicalPager {
|
|||
$this->getUser()->getName(),
|
||||
$lang->getCode()
|
||||
),
|
||||
fn() => ChangeTags::formatSummaryRow(
|
||||
fn () => ChangeTags::formatSummaryRow(
|
||||
$row->ts_tags,
|
||||
null,
|
||||
$this->getContext()
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ abstract class DumpIterator extends Maintenance {
|
|||
if ( $this->getDbType() == Maintenance::DB_NONE ) {
|
||||
// TODO: Allow hooks to be registered via SettingsBuilder as well!
|
||||
// This matches the idea of unifying SettingsBuilder with ExtensionRegistry.
|
||||
// phpcs:disable MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgHooks
|
||||
global $wgHooks;
|
||||
$wgHooks['InterwikiLoadPrefix'][] = 'DumpIterator::disableInterwikis';
|
||||
|
||||
|
|
|
|||
|
|
@ -1376,6 +1376,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
|
|||
}
|
||||
|
||||
private static function resetLegacyGlobals( MediaWikiServices $services ) {
|
||||
// phpcs:disable MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgHooks
|
||||
global $wgHooks;
|
||||
|
||||
$hooks = $wgHooks instanceof FauxGlobalHookArray ? $wgHooks->getOriginalArray() : $wgHooks;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ TestSetup::applyInitialConfig();
|
|||
$process = proc_open(
|
||||
__DIR__ . '/getPHPUnitExtensionsAndSkins.php',
|
||||
[
|
||||
0 => [ 'pipe' ,'r' ],
|
||||
0 => [ 'pipe', 'r' ],
|
||||
1 => [ 'pipe', 'w' ],
|
||||
2 => [ 'pipe', 'w' ]
|
||||
],
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ class HooksTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers Hooks::getHandlers
|
||||
*/
|
||||
public function testGetHandlers() {
|
||||
// phpcs:disable MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgHooks
|
||||
global $wgHooks;
|
||||
$hookContainer = $this->getServiceContainer()->getHookContainer();
|
||||
|
||||
|
|
@ -108,6 +109,7 @@ class HooksTest extends MediaWikiIntegrationTestCase {
|
|||
public function testRegistration() {
|
||||
$this->hideDeprecated( 'Hooks::isRegistered' );
|
||||
$this->hideDeprecated( 'Hooks::run' );
|
||||
// phpcs:disable MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgHooks
|
||||
global $wgHooks;
|
||||
$hookContainer = $this->getServiceContainer()->getHookContainer();
|
||||
|
||||
|
|
|
|||
|
|
@ -1373,10 +1373,10 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
|
|||
$catLinks = $op->getCategoryLinks();
|
||||
$this->assertCount( (bool)$expectedNormal + (bool)$expectedHidden, $catLinks );
|
||||
if ( $expectedNormal ) {
|
||||
$this->assertSame( count( $expectedNormal ), count( $catLinks['normal'] ) );
|
||||
$this->assertSameSize( $expectedNormal, $catLinks['normal'] );
|
||||
}
|
||||
if ( $expectedHidden ) {
|
||||
$this->assertSame( count( $expectedHidden ), count( $catLinks['hidden'] ) );
|
||||
$this->assertSameSize( $expectedHidden, $catLinks['hidden'] );
|
||||
}
|
||||
|
||||
foreach ( $expectedNormal as $i => $name ) {
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ class MessageBlobStoreTest extends \PHPUnit\Framework\TestCase {
|
|||
// Arrange version 1 and 2
|
||||
$blobStore->expects( $this->exactly( 2 ) )
|
||||
->method( 'fetchMessage' )
|
||||
->will( $this->onConsecutiveCalls( 'First', 'Second' ) );
|
||||
->willReturnOnConsecutiveCalls( 'First', 'Second' );
|
||||
|
||||
// Assert
|
||||
$blob = $blobStore->getBlob( $module, 'en' );
|
||||
|
|
|
|||
|
|
@ -667,9 +667,9 @@ END
|
|||
$mock = $this->getMockBuilder( ResourceLoaderTestModule::class )
|
||||
->onlyMethods( [ $getter, 'getName' ] )
|
||||
->getMock();
|
||||
$mock->method( $getter )->will( $this->throwException(
|
||||
$mock->method( $getter )->willThrowException(
|
||||
new Exception( 'Ferry not found' )
|
||||
) );
|
||||
);
|
||||
$mock->method( 'getName' )->willReturn( __METHOD__ );
|
||||
return $mock;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -728,9 +728,7 @@ mw.loader.register([
|
|||
'factory' => function () {
|
||||
$mock = $this->getMockBuilder( ResourceLoaderTestModule::class )
|
||||
->onlyMethods( [ 'getModuleContent' ] )->getMock();
|
||||
$mock->method( 'getModuleContent' )->will(
|
||||
$this->throwException( new Exception )
|
||||
);
|
||||
$mock->method( 'getModuleContent' )->willThrowException( new Exception );
|
||||
return $mock;
|
||||
}
|
||||
]
|
||||
|
|
@ -750,9 +748,7 @@ mw.loader.register([
|
|||
] )
|
||||
->getMock();
|
||||
$mock->method( 'enableModuleContentVersion' )->willReturn( false );
|
||||
$mock->method( 'getDefinitionSummary' )->will(
|
||||
$this->throwException( new Exception )
|
||||
);
|
||||
$mock->method( 'getDefinitionSummary' )->willThrowException( new Exception );
|
||||
return $mock;
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class RevisionRendererTest extends MediaWikiIntegrationTestCase {
|
|||
);
|
||||
}
|
||||
);
|
||||
$db->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $db ) );
|
||||
$db->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $db ) );
|
||||
|
||||
return $db;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ class StatusTest extends MediaWikiLangTestCase {
|
|||
}
|
||||
$warnings = $status->getWarningsArray();
|
||||
|
||||
$this->assertSame( count( $messages ), count( $warnings ) );
|
||||
$this->assertSameSize( $messages, $warnings );
|
||||
foreach ( $messages as $key => $message ) {
|
||||
$expectedArray = array_merge( [ $message->getKey() ], $message->getParams() );
|
||||
$this->assertEquals( $expectedArray, $warnings[$key] );
|
||||
|
|
@ -191,7 +191,7 @@ class StatusTest extends MediaWikiLangTestCase {
|
|||
}
|
||||
$errors = $status->getErrorsArray();
|
||||
|
||||
$this->assertSame( count( $messages ), count( $errors ) );
|
||||
$this->assertSameSize( $messages, $errors );
|
||||
foreach ( $messages as $key => $message ) {
|
||||
$expectedArray = array_merge( [ $message->getKey() ], $message->getParams() );
|
||||
$this->assertEquals( $expectedArray, $errors[$key] );
|
||||
|
|
@ -213,7 +213,7 @@ class StatusTest extends MediaWikiLangTestCase {
|
|||
}
|
||||
$errors = $status->getErrorsArray();
|
||||
|
||||
$this->assertSame( count( $messages ), count( $errors ) );
|
||||
$this->assertSameSize( $messages, $errors );
|
||||
foreach ( $messages as $key => $message ) {
|
||||
$expectedArray = array_merge( [ $message->getKey() ], $message->getParams() );
|
||||
$this->assertEquals( $expectedArray, $errors[$key] );
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ class NameTableStoreTest extends MediaWikiIntegrationTestCase {
|
|||
return $this->db->$method( ...$args );
|
||||
} );
|
||||
}
|
||||
$mock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $mock ) );
|
||||
$mock->method( 'newInsertQueryBuilder' )->willReturnCallback( static fn() => new InsertQueryBuilder( $mock ) );
|
||||
$mock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $mock ) );
|
||||
$mock->method( 'newInsertQueryBuilder' )->willReturnCallback( static fn () => new InsertQueryBuilder( $mock ) );
|
||||
return $mock;
|
||||
}
|
||||
|
||||
|
|
@ -389,7 +389,7 @@ class NameTableStoreTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
return true;
|
||||
} );
|
||||
$db->method( 'newInsertQueryBuilder' )->willReturnCallback( static fn() => new InsertQueryBuilder( $db ) );
|
||||
$db->method( 'newInsertQueryBuilder' )->willReturnCallback( static fn () => new InsertQueryBuilder( $db ) );
|
||||
|
||||
$lb = $this->createMock( LoadBalancer::class );
|
||||
$lb->method( 'getConnection' )
|
||||
|
|
|
|||
|
|
@ -433,12 +433,10 @@ class WatchActionTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$mockMessageLocalizer->expects( $this->exactly( 2 ) )
|
||||
->method( 'msg' )
|
||||
->will(
|
||||
$this->onConsecutiveCalls(
|
||||
->willReturnOnConsecutiveCalls(
|
||||
$mockMessage,
|
||||
new Message( 'watchlist-expiry-options' )
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
$expected = WatchAction::getExpiryOptions( new MockMessageLocalizer( 'en' ), false );
|
||||
$expiryOptions = WatchAction::getExpiryOptions( $mockMessageLocalizer, false );
|
||||
|
|
|
|||
|
|
@ -1324,7 +1324,7 @@ class ApiBaseTest extends ApiTestCase {
|
|||
$paramDescription = $mock->getFinalParamDescription();
|
||||
$this->assertArrayHasKey( 'param', $paramDescription );
|
||||
$messages = $paramDescription['param'];
|
||||
$messageKeys = array_map( static fn( MessageSpecifier $m ) => $m->getKey(), $messages );
|
||||
$messageKeys = array_map( static fn ( MessageSpecifier $m ) => $m->getKey(), $messages );
|
||||
$this->assertSame( $expectedMessages, $messageKeys );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ class ApiMainTest extends ApiTestCase {
|
|||
$mock->method( 'getModuleName' )->willReturn( 'testmodule' );
|
||||
$mock->method( 'getConditionalRequestData' )
|
||||
->willReturn( wfTimestamp( TS_MW, $now - 3600 ) );
|
||||
$mock->expects( $this->exactly( 0 ) )->method( 'execute' );
|
||||
$mock->expects( $this->never() )->method( 'execute' );
|
||||
|
||||
$req = new FauxRequest( [
|
||||
'action' => 'testmodule',
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ class ApiParamValidatorCallbacksTest extends ApiUploadTestCase {
|
|||
->onlyMethods( [ 'canApiHighLimits' ] )
|
||||
->getMock();
|
||||
|
||||
$main->method( 'canApiHighLimits' )->will( $this->onConsecutiveCalls( true, false ) );
|
||||
$main->method( 'canApiHighLimits' )->willReturnOnConsecutiveCalls( true, false );
|
||||
|
||||
$callbacks = new ApiParamValidatorCallbacks( $main );
|
||||
$this->assertTrue( $callbacks->useHighLimits( [] ) );
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ class ApiQueryWatchlistIntegrationTest extends ApiTestCase {
|
|||
array $keysUsedInValueComparison,
|
||||
array $requiredKeys = []
|
||||
) {
|
||||
$this->assertCount( count( $expectedItems ), $actualItems );
|
||||
$this->assertSameSize( $expectedItems, $actualItems );
|
||||
|
||||
// not checking values of all keys of the actual item, so removing unwanted keys from comparison
|
||||
$actualItemsOnlyComparedValues = array_map(
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class BacklinkCacheTest extends MediaWikiIntegrationTestCase {
|
|||
$blcFactory = $this->getServiceContainer()->getBacklinkCacheFactory();
|
||||
$backlinkCache = $blcFactory->getBacklinkCache( Title::newFromText( $title ) );
|
||||
$titlesArray = iterator_to_array( $backlinkCache->getLinkPages( $table, $startId, $endId, $max ) );
|
||||
$this->assertSame( count( $expectedTitles ), count( $titlesArray ) );
|
||||
$this->assertSameSize( $expectedTitles, $titlesArray );
|
||||
$numOfTitles = count( $titlesArray );
|
||||
for ( $i = 0; $i < $numOfTitles; $i++ ) {
|
||||
$this->assertEquals( $expectedTitles[$i], $titlesArray[$i]->getDbKey() );
|
||||
|
|
|
|||
|
|
@ -1306,9 +1306,9 @@ class FileBackendIntegrationTest extends MediaWikiIntegrationTestCase {
|
|||
array_keys( $contents ),
|
||||
"Contents in right order ($backendName)."
|
||||
);
|
||||
$this->assertSame(
|
||||
count( $source ),
|
||||
count( $contents ),
|
||||
$this->assertSameSize(
|
||||
$source,
|
||||
$contents,
|
||||
"Contents array size correct ($backendName)."
|
||||
);
|
||||
} else {
|
||||
|
|
@ -1380,9 +1380,9 @@ class FileBackendIntegrationTest extends MediaWikiIntegrationTestCase {
|
|||
array_keys( $tmpFiles ),
|
||||
"Local copies in right order ($backendName)."
|
||||
);
|
||||
$this->assertSame(
|
||||
count( $source ),
|
||||
count( $tmpFiles ),
|
||||
$this->assertSameSize(
|
||||
$source,
|
||||
$tmpFiles,
|
||||
"Local copies array size correct ($backendName)."
|
||||
);
|
||||
} else {
|
||||
|
|
@ -1465,9 +1465,9 @@ class FileBackendIntegrationTest extends MediaWikiIntegrationTestCase {
|
|||
array_keys( $tmpFiles ),
|
||||
"Local refs in right order ($backendName)."
|
||||
);
|
||||
$this->assertSame(
|
||||
count( $source ),
|
||||
count( $tmpFiles ),
|
||||
$this->assertSameSize(
|
||||
$source,
|
||||
$tmpFiles,
|
||||
"Local refs array size correct ($backendName)."
|
||||
);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class FileBackendDBRepoWrapperTest extends MediaWikiIntegrationTestCase {
|
|||
$dbMock->expects( $dbReadsExpected )
|
||||
->method( 'selectField' )
|
||||
->willReturn( $dbReturnValue );
|
||||
$dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $dbMock ) );
|
||||
$dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $dbMock ) );
|
||||
|
||||
$newPaths = $wrapperMock->getBackendPaths( [ $originalPath ], $latest );
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ class FileBackendDBRepoWrapperTest extends MediaWikiIntegrationTestCase {
|
|||
$dbMock->expects( $this->once() )
|
||||
->method( 'selectField' )
|
||||
->willReturn( '96246614d75ba1703bdfd5d7660bb57407aaf5d9' );
|
||||
$dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $dbMock ) );
|
||||
$dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $dbMock ) );
|
||||
|
||||
$backendMock->expects( $this->once() )
|
||||
->method( 'getFileContentsMulti' )
|
||||
|
|
@ -122,7 +122,7 @@ class FileBackendDBRepoWrapperTest extends MediaWikiIntegrationTestCase {
|
|||
->disableOriginalClone()
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $dbMock ) );
|
||||
$dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $dbMock ) );
|
||||
|
||||
$backendMock = $this->getMockBuilder( FSFileBackend::class )
|
||||
->setConstructorArgs( [ [
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ class LocalRepoTest extends MediaWikiIntegrationTestCase {
|
|||
$mockBag = $this->getMockBuilder( EmptyBagOStuff::class )
|
||||
->onlyMethods( [ 'makeKey', 'makeGlobalKey' ] )
|
||||
->getMock();
|
||||
$mockBag->expects( $this->exactly( 0 ) )
|
||||
$mockBag->expects( $this->never() )
|
||||
->method( 'makeKey' )
|
||||
->withConsecutive(
|
||||
[ 'filerepo-file-redirect', 'local', md5( 'Redirect' ) ]
|
||||
|
|
|
|||
|
|
@ -41,12 +41,12 @@ class MigrateFileRepoLayoutTest extends MediaWikiIntegrationTestCase {
|
|||
];
|
||||
|
||||
$dbMock->method( 'select' )
|
||||
->will( $this->onConsecutiveCalls(
|
||||
->willReturnOnConsecutiveCalls(
|
||||
new FakeResultWrapper( [ $imageRow ] ), // image
|
||||
new FakeResultWrapper( [] ), // image
|
||||
new FakeResultWrapper( [] ) // filearchive
|
||||
) );
|
||||
$dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $dbMock ) );
|
||||
);
|
||||
$dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( fn () => new SelectQueryBuilder( $dbMock ) );
|
||||
|
||||
$repoMock = $this->getMockBuilder( LocalRepo::class )
|
||||
->onlyMethods( [ 'getPrimaryDB', 'getReplicaDB' ] )
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ class MultiHttpClientTest extends MediaWikiIntegrationTestCase {
|
|||
] );
|
||||
|
||||
$this->assertSame( 200, $rcode );
|
||||
$this->assertSame( count( $headers ), count( $rhdrs ) );
|
||||
$this->assertSameSize( $headers, $rhdrs );
|
||||
foreach ( $headers as $name => $values ) {
|
||||
$value = implode( ', ', $values );
|
||||
$this->assertArrayHasKey( $name, $rhdrs );
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ class ExtensionRegistrationTest extends MediaWikiIntegrationTestCase {
|
|||
private $originalExtensionRegistry = null;
|
||||
|
||||
protected function setUp(): void {
|
||||
// phpcs:disable MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgHooks
|
||||
global $wgHooks;
|
||||
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class SpecialContributeTest extends SpecialPageTestBase {
|
|||
*/
|
||||
public function testExecute() {
|
||||
$this->specialContribute = new SpecialContribute();
|
||||
list( $html ) = $this->executeSpecialPage(
|
||||
[ $html ] = $this->executeSpecialPage(
|
||||
$this->admin->getUser()->getName(),
|
||||
null,
|
||||
'qqx',
|
||||
|
|
|
|||
|
|
@ -294,8 +294,8 @@ class UserOptionsManagerTest extends UserOptionsLookupTest {
|
|||
'up_property' => 'test_option',
|
||||
]
|
||||
] ) );
|
||||
$mockDb->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $mockDb ) );
|
||||
$mockDb->method( 'newInsertQueryBuilder' )->willReturnCallback( static fn() => new InsertQueryBuilder( $mockDb ) );
|
||||
$mockDb->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $mockDb ) );
|
||||
$mockDb->method( 'newInsertQueryBuilder' )->willReturnCallback( static fn () => new InsertQueryBuilder( $mockDb ) );
|
||||
$mockDbProvider = $this->createMock( IConnectionProvider::class );
|
||||
$mockDbProvider
|
||||
->method( 'getPrimaryDatabase' )
|
||||
|
|
@ -329,7 +329,7 @@ class UserOptionsManagerTest extends UserOptionsLookupTest {
|
|||
] ) );
|
||||
$mockDb->expects( $this->never() ) // This is critical what we are testing
|
||||
->method( 'delete' );
|
||||
$mockDb->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $mockDb ) );
|
||||
$mockDb->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $mockDb ) );
|
||||
$mockDbProvider = $this->createMock( IConnectionProvider::class );
|
||||
$mockDbProvider
|
||||
->method( 'getPrimaryDatabase' )
|
||||
|
|
@ -356,7 +356,7 @@ class UserOptionsManagerTest extends UserOptionsLookupTest {
|
|||
$mockDb = $this->createMock( DBConnRef::class );
|
||||
$mockDb
|
||||
->method( 'newDeleteQueryBuilder' )
|
||||
->willReturnCallback( static fn() => new DeleteQueryBuilder( $mockDb ) );
|
||||
->willReturnCallback( static fn () => new DeleteQueryBuilder( $mockDb ) );
|
||||
$mockDb->expects( $this->once() )
|
||||
->method( 'select' )
|
||||
->willReturn( new FakeResultWrapper( [
|
||||
|
|
@ -386,7 +386,7 @@ class UserOptionsManagerTest extends UserOptionsLookupTest {
|
|||
'up_property' => [ 'set_default', 'set_default_null', 'set_default_not_null' ]
|
||||
]
|
||||
);
|
||||
$mockDb->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $mockDb ) );
|
||||
$mockDb->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $mockDb ) );
|
||||
$mockDbProvider = $this->createMock( IConnectionProvider::class );
|
||||
$mockDbProvider
|
||||
->method( 'getPrimaryDatabase' )
|
||||
|
|
|
|||
|
|
@ -40,10 +40,10 @@ class WatchedItemStoreUnitTest extends MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
private function getMockDb() {
|
||||
$mock = $this->createMock( DBConnRef::class );
|
||||
$mock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $mock ) );
|
||||
$mock->method( 'newUpdateQueryBuilder' )->willReturnCallback( static fn() => new UpdateQueryBuilder( $mock ) );
|
||||
$mock->method( 'newDeleteQueryBuilder' )->willReturnCallback( static fn() => new DeleteQueryBuilder( $mock ) );
|
||||
$mock->method( 'newReplaceQueryBuilder' )->willReturnCallback( static fn() => new ReplaceQueryBuilder( $mock ) );
|
||||
$mock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $mock ) );
|
||||
$mock->method( 'newUpdateQueryBuilder' )->willReturnCallback( static fn () => new UpdateQueryBuilder( $mock ) );
|
||||
$mock->method( 'newDeleteQueryBuilder' )->willReturnCallback( static fn () => new DeleteQueryBuilder( $mock ) );
|
||||
$mock->method( 'newReplaceQueryBuilder' )->willReturnCallback( static fn () => new ReplaceQueryBuilder( $mock ) );
|
||||
return $mock;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ class UserRightsProxyTest extends MediaWikiIntegrationTestCase {
|
|||
'user_id' => 12345,
|
||||
];
|
||||
$dbMock->method( 'selectRow' )->willReturn( $row );
|
||||
$dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $dbMock ) );
|
||||
$dbMock->method( 'newReplaceQueryBuilder' )->willReturnCallback( static fn() => new ReplaceQueryBuilder( $dbMock ) );
|
||||
$dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $dbMock ) );
|
||||
$dbMock->method( 'newReplaceQueryBuilder' )->willReturnCallback( static fn () => new ReplaceQueryBuilder( $dbMock ) );
|
||||
|
||||
$lbMock = $this->createMock( ILoadBalancer::class );
|
||||
$lbMock->method( 'getMaintenanceConnectionRef' )->willReturn( $dbMock );
|
||||
|
|
@ -219,8 +219,8 @@ class UserRightsProxyTest extends MediaWikiIntegrationTestCase {
|
|||
$dbMock->method( 'selectRow' )->willReturn( $row );
|
||||
$dbMock->method( 'timestamp' )->willReturn( 'timestamp' );
|
||||
$dbMock->method( 'getDomainID' )->willReturn( 'foowiki' );
|
||||
$dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $dbMock ) );
|
||||
$dbMock->method( 'newReplaceQueryBuilder' )->willReturnCallback( static fn() => new ReplaceQueryBuilder( $dbMock ) );
|
||||
$dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $dbMock ) );
|
||||
$dbMock->method( 'newReplaceQueryBuilder' )->willReturnCallback( static fn () => new ReplaceQueryBuilder( $dbMock ) );
|
||||
|
||||
$dbMock->expects( $this->once() )
|
||||
->method( 'replace' )
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class UserSelectQueryBuilderTest extends ActorStoreTestBase {
|
|||
->caller( __METHOD__ )
|
||||
->orderByName( $options['sort'] ?? SelectQueryBuilder::SORT_ASC );
|
||||
$actors = iterator_to_array( $queryBuilder->fetchUserIdentities() );
|
||||
$this->assertCount( count( $expected ), $actors );
|
||||
$this->assertSameSize( $expected, $actors );
|
||||
foreach ( $expected as $idx => $expectedActor ) {
|
||||
$this->assertSameActors( $expectedActor, $actors[$idx] );
|
||||
}
|
||||
|
|
@ -95,7 +95,7 @@ class UserSelectQueryBuilderTest extends ActorStoreTestBase {
|
|||
->orderByUserId( $options['sort'] ?? SelectQueryBuilder::SORT_ASC )
|
||||
->fetchUserIdentities()
|
||||
);
|
||||
$this->assertCount( count( $expected ), $actors );
|
||||
$this->assertSameSize( $expected, $actors );
|
||||
foreach ( $expected as $idx => $expectedActor ) {
|
||||
$this->assertSameActors( $expectedActor, $actors[$idx] );
|
||||
}
|
||||
|
|
@ -146,7 +146,7 @@ class UserSelectQueryBuilderTest extends ActorStoreTestBase {
|
|||
->orderByUserId( $options['sort'] ?? SelectQueryBuilder::SORT_ASC )
|
||||
->fetchUserIdentities()
|
||||
);
|
||||
$this->assertCount( count( $expected ), $actors );
|
||||
$this->assertSameSize( $expected, $actors );
|
||||
foreach ( $expected as $idx => $expectedActor ) {
|
||||
$this->assertSameActors( $expectedActor, $actors[$idx] );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,10 +145,10 @@ class BenchmarkerTest extends TestCase {
|
|||
|
||||
$out = '';
|
||||
$bench->expects( $this->any() )->method( 'output' )
|
||||
->will( $this->returnCallback( static function ( $str ) use ( &$out ) {
|
||||
->willReturnCallback( static function ( $str ) use ( &$out ) {
|
||||
$out .= $str;
|
||||
return null;
|
||||
} ) );
|
||||
} );
|
||||
|
||||
$bench->bench( [
|
||||
[
|
||||
|
|
|
|||
|
|
@ -320,6 +320,6 @@ class CorsUtilsTest extends \MediaWikiUnitTestCase {
|
|||
$header = $response->getHeader( 'Access-Control-Allow-Headers' );
|
||||
$this->assertContains( 'Authorization', $header );
|
||||
$this->assertContains( 'Content-Type', $header );
|
||||
$this->assertSame( count( $header ), count( array_unique( $header ) ) );
|
||||
$this->assertSameSize( $header, array_unique( $header ) );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ class CachedSourceTest extends TestCase {
|
|||
$source
|
||||
->expects( $this->once() )
|
||||
->method( 'load' )
|
||||
->will( $this->throwException( new SettingsBuilderException( 'foo' ) ) );
|
||||
->willThrowException( new SettingsBuilderException( 'foo' ) );
|
||||
|
||||
$this->assertSame( $settings, $cacheSource->load() );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class EditResultCacheTest extends MediaWikiUnitTestCase {
|
|||
$dbr->expects( $this->once() )
|
||||
->method( 'selectField' )
|
||||
->willReturn( FormatJson::encode( $editResult ) );
|
||||
$dbr->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $dbr ) );
|
||||
$dbr->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $dbr ) );
|
||||
$dbProvider = $this->createMock( IConnectionProvider::class );
|
||||
$dbProvider->expects( $this->once() )
|
||||
->method( 'getReplicaDatabase' )
|
||||
|
|
@ -152,7 +152,7 @@ class EditResultCacheTest extends MediaWikiUnitTestCase {
|
|||
$dbr->expects( $this->once() )
|
||||
->method( 'selectField' )
|
||||
->willReturn( false );
|
||||
$dbr->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $dbr ) );
|
||||
$dbr->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $dbr ) );
|
||||
$dbProvider = $this->createMock( IConnectionProvider::class );
|
||||
$dbProvider->expects( $this->once() )
|
||||
->method( 'getReplicaDatabase' )
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ class EtcdConfigTest extends MediaWikiUnitTestCase {
|
|||
->onlyMethods( [ 'get', 'lock' ] )
|
||||
->getMock();
|
||||
$cache->expects( $this->exactly( 2 ) )->method( 'get' )
|
||||
->will( $this->onConsecutiveCalls(
|
||||
->willReturnOnConsecutiveCalls(
|
||||
// .. misses cache first time
|
||||
false,
|
||||
// .. hits cache on retry
|
||||
|
|
@ -212,7 +212,7 @@ class EtcdConfigTest extends MediaWikiUnitTestCase {
|
|||
'expires' => INF,
|
||||
'modifiedIndex' => 123
|
||||
]
|
||||
) );
|
||||
);
|
||||
// .. misses lock
|
||||
$cache->expects( $this->once() )->method( 'lock' )
|
||||
->willReturn( false );
|
||||
|
|
|
|||
|
|
@ -47,13 +47,11 @@ class UserRateLimitConstraintTest extends MediaWikiUnitTestCase {
|
|||
[ 'linkpurge', 0 ],
|
||||
[ 'editcontentmodel', 1 ]
|
||||
)
|
||||
->will(
|
||||
$this->onConsecutiveCalls(
|
||||
->willReturnOnConsecutiveCalls(
|
||||
false,
|
||||
false,
|
||||
false
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
$title = $this->createMock( Title::class );
|
||||
$title->expects( $this->once() )
|
||||
|
|
@ -78,13 +76,11 @@ class UserRateLimitConstraintTest extends MediaWikiUnitTestCase {
|
|||
[ 'linkpurge', 0 ],
|
||||
[ 'editcontentmodel', 1 ]
|
||||
)
|
||||
->will(
|
||||
$this->onConsecutiveCalls(
|
||||
->willReturnOnConsecutiveCalls(
|
||||
false,
|
||||
false,
|
||||
true // Only die on the last check
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
$title = $this->createMock( Title::class );
|
||||
$title->expects( $this->once() )
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class PingbackTest extends MediaWikiUnitTestCase {
|
|||
// - cache lock is unavailable
|
||||
$database = $this->createNoOpMock( DBConnRef::class, [ 'selectField', 'newSelectQueryBuilder' ] );
|
||||
$database->expects( $this->once() )->method( 'selectField' )->willReturn( false );
|
||||
$database->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $database ) );
|
||||
$database->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $database ) );
|
||||
|
||||
$cache = $this->createMock( BagOStuff::class );
|
||||
$cache->method( 'add' )->willReturn( false );
|
||||
|
|
@ -95,7 +95,7 @@ class PingbackTest extends MediaWikiUnitTestCase {
|
|||
$database = $this->createNoOpMock( DBConnRef::class, [ 'selectField', 'lock', 'newSelectQueryBuilder' ] );
|
||||
$database->expects( $this->once() )->method( 'selectField' )->willReturn( false );
|
||||
$database->expects( $this->once() )->method( 'lock' )->willReturn( false );
|
||||
$database->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $database ) );
|
||||
$database->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $database ) );
|
||||
|
||||
$pingback = $this->makePingback(
|
||||
$database,
|
||||
|
|
@ -130,8 +130,8 @@ class PingbackTest extends MediaWikiUnitTestCase {
|
|||
->with( 'https://www.mediawiki.org/beacon/event?%7B%22some%22%3A%22stuff%22%7D;' )
|
||||
->willReturn( true );
|
||||
$database->expects( $this->once() )->method( 'upsert' );
|
||||
$database->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $database ) );
|
||||
$database->method( 'newInsertQueryBuilder' )->willReturnCallback( static fn() => new InsertQueryBuilder( $database ) );
|
||||
$database->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $database ) );
|
||||
$database->method( 'newInsertQueryBuilder' )->willReturnCallback( static fn () => new InsertQueryBuilder( $database ) );
|
||||
|
||||
$pingback = $this->makePingback(
|
||||
$database,
|
||||
|
|
@ -160,7 +160,7 @@ class PingbackTest extends MediaWikiUnitTestCase {
|
|||
$database->expects( $this->once() )->method( 'selectField' )->willReturn(
|
||||
ConvertibleTimestamp::convert( TS_UNIX, '20110401080000' )
|
||||
);
|
||||
$database->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $database ) );
|
||||
$database->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $database ) );
|
||||
|
||||
$pingback = $this->makePingback(
|
||||
$database,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class StatsEmitterTest extends TestCase {
|
|||
public function testSend() {
|
||||
// set up a mock statsd data factory
|
||||
$statsd = $this->createMock( IBufferingStatsdDataFactory::class );
|
||||
$statsd->expects( $this->exactly( 1 ) )->method( "updateCount" );
|
||||
$statsd->expects( $this->once() )->method( "updateCount" );
|
||||
|
||||
// initialize cache
|
||||
$cache = new StatsCache();
|
||||
|
|
@ -36,7 +36,7 @@ class StatsEmitterTest extends TestCase {
|
|||
|
||||
// transport
|
||||
$transport = $this->createMock( UDPTransport::class );
|
||||
$transport->expects( $this->exactly( 1 ) )->method( "emit" )
|
||||
$transport->expects( $this->once() )->method( "emit" )
|
||||
->withConsecutive(
|
||||
[ "mediawiki.test.bar:1|c\nmediawiki.test.bar:1|c\nmediawiki.test.foo:3.14|ms\n" ]
|
||||
);
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ class XhprofDataTest extends PHPUnit\Framework\TestCase {
|
|||
*/
|
||||
protected function assertArrayStructure( $struct, $actual, $label = '' ) {
|
||||
$this->assertIsArray( $actual, $label );
|
||||
$this->assertCount( count( $struct ), $actual, $label );
|
||||
$this->assertSameSize( $struct, $actual, $label );
|
||||
foreach ( $struct as $key => $type ) {
|
||||
$this->assertArrayHasKey( $key, $actual );
|
||||
switch ( $type ) {
|
||||
|
|
|
|||
|
|
@ -2350,7 +2350,7 @@ class WANObjectCacheTest extends MediaWikiUnitTestCase {
|
|||
* @param string|null $keyNeedle
|
||||
*/
|
||||
public function testSegmentableValues( array $params, $keyNeedle ) {
|
||||
list( $cache, $bag ) = $this->newWanCache( $params );
|
||||
[ $cache, $bag ] = $this->newWanCache( $params );
|
||||
$mockWallClock = 1549343530.0;
|
||||
$cache->setMockTime( $mockWallClock );
|
||||
$key = $cache->makeGlobalKey( 'z', wfRandomString() );
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ class TransactionProfilerTest extends PHPUnit\Framework\TestCase {
|
|||
|
||||
public function testSilence() {
|
||||
$logger = $this->createMock( LoggerInterface::class );
|
||||
$logger->expects( $this->exactly( 0 ) )->method( 'warning' );
|
||||
$logger->expects( $this->never() )->method( 'warning' );
|
||||
|
||||
$now = 1668108368.0;
|
||||
$tp = new TransactionProfiler();
|
||||
|
|
@ -221,7 +221,7 @@ class TransactionProfilerTest extends PHPUnit\Framework\TestCase {
|
|||
public function testPartialSilence() {
|
||||
$logger = $this->createMock( LoggerInterface::class );
|
||||
// 1 entry for slow write
|
||||
$logger->expects( $this->exactly( 1 ) )->method( 'warning' );
|
||||
$logger->expects( $this->once() )->method( 'warning' );
|
||||
|
||||
$now = 1668108368.0;
|
||||
$tp = new TransactionProfiler();
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class UserNamePrefixSearchTest extends MediaWikiUnitTestCase {
|
|||
$joinConds
|
||||
)
|
||||
->willReturn( $result );
|
||||
$database->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $database ) );
|
||||
$database->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $database ) );
|
||||
|
||||
$dbProvider = $this->createMock( IConnectionProvider::class );
|
||||
$dbProvider->expects( $this->once() )
|
||||
|
|
|
|||
Loading…
Reference in a new issue