aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUmherirrender <umherirrender_de.wp@web.de>2021-01-30 13:51:38 +0100
committerReedy <reedy@wikimedia.org>2021-01-31 13:34:38 +0000
commit62002cdcf1becd528764cad2123393fd8ac4d587 (patch)
treee0739c735a3ecc85a6eb06f762c89d1efb961d44
parent8a03ce65641954fa283c97283b9f1f6e513109e9 (diff)
downloadmediawikicore-62002cdcf1becd528764cad2123393fd8ac4d587.tar.gz
mediawikicore-62002cdcf1becd528764cad2123393fd8ac4d587.zip
build: Update mediawiki/mediawiki-codesniffer to 35.0.0
Change-Id: Idb413be4b8cba8611afdc022af59810ce1a4531e
-rw-r--r--.phpcs.xml8
-rw-r--r--composer.json2
-rw-r--r--includes/BadFileLookup.php3
-rw-r--r--includes/WebRequestUpload.php3
-rw-r--r--includes/libs/rdbms/database/Database.php1
-rw-r--r--includes/logging/ProtectLogFormatter.php2
-rw-r--r--maintenance/refreshLinks.php2
-rw-r--r--tests/phpunit/includes/HookContainer/HookContainerIntegrationTest.php6
-rw-r--r--tests/phpunit/includes/MultiHttpClientTest.php2
-rw-r--r--tests/phpunit/includes/OutputPageTest.php2
-rw-r--r--tests/phpunit/includes/Revision/McrRevisionStoreDbTest.php4
-rw-r--r--tests/phpunit/includes/StatusTest.php6
-rw-r--r--tests/phpunit/includes/TitleTest.php4
-rw-r--r--tests/phpunit/includes/content/ContentHandlerTest.php4
-rw-r--r--tests/phpunit/includes/db/LoadBalancerTest.php4
-rw-r--r--tests/phpunit/includes/filebackend/FileBackendIntegrationTest.php6
-rw-r--r--tests/phpunit/includes/libs/GenericArrayObjectTest.php2
-rw-r--r--tests/phpunit/includes/parser/CoreParserFunctionsTest.php4
-rw-r--r--tests/phpunit/includes/site/SiteTest.php4
-rw-r--r--tests/phpunit/includes/user/UserTest.php12
-rw-r--r--tests/phpunit/integration/includes/block/DatabaseBlockStoreTest.php2
-rw-r--r--tests/phpunit/languages/LanguageConverterTest.php4
-rw-r--r--tests/phpunit/maintenance/backupPrefetchTest.php2
-rw-r--r--tests/phpunit/structure/RestStructureTest.php2
-rw-r--r--tests/phpunit/unit/includes/HookContainer/HookContainerTest.php4
-rw-r--r--tests/phpunit/unit/includes/Rest/Validator/JsonBodyValidatorTest.php16
-rw-r--r--tests/phpunit/unit/includes/libs/XhprofDataTest.php2
-rw-r--r--tests/phpunit/unit/includes/libs/XhprofTest.php21
-rw-r--r--tests/phpunit/unit/includes/libs/objectcache/WANObjectCacheTest.php8
29 files changed, 80 insertions, 62 deletions
diff --git a/.phpcs.xml b/.phpcs.xml
index 28e31ea03c66..5cfb2868fa1d 100644
--- a/.phpcs.xml
+++ b/.phpcs.xml
@@ -5,6 +5,7 @@
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
+ <exclude name="MediaWiki.Commenting.FunctionComment.WrongStyle" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPrivate" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationProtected" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPublic" />
@@ -13,6 +14,7 @@
<exclude name="MediaWiki.Commenting.PropertyDocumentation.WrongStyle" />
<exclude name="MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures" />
<exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName" />
+ <exclude name="MediaWiki.PHPUnit.AssertCount.NotUsed" />
<exclude name="MediaWiki.Usage.DbrQueryUsage.DbrQueryFound" />
<exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgContLang" />
<exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle" />
@@ -22,11 +24,9 @@
<exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage" />
<exclude name="MediaWiki.Usage.ForbiddenFunctions.is_resource" />
<exclude name="MediaWiki.Usage.ForbiddenFunctions.passthru" />
+ <exclude name="MediaWiki.Usage.SuperGlobalsUsage.SuperGlobals" />
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
- </rule>
- <!-- TODO Still to be done -->
- <rule ref="MediaWiki.Commenting.FunctionComment.WrongStyle">
- <exclude-pattern>includes/</exclude-pattern>
+ <exclude name="PSR2.Classes.PropertyDeclaration.Multiple" />
</rule>
<!-- See T238572 -->
<rule ref="MediaWiki.Commenting.FunctionComment.MissingParamTag">
diff --git a/composer.json b/composer.json
index 27b6620d39fb..ecdfb4694f9c 100644
--- a/composer.json
+++ b/composer.json
@@ -80,7 +80,7 @@
"hamcrest/hamcrest-php": "^2.0",
"johnkary/phpunit-speedtrap": "^3.1",
"justinrainbow/json-schema": "~5.2",
- "mediawiki/mediawiki-codesniffer": "34.0.0",
+ "mediawiki/mediawiki-codesniffer": "35.0.0",
"mediawiki/mediawiki-phan-config": "0.10.6",
"monolog/monolog": "~2.2.0",
"nikic/php-parser": "4.10.2",
diff --git a/includes/BadFileLookup.php b/includes/BadFileLookup.php
index 8419f1082bc4..ce0e04efea46 100644
--- a/includes/BadFileLookup.php
+++ b/includes/BadFileLookup.php
@@ -128,7 +128,6 @@ class BadFileLookup {
}
return isset( $this->badFiles[$name] ) && ( !$contextTitle ||
- !isset( $this->badFiles[$name][$contextTitle->getNamespace()]
- [$contextTitle->getDBkey()] ) );
+ !isset( $this->badFiles[$name][$contextTitle->getNamespace()][$contextTitle->getDBkey()] ) );
}
}
diff --git a/includes/WebRequestUpload.php b/includes/WebRequestUpload.php
index 871412a82103..a492ae9be825 100644
--- a/includes/WebRequestUpload.php
+++ b/includes/WebRequestUpload.php
@@ -22,6 +22,9 @@
use MediaWiki\MediaWikiServices;
+// The point of this class is to be a wrapper around super globals
+// phpcs:disable MediaWiki.Usage.SuperGlobalsUsage.SuperGlobals
+
/**
* Object to access the $_FILES array
*
diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php
index c89a7476401e..5a0b57edb13e 100644
--- a/includes/libs/rdbms/database/Database.php
+++ b/includes/libs/rdbms/database/Database.php
@@ -68,6 +68,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
/** @var DatabaseDomain */
protected $currentDomain;
+ // phpcs:ignore MediaWiki.Commenting.PropertyDocumentation.ObjectTypeHintVar
/** @var object|resource|null Database connection */
protected $conn;
diff --git a/includes/logging/ProtectLogFormatter.php b/includes/logging/ProtectLogFormatter.php
index 0894eb3163f0..ce8d5c91f5d9 100644
--- a/includes/logging/ProtectLogFormatter.php
+++ b/includes/logging/ProtectLogFormatter.php
@@ -91,7 +91,7 @@ class ProtectLogFormatter extends LogFormatter {
$title = $this->entry->getTarget();
$links = [];
if ( $title->exists() ) {
- $links [] = $linkRenderer->makeLink( $title,
+ $links[] = $linkRenderer->makeLink( $title,
$this->msg( 'hist' )->text(),
[],
[
diff --git a/maintenance/refreshLinks.php b/maintenance/refreshLinks.php
index 26c4f9c096fa..5606300907b2 100644
--- a/maintenance/refreshLinks.php
+++ b/maintenance/refreshLinks.php
@@ -455,7 +455,7 @@ class RefreshLinks extends Maintenance {
do {
$finalConds = $conds;
$timestamp = $dbr->addQuotes( $timestamp );
- $finalConds [] =
+ $finalConds[] =
"(cl_timestamp > $timestamp OR (cl_timestamp = $timestamp AND cl_from > $lastId))";
$res = $dbr->select( [ 'page', 'categorylinks' ],
[ 'page_id', 'cl_timestamp' ],
diff --git a/tests/phpunit/includes/HookContainer/HookContainerIntegrationTest.php b/tests/phpunit/includes/HookContainer/HookContainerIntegrationTest.php
index 3e38677cc538..0344d7a87aaa 100644
--- a/tests/phpunit/includes/HookContainer/HookContainerIntegrationTest.php
+++ b/tests/phpunit/includes/HookContainer/HookContainerIntegrationTest.php
@@ -22,9 +22,9 @@ namespace MediaWiki\HookContainer {
] ] ]
];
$reset = $extensionRegistry->setAttributeForTest( 'Hooks', $handlers );
- $this->assertEquals( $numHandlersExecuted, 0 );
+ $this->assertSame( 0, $numHandlersExecuted );
$hookContainer->run( 'FooHook', [ &$numHandlersExecuted ] );
- $this->assertEquals( $numHandlersExecuted, 1 );
+ $this->assertSame( 1, $numHandlersExecuted );
ScopedCallback::consume( $reset );
}
@@ -85,7 +85,7 @@ namespace MediaWiki\HookContainer {
];
$reset3 = ExtensionRegistry::getInstance()->setAttributeForTest( 'Hooks', $handlerThree );
$hookContainer->run( 'FooHook', [ &$numHandlersExecuted ] );
- $this->assertEquals( $numHandlersExecuted, 3 );
+ $this->assertEquals( 3, $numHandlersExecuted );
ScopedCallback::consume( $reset );
ScopedCallback::consume( $reset2 );
ScopedCallback::consume( $reset3 );
diff --git a/tests/phpunit/includes/MultiHttpClientTest.php b/tests/phpunit/includes/MultiHttpClientTest.php
index 0d22dca56b45..7609d48a98cd 100644
--- a/tests/phpunit/includes/MultiHttpClientTest.php
+++ b/tests/phpunit/includes/MultiHttpClientTest.php
@@ -172,7 +172,7 @@ class MultiHttpClientTest extends MediaWikiIntegrationTestCase {
] );
$this->assertEquals( 200, $rcode );
- $this->assertEquals( count( $headers ), count( $rhdrs ) );
+ $this->assertSame( count( $headers ), count( $rhdrs ) );
foreach ( $headers as $name => $values ) {
$value = implode( ', ', $values );
$this->assertArrayHasKey( $name, $rhdrs );
diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php
index 46d56e7054da..b855fc0ea360 100644
--- a/tests/phpunit/includes/OutputPageTest.php
+++ b/tests/phpunit/includes/OutputPageTest.php
@@ -1254,7 +1254,7 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
private function doCategoryLinkAsserts( OutputPage $op, $expectedNormal, $expectedHidden ) {
$catLinks = $op->getCategoryLinks();
- $this->assertSame( (bool)$expectedNormal + (bool)$expectedHidden, count( $catLinks ) );
+ $this->assertCount( (bool)$expectedNormal + (bool)$expectedHidden, $catLinks );
if ( $expectedNormal ) {
$this->assertSame( count( $expectedNormal ), count( $catLinks['normal'] ) );
}
diff --git a/tests/phpunit/includes/Revision/McrRevisionStoreDbTest.php b/tests/phpunit/includes/Revision/McrRevisionStoreDbTest.php
index 7454111177a8..f5d54d97ba06 100644
--- a/tests/phpunit/includes/Revision/McrRevisionStoreDbTest.php
+++ b/tests/phpunit/includes/Revision/McrRevisionStoreDbTest.php
@@ -134,8 +134,8 @@ class McrRevisionStoreDbTest extends RevisionStoreDbTestBase {
$queryInfo = $store->getQueryInfo();
// with the new schema enabled, query info should not join the main slot info
- $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['tables'] ) );
- $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['joins'] ) );
+ $this->assertArrayNotHasKey( 'a_slot_data', $queryInfo['tables'] );
+ $this->assertArrayNotHasKey( 'a_slot_data', $queryInfo['joins'] );
}
/**
diff --git a/tests/phpunit/includes/StatusTest.php b/tests/phpunit/includes/StatusTest.php
index 5a8820d6db69..d9264c10b314 100644
--- a/tests/phpunit/includes/StatusTest.php
+++ b/tests/phpunit/includes/StatusTest.php
@@ -165,7 +165,7 @@ class StatusTest extends MediaWikiLangTestCase {
}
$warnings = $status->getWarningsArray();
- $this->assertEquals( count( $messages ), count( $warnings ) );
+ $this->assertSame( count( $messages ), count( $warnings ) );
foreach ( $messages as $key => $message ) {
$expectedArray = array_merge( [ $message->getKey() ], $message->getParams() );
$this->assertEquals( $warnings[$key], $expectedArray );
@@ -188,7 +188,7 @@ class StatusTest extends MediaWikiLangTestCase {
}
$errors = $status->getErrorsArray();
- $this->assertEquals( count( $messages ), count( $errors ) );
+ $this->assertSame( count( $messages ), count( $errors ) );
foreach ( $messages as $key => $message ) {
$expectedArray = array_merge( [ $message->getKey() ], $message->getParams() );
$this->assertEquals( $errors[$key], $expectedArray );
@@ -210,7 +210,7 @@ class StatusTest extends MediaWikiLangTestCase {
}
$errors = $status->getErrorsArray();
- $this->assertEquals( count( $messages ), count( $errors ) );
+ $this->assertSame( count( $messages ), count( $errors ) );
foreach ( $messages as $key => $message ) {
$expectedArray = array_merge( [ $message->getKey() ], $message->getParams() );
$this->assertEquals( $errors[$key], $expectedArray );
diff --git a/tests/phpunit/includes/TitleTest.php b/tests/phpunit/includes/TitleTest.php
index 467db11e5e2f..a73482d7df23 100644
--- a/tests/phpunit/includes/TitleTest.php
+++ b/tests/phpunit/includes/TitleTest.php
@@ -1776,8 +1776,8 @@ class TitleTest extends MediaWikiIntegrationTestCase {
[ 'edit' => [ 'sysop' ] ],
$result[1]
);
- $this->assertTrue(
- array_key_exists( $anotherPage->getTitle()->getArticleID(), $result[0] )
+ $this->assertArrayHasKey(
+ $anotherPage->getTitle()->getArticleID(), $result[0]
);
}
diff --git a/tests/phpunit/includes/content/ContentHandlerTest.php b/tests/phpunit/includes/content/ContentHandlerTest.php
index ff1b7aa08f05..e0b225967a94 100644
--- a/tests/phpunit/includes/content/ContentHandlerTest.php
+++ b/tests/phpunit/includes/content/ContentHandlerTest.php
@@ -338,7 +338,7 @@ class ContentHandlerTest extends MediaWikiIntegrationTestCase {
wfMessage( 'autosumm-newblank' )->inContentLanguage()->text() );
// now check, what we become with another bitmask
$autoSummary = $content->getAutosummary( null, $newContent, 92 );
- $this->assertEquals( $autoSummary, '' );
+ $this->assertSame( '', $autoSummary );
}
/**
@@ -354,7 +354,7 @@ class ContentHandlerTest extends MediaWikiIntegrationTestCase {
$newContent = ContentHandler::makeContent( '', null, CONTENT_MODEL_WIKITEXT, null );
// Get the tag for this edit
$tag = $wikitextContentHandler->getChangeTag( $oldContent, $newContent, EDIT_UPDATE );
- $this->assertSame( $tag, 'mw-contentmodelchange' );
+ $this->assertSame( 'mw-contentmodelchange', $tag );
}
/**
diff --git a/tests/phpunit/includes/db/LoadBalancerTest.php b/tests/phpunit/includes/db/LoadBalancerTest.php
index 2f32673950fe..44b14ff1ffe7 100644
--- a/tests/phpunit/includes/db/LoadBalancerTest.php
+++ b/tests/phpunit/includes/db/LoadBalancerTest.php
@@ -716,7 +716,7 @@ class LoadBalancerTest extends MediaWikiIntegrationTestCase {
$mainIndexPicked,
$lbWrapper->getExistingReaderIndex( $lb::GROUP_GENERIC )
);
- $this->assertTrue( in_array( $mainIndexPicked, [ 1, 2 ] ) );
+ $this->assertContains( $mainIndexPicked, [ 1, 2 ] );
for ( $i = 0; $i < 300; ++$i ) {
$rLog = $lb->getConnectionRef( DB_REPLICA, [] );
$this->assertEquals(
@@ -739,7 +739,7 @@ class LoadBalancerTest extends MediaWikiIntegrationTestCase {
$logIndexPicked = $rLog->getLBInfo( 'serverIndex' );
$this->assertEquals( $logIndexPicked, $lbWrapper->getExistingReaderIndex( 'logging' ) );
- $this->assertTrue( in_array( $logIndexPicked, [ 4, 5 ] ) );
+ $this->assertContains( $logIndexPicked, [ 4, 5 ] );
for ( $i = 0; $i < 300; ++$i ) {
$rLog = $lb->getConnectionRef( DB_REPLICA, [ 'logging', 'watchlist' ] );
diff --git a/tests/phpunit/includes/filebackend/FileBackendIntegrationTest.php b/tests/phpunit/includes/filebackend/FileBackendIntegrationTest.php
index f8332f1298c8..69f38ff9e6a3 100644
--- a/tests/phpunit/includes/filebackend/FileBackendIntegrationTest.php
+++ b/tests/phpunit/includes/filebackend/FileBackendIntegrationTest.php
@@ -1309,7 +1309,7 @@ class FileBackendIntegrationTest extends MediaWikiIntegrationTestCase {
array_keys( $contents ),
"Contents in right order ($backendName)."
);
- $this->assertEquals(
+ $this->assertSame(
count( $source ),
count( $contents ),
"Contents array size correct ($backendName)."
@@ -1383,7 +1383,7 @@ class FileBackendIntegrationTest extends MediaWikiIntegrationTestCase {
array_keys( $tmpFiles ),
"Local copies in right order ($backendName)."
);
- $this->assertEquals(
+ $this->assertSame(
count( $source ),
count( $tmpFiles ),
"Local copies array size correct ($backendName)."
@@ -1468,7 +1468,7 @@ class FileBackendIntegrationTest extends MediaWikiIntegrationTestCase {
array_keys( $tmpFiles ),
"Local refs in right order ($backendName)."
);
- $this->assertEquals(
+ $this->assertSame(
count( $source ),
count( $tmpFiles ),
"Local refs array size correct ($backendName)."
diff --git a/tests/phpunit/includes/libs/GenericArrayObjectTest.php b/tests/phpunit/includes/libs/GenericArrayObjectTest.php
index 373a8b8df05f..dba51bea0af0 100644
--- a/tests/phpunit/includes/libs/GenericArrayObjectTest.php
+++ b/tests/phpunit/includes/libs/GenericArrayObjectTest.php
@@ -269,7 +269,7 @@ abstract class GenericArrayObjectTest extends PHPUnit\Framework\TestCase {
$copy = unserialize( $serialization );
$this->assertEquals( $serialization, serialize( $copy ) );
- $this->assertEquals( count( $list ), count( $copy ) );
+ $this->assertSame( count( $list ), count( $copy ) );
$list = $list->getArrayCopy();
$copy = $copy->getArrayCopy();
diff --git a/tests/phpunit/includes/parser/CoreParserFunctionsTest.php b/tests/phpunit/includes/parser/CoreParserFunctionsTest.php
index 6b4737001021..1f0b1372d2a2 100644
--- a/tests/phpunit/includes/parser/CoreParserFunctionsTest.php
+++ b/tests/phpunit/includes/parser/CoreParserFunctionsTest.php
@@ -14,11 +14,11 @@ class CoreParserFunctionsTest extends MediaWikiLangTestCase {
$user->saveSettings();
$msg = ( new RawMessage( '{{GENDER:*Female|m|f|o}}' ) )->parse();
- $this->assertEquals( $msg, 'f', 'Works unescaped' );
+ $this->assertEquals( 'f', $msg, 'Works unescaped' );
$escapedName = wfEscapeWikiText( '*Female' );
$msg2 = ( new RawMessage( '{{GENDER:' . $escapedName . '|m|f|o}}' ) )
->parse();
- $this->assertEquals( $msg2, 'f', 'Works escaped' );
+ $this->assertEquals( 'f', $msg2, 'Works escaped' );
}
public function provideTalkpagename() {
diff --git a/tests/phpunit/includes/site/SiteTest.php b/tests/phpunit/includes/site/SiteTest.php
index c347e4911ec9..1d3d753bc2f9 100644
--- a/tests/phpunit/includes/site/SiteTest.php
+++ b/tests/phpunit/includes/site/SiteTest.php
@@ -57,7 +57,7 @@ class SiteTest extends MediaWikiIntegrationTestCase {
*/
public function testAddNavigationId( Site $site ) {
$site->addNavigationId( 'foobar' );
- $this->assertTrue( in_array( 'foobar', $site->getNavigationIds(), true ) );
+ $this->assertContains( 'foobar', $site->getNavigationIds() );
}
/**
@@ -67,7 +67,7 @@ class SiteTest extends MediaWikiIntegrationTestCase {
*/
public function testAddInterwikiId( Site $site ) {
$site->addInterwikiId( 'foobar' );
- $this->assertTrue( in_array( 'foobar', $site->getInterwikiIds(), true ) );
+ $this->assertContains( 'foobar', $site->getInterwikiIds() );
}
/**
diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php
index fab999e4b176..dde8edf51e3e 100644
--- a/tests/phpunit/includes/user/UserTest.php
+++ b/tests/phpunit/includes/user/UserTest.php
@@ -1607,8 +1607,8 @@ class UserTest extends MediaWikiIntegrationTestCase {
* @covers User::idFromName
*/
public function testExistingIdFromName() {
- $this->assertTrue(
- array_key_exists( $this->user->getName(), User::$idCacheByName ),
+ $this->assertArrayHasKey(
+ $this->user->getName(), User::$idCacheByName,
'Test user should already be in the id cache.'
);
$this->assertSame(
@@ -1625,13 +1625,13 @@ class UserTest extends MediaWikiIntegrationTestCase {
* @covers User::idFromName
*/
public function testNonExistingIdFromName() {
- $this->assertFalse(
- array_key_exists( 'NotExisitngUser', User::$idCacheByName ),
+ $this->assertArrayNotHasKey(
+ 'NotExisitngUser', User::$idCacheByName,
'Non exisitng user should not be in the id cache.'
);
$this->assertNull( User::idFromName( 'NotExisitngUser' ) );
- $this->assertTrue(
- array_key_exists( 'NotExisitngUser', User::$idCacheByName ),
+ $this->assertArrayHasKey(
+ 'NotExisitngUser', User::$idCacheByName,
'Username will be cached when requested once.'
);
$this->assertNull( User::idFromName( 'NotExistingUser' ) );
diff --git a/tests/phpunit/integration/includes/block/DatabaseBlockStoreTest.php b/tests/phpunit/integration/includes/block/DatabaseBlockStoreTest.php
index 9beeee884a26..a834d53c084b 100644
--- a/tests/phpunit/integration/includes/block/DatabaseBlockStoreTest.php
+++ b/tests/phpunit/integration/includes/block/DatabaseBlockStoreTest.php
@@ -138,7 +138,7 @@ class DatabaseBlockStoreTest extends MediaWikiIntegrationTestCase {
$this->assertIsArray( $result );
$this->assertArrayHasKey( 'id', $result );
$this->assertArrayHasKey( 'autoIds', $result );
- $this->assertSame( 0, count( $result['autoIds'] ) );
+ $this->assertCount( 0, $result['autoIds'] );
$retrievedBlock = DatabaseBlock::newFromId( $result['id'] );
$this->assertTrue( $block->equals( $retrievedBlock ) );
diff --git a/tests/phpunit/languages/LanguageConverterTest.php b/tests/phpunit/languages/LanguageConverterTest.php
index 83a68ac73671..45d47f72bb65 100644
--- a/tests/phpunit/languages/LanguageConverterTest.php
+++ b/tests/phpunit/languages/LanguageConverterTest.php
@@ -195,8 +195,8 @@ class LanguageConverterTest extends MediaWikiLangTestCase {
$this->setIniSetting( 'pcre.backtrack_limit', 200 );
$result = $this->lc->autoConvert( $testString, 'tg-latn' );
// The в in the id attribute should not get converted to a v
- $this->assertFalse(
- strpos( $result, 'v' ),
+ $this->assertStringNotContainsString(
+ $result, 'v',
"в converted to v despite being in attribue"
);
}
diff --git a/tests/phpunit/maintenance/backupPrefetchTest.php b/tests/phpunit/maintenance/backupPrefetchTest.php
index 0978f45a7c1c..79e912d833ca 100644
--- a/tests/phpunit/maintenance/backupPrefetchTest.php
+++ b/tests/phpunit/maintenance/backupPrefetchTest.php
@@ -284,7 +284,7 @@ class BaseDumpTest extends MediaWikiIntegrationTestCase {
// Putting together the content of the prefetch files
$content = $header;
foreach ( $requested_pages as $i ) {
- $this->assertTrue( array_key_exists( $i, $available_pages ),
+ $this->assertArrayHasKey( $i, $available_pages,
"Check for availability of requested page " . $i );
$content .= $available_pages[$i];
}
diff --git a/tests/phpunit/structure/RestStructureTest.php b/tests/phpunit/structure/RestStructureTest.php
index f17a45576372..8da8b9668463 100644
--- a/tests/phpunit/structure/RestStructureTest.php
+++ b/tests/phpunit/structure/RestStructureTest.php
@@ -173,7 +173,7 @@ class RestStructureTest extends MediaWikiIntegrationTestCase {
foreach ( $method as $m ) {
$key = "{$m} {$spec['path']}";
- $this->assertFalse( array_key_exists( $key, $routes ), "{$key} already exists in routes" );
+ $this->assertArrayNotHasKey( $key, $routes, "{$key} already exists in routes" );
$routes[$key] = true;
}
diff --git a/tests/phpunit/unit/includes/HookContainer/HookContainerTest.php b/tests/phpunit/unit/includes/HookContainer/HookContainerTest.php
index 9eab015b97c7..8d264eaf89de 100644
--- a/tests/phpunit/unit/includes/HookContainer/HookContainerTest.php
+++ b/tests/phpunit/unit/includes/HookContainer/HookContainerTest.php
@@ -218,7 +218,7 @@ namespace MediaWiki\HookContainer {
// handlers registered in 2 different ways
$this->assertCount( 2, $hookContainer->getLegacyHandlers( 'MWTestHook' ) );
$hookContainer->run( 'MWTestHook' );
- $this->assertEquals( $numCalls, 2 );
+ $this->assertEquals( 2, $numCalls );
// Remove one of the handlers that increments $called
ScopedCallback::consume( $reset );
@@ -226,7 +226,7 @@ namespace MediaWiki\HookContainer {
$numCalls = 0;
$hookContainer->run( 'MWTestHook' );
- $this->assertEquals( $numCalls, 1 );
+ $this->assertSame( 1, $numCalls );
}
/**
diff --git a/tests/phpunit/unit/includes/Rest/Validator/JsonBodyValidatorTest.php b/tests/phpunit/unit/includes/Rest/Validator/JsonBodyValidatorTest.php
index f8b8edb31f40..7cb2ec219dd3 100644
--- a/tests/phpunit/unit/includes/Rest/Validator/JsonBodyValidatorTest.php
+++ b/tests/phpunit/unit/includes/Rest/Validator/JsonBodyValidatorTest.php
@@ -16,7 +16,7 @@ class JsonBodyValidatorTest extends \MediaWikiUnitTestCase {
public function provideValidateBody() {
yield 'empty object' => [
[],
- $request = new RequestData( [
+ new RequestData( [
'bodyContents' => json_encode( (object)[] ),
] ),
[]
@@ -24,7 +24,7 @@ class JsonBodyValidatorTest extends \MediaWikiUnitTestCase {
yield 'extra data' => [
[],
- $request = new RequestData( [
+ new RequestData( [
'bodyContents' => json_encode( (object)[
'kittens' => 'cute',
'number' => 5,
@@ -43,7 +43,7 @@ class JsonBodyValidatorTest extends \MediaWikiUnitTestCase {
ParamValidator::PARAM_REQUIRED => false,
]
],
- $request = new RequestData( [
+ new RequestData( [
'bodyContents' => json_encode( (object)[
'kittens' => 'cute',
] ),
@@ -62,7 +62,7 @@ class JsonBodyValidatorTest extends \MediaWikiUnitTestCase {
ParamValidator::PARAM_DEFAULT => 10,
]
],
- $request = new RequestData( [
+ new RequestData( [
'bodyContents' => json_encode( (object)[] ),
] ),
[
@@ -83,7 +83,7 @@ class JsonBodyValidatorTest extends \MediaWikiUnitTestCase {
public function provideValidateBody_failure() {
yield 'empty body' => [
[],
- $request = new RequestData( [
+ new RequestData( [
'bodyContents' => '',
] ),
new LocalizedHttpException( new MessageValue( 'rest-json-body-parse-error' ), 400 ),
@@ -91,7 +91,7 @@ class JsonBodyValidatorTest extends \MediaWikiUnitTestCase {
yield 'bad syntax' => [
[],
- $request = new RequestData( [
+ new RequestData( [
'bodyContents' => '.....',
] ),
new LocalizedHttpException( new MessageValue( 'rest-json-body-parse-error' ), 400 ),
@@ -99,7 +99,7 @@ class JsonBodyValidatorTest extends \MediaWikiUnitTestCase {
yield 'not an object' => [
[],
- $request = new RequestData( [
+ new RequestData( [
'bodyContents' => json_encode( 'evil' ),
] ),
new LocalizedHttpException( new MessageValue( 'rest-bad-json-body' ), 400 ),
@@ -112,7 +112,7 @@ class JsonBodyValidatorTest extends \MediaWikiUnitTestCase {
ParamValidator::PARAM_REQUIRED => true,
]
],
- $request = new RequestData( [
+ new RequestData( [
'bodyContents' => json_encode( (object)[
'kittens' => 'cute',
] ),
diff --git a/tests/phpunit/unit/includes/libs/XhprofDataTest.php b/tests/phpunit/unit/includes/libs/XhprofDataTest.php
index d04cc244d6ae..81e189e60f41 100644
--- a/tests/phpunit/unit/includes/libs/XhprofDataTest.php
+++ b/tests/phpunit/unit/includes/libs/XhprofDataTest.php
@@ -177,7 +177,7 @@ class XhprofDataTest extends PHPUnit\Framework\TestCase {
$this->assertSame( $last, $func );
$last = $call;
}
- $this->assertSame( $last, 'bar@1' );
+ $this->assertSame( 'bar@1', $last );
}
/**
diff --git a/tests/phpunit/unit/includes/libs/XhprofTest.php b/tests/phpunit/unit/includes/libs/XhprofTest.php
index 63c9af2a0272..f18989fcac15 100644
--- a/tests/phpunit/unit/includes/libs/XhprofTest.php
+++ b/tests/phpunit/unit/includes/libs/XhprofTest.php
@@ -97,17 +97,32 @@ class XhprofTest extends PHPUnit\Framework\TestCase {
}
}
-/** Test function #1 for XhprofTest::testCallAny */
+/**
+ * Test function #1 for XhprofTest::testCallAny
+ * @param int $a
+ * @param int $b
+ * @return int
+ */
function wfTestCallAny_func1( $a, $b ) {
return $a * $b;
}
-/** Test function #2 for XhprofTest::testCallAny */
+/**
+ * Test function #2 for XhprofTest::testCallAny
+ * @param int $a
+ * @param int $b
+ * @return int
+ */
function wfTestCallAny_func2( $a, $b ) {
return $a + $b;
}
-/** Test function #3 for XhprofTest::testCallAny */
+/**
+ * Test function #3 for XhprofTest::testCallAny
+ * @param int $a
+ * @param int $b
+ * @return int
+ */
function wfTestCallAny_func3( $a, $b ) {
return $a - $b;
}
diff --git a/tests/phpunit/unit/includes/libs/objectcache/WANObjectCacheTest.php b/tests/phpunit/unit/includes/libs/objectcache/WANObjectCacheTest.php
index 48a4f3185a9a..a754dadaae81 100644
--- a/tests/phpunit/unit/includes/libs/objectcache/WANObjectCacheTest.php
+++ b/tests/phpunit/unit/includes/libs/objectcache/WANObjectCacheTest.php
@@ -905,9 +905,9 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase {
$preemptiveRefresh = ( $expiring || $popular );
$v = $cache->getMultiWithSetCallback( $keyedIds, 30, $genFunc );
$this->assertSame( 0, $wasSet, "No values generated" );
- $this->assertSame(
+ $this->assertCount(
$preemptiveRefresh ? count( $idsByKey ) : 0,
- count( $deferredCbs ),
+ $deferredCbs,
"Deferred callbacks queued"
);
foreach ( $idsByKey as $key => $id ) {
@@ -1153,9 +1153,9 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase {
$preemptiveRefresh = ( $expiring || $popular );
$v = $cache->getMultiWithUnionSetCallback( $keyedIds, 30, $genFunc );
$this->assertSame( count( $idsByKey ), $wasSet, "Deferred callbacks did not run yet" );
- $this->assertSame(
+ $this->assertCount(
$preemptiveRefresh ? count( $idsByKey ) : 0,
- count( $deferredCbs ),
+ $deferredCbs,
"Deferred callbacks queued"
);
foreach ( $idsByKey as $key => $id ) {