diff --git a/.phpcs.xml b/.phpcs.xml index 4aacd668423..4bfb84b4cc8 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -9,7 +9,10 @@ + + + diff --git a/composer.json b/composer.json index 67dad3225be..af0659bafff 100644 --- a/composer.json +++ b/composer.json @@ -73,7 +73,7 @@ "jakub-onderka/php-parallel-lint": "0.9.2", "johnkary/phpunit-speedtrap": "^3.1", "justinrainbow/json-schema": "~5.2", - "mediawiki/mediawiki-codesniffer": "30.0.0", + "mediawiki/mediawiki-codesniffer": "31.0.0", "mediawiki/mediawiki-phan-config": "0.10.2", "monolog/monolog": "~1.25.3", "nikic/php-parser": "4.4.0", @@ -117,7 +117,7 @@ "scripts": { "lint": "parallel-lint --exclude vendor", "phpcs": "phpcs -p -s", - "fix": "phpcbf", + "fix": "phpcbf -p", "pre-install-cmd": "ComposerHookHandler::onPreInstall", "pre-update-cmd": "ComposerHookHandler::onPreUpdate", "post-install-cmd": "ComposerVendorHtaccessCreator::onEvent", diff --git a/includes/FormOptions.php b/includes/FormOptions.php index 56a17e29a15..6ce4ead67ea 100644 --- a/includes/FormOptions.php +++ b/includes/FormOptions.php @@ -421,5 +421,6 @@ class FormOptions implements ArrayAccess { public function offsetUnset( $name ) { $this->delete( $name ); } + /* @} */ } diff --git a/includes/changes/FeedItem.php b/includes/changes/FeedItem.php index 8df3a2b090b..cb3f9e67e64 100644 --- a/includes/changes/FeedItem.php +++ b/includes/changes/FeedItem.php @@ -220,5 +220,6 @@ class FeedItem { public static function stripComment( $text ) { return preg_replace( '/\[\[([^]]*\|)?([^]]+)\]\]/', '\2', $text ); } + /** #@- */ } diff --git a/includes/content/Content.php b/includes/content/Content.php index 1d14687c4fd..19519e901f6 100644 --- a/includes/content/Content.php +++ b/includes/content/Content.php @@ -524,6 +524,7 @@ interface Content { * that conversion is not supported. */ public function convert( $toModel, $lossy = '' ); + // @todo ImagePage and CategoryPage interfere with per-content action handlers // @todo nice&sane integration of GeSHi syntax highlighting // [11:59] Hooks are ugly; make CodeHighlighter interface and a diff --git a/includes/specials/SpecialEditPage.php b/includes/specials/SpecialEditPage.php index 7c35c95d635..4d8a430e0de 100644 --- a/includes/specials/SpecialEditPage.php +++ b/includes/specials/SpecialEditPage.php @@ -25,6 +25,7 @@ class SpecialEditPage extends SpecialRedirectWithAction { public function __construct() { parent::__construct( 'EditPage', 'edit', 'editpage' ); } + // Messages, for grep: // specialeditpage-page // specialeditpage-submit diff --git a/includes/specials/SpecialPageHistory.php b/includes/specials/SpecialPageHistory.php index ed810126f98..5b34ec9fd7e 100644 --- a/includes/specials/SpecialPageHistory.php +++ b/includes/specials/SpecialPageHistory.php @@ -25,6 +25,7 @@ class SpecialPageHistory extends SpecialRedirectWithAction { public function __construct() { parent::__construct( 'PageHistory', 'history', 'pagehistory' ); } + // Messages, for grep: // specialpagehistory-page // specialpagehistory-submit diff --git a/includes/specials/SpecialPageInfo.php b/includes/specials/SpecialPageInfo.php index ada3856ecd6..1fffbb604aa 100644 --- a/includes/specials/SpecialPageInfo.php +++ b/includes/specials/SpecialPageInfo.php @@ -25,6 +25,7 @@ class SpecialPageInfo extends SpecialRedirectWithAction { public function __construct() { parent::__construct( 'PageInfo', 'info', 'pageinfo' ); } + // Messages, for grep: // specialpageinfo-page // specialpageinfo-submit diff --git a/includes/specials/SpecialPurge.php b/includes/specials/SpecialPurge.php index f1a315600d8..a93fa4ffb3c 100644 --- a/includes/specials/SpecialPurge.php +++ b/includes/specials/SpecialPurge.php @@ -25,6 +25,7 @@ class SpecialPurge extends SpecialRedirectWithAction { public function __construct() { parent::__construct( 'Purge', 'purge', 'purge' ); } + // Messages, for grep: // specialpurge-page // specialpurge-submit diff --git a/languages/classes/LanguageKaa.php b/languages/classes/LanguageKaa.php index 0d024d99d42..2442bd232db 100644 --- a/languages/classes/LanguageKaa.php +++ b/languages/classes/LanguageKaa.php @@ -30,6 +30,7 @@ class LanguageKaa extends Language { # Convert from the nominative form of a noun to some other case # Invoked with {{GRAMMAR:case|word}} + /** * Cases: genitive, dative, accusative, locative, ablative, comitative + possessive forms * diff --git a/languages/classes/LanguageKk_cyrl.php b/languages/classes/LanguageKk_cyrl.php index 963b8e3bd90..8a89b4a9d5b 100644 --- a/languages/classes/LanguageKk_cyrl.php +++ b/languages/classes/LanguageKk_cyrl.php @@ -30,6 +30,7 @@ class LanguageKk_cyrl extends Language { # Convert from the nominative form of a noun to some other case # Invoked with {{GRAMMAR:case|word}} + /** * Cases: genitive, dative, accusative, locative, ablative, comitative + possessive forms * diff --git a/languages/classes/LanguageSl.php b/languages/classes/LanguageSl.php index 6ffdb97d86a..f3ccf8e4c8c 100644 --- a/languages/classes/LanguageSl.php +++ b/languages/classes/LanguageSl.php @@ -29,6 +29,7 @@ class LanguageSl extends Language { # Convert from the nominative form of a noun to some other case # Invoked with {{GRAMMAR:case|word}} + /** * Cases: rodilnik, dajalnik, tožilnik, mestnik, orodnik * diff --git a/languages/converters/ZhConverter.php b/languages/converters/ZhConverter.php index 4f3a88f8883..11e596546e4 100644 --- a/languages/converters/ZhConverter.php +++ b/languages/converters/ZhConverter.php @@ -121,5 +121,5 @@ class ZhConverter extends LanguageConverter { */ public function convertCategoryKey( $key ) { return $this->autoConvert( $key, 'zh' ); - } + } } diff --git a/tests/phpunit/includes/CategoryTest.php b/tests/phpunit/includes/CategoryTest.php index ddacf0dc1d7..ab484576dea 100644 --- a/tests/phpunit/includes/CategoryTest.php +++ b/tests/phpunit/includes/CategoryTest.php @@ -136,7 +136,7 @@ class CategoryTest extends MediaWikiTestCase { __METHOD__ ) ); - $this->assertEquals( 1, $category->getID() ); + $this->assertSame( '1', $category->getID() ); $dbw->delete( 'category', '*', __METHOD__ ); } diff --git a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php index e6461cd13dd..19bf3985f41 100644 --- a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php +++ b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php @@ -729,5 +729,6 @@ class GlobalTest extends MediaWikiTestCase { ], ]; } + /* @todo many more! */ } diff --git a/tests/phpunit/includes/HooksTest.php b/tests/phpunit/includes/HooksTest.php index 205afc9fb07..5a6a56a65e1 100644 --- a/tests/phpunit/includes/HooksTest.php +++ b/tests/phpunit/includes/HooksTest.php @@ -140,12 +140,12 @@ class HooksTest extends MediaWikiTestCase { $bar = 'qaax'; Hooks::run( 'MediaWikiHooksTest001', [ &$foo, &$bar ] ); - $this->assertEquals( + $this->assertSame( 1, $a->calls, 'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register' ); - $this->assertEquals( + $this->assertSame( 1, $b->calls, 'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register' diff --git a/tests/phpunit/includes/MediaWikiServicesTest.php b/tests/phpunit/includes/MediaWikiServicesTest.php index c8a4f43e5a5..c47ac01ba58 100644 --- a/tests/phpunit/includes/MediaWikiServicesTest.php +++ b/tests/phpunit/includes/MediaWikiServicesTest.php @@ -230,7 +230,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase { $this->assertSame( 0, $serviceCounter, 'No service instance should be created yet.' ); $oldInstance = $services->getService( 'Test' ); - $this->assertEquals( 1, $serviceCounter, 'A service instance should exit now.' ); + $this->assertSame( 1, $serviceCounter, 'A service instance should exit now.' ); // The old instance should be detached, and destroy() called. $services->resetServiceForTesting( 'Test' ); diff --git a/tests/phpunit/includes/SiteStatsTest.php b/tests/phpunit/includes/SiteStatsTest.php index d45ae2613ef..a70124cba41 100644 --- a/tests/phpunit/includes/SiteStatsTest.php +++ b/tests/phpunit/includes/SiteStatsTest.php @@ -11,11 +11,11 @@ class SiteStatsTest extends MediaWikiTestCase { $jobq = JobQueueGroup::singleton(); $jobq->push( Job::factory( 'null', Title::newMainPage(), [] ) ); - $this->assertEquals( 1, SiteStats::jobs(), + $this->assertSame( 1, SiteStats::jobs(), 'A single job enqueued bumps jobscount stat to 1' ); $jobq->push( Job::factory( 'null', Title::newMainPage(), [] ) ); - $this->assertEquals( 1, SiteStats::jobs(), + $this->assertSame( 1, SiteStats::jobs(), 'SiteStats::jobs() count does not reflect addition ' . 'of a second job (cached)' ); @@ -25,7 +25,7 @@ class SiteStatsTest extends MediaWikiTestCase { 'Job queue for NullJob has been cleaned' ); $cache->delete( $cache->makeKey( 'SiteStats', 'jobscount' ) ); - $this->assertEquals( 1, SiteStats::jobs(), + $this->assertSame( 1, SiteStats::jobs(), 'jobs count is kept in process cache' ); $cache->clearProcessCache(); diff --git a/tests/phpunit/includes/block/BlockRestrictionStoreTest.php b/tests/phpunit/includes/block/BlockRestrictionStoreTest.php index c79a9309a80..b32177a2f4f 100644 --- a/tests/phpunit/includes/block/BlockRestrictionStoreTest.php +++ b/tests/phpunit/includes/block/BlockRestrictionStoreTest.php @@ -259,7 +259,7 @@ class BlockRestrictionStoreTest extends \MediaWikiLangTestCase { [ 'ir_ipb_id' => $block->getId() ] ); - $this->assertEquals( 1, $result->numRows() ); + $this->assertSame( 1, $result->numRows() ); $row = $result->fetchObject(); $this->assertEquals( $block->getId(), $row->ir_ipb_id ); $this->assertEquals( $page->getId(), $row->ir_value ); @@ -308,7 +308,7 @@ class BlockRestrictionStoreTest extends \MediaWikiLangTestCase { [ 'ir_ipb_id' => $block->getId() ] ); - $this->assertEquals( 1, $result->numRows() ); + $this->assertSame( 1, $result->numRows() ); $row = $result->fetchObject(); $this->assertEquals( $block->getId(), $row->ir_ipb_id ); $this->assertEquals( $page->getId(), $row->ir_value ); diff --git a/tests/phpunit/includes/changes/CategoryMembershipChangeTest.php b/tests/phpunit/includes/changes/CategoryMembershipChangeTest.php index a6a2b32f876..164fe54e011 100644 --- a/tests/phpunit/includes/changes/CategoryMembershipChangeTest.php +++ b/tests/phpunit/includes/changes/CategoryMembershipChangeTest.php @@ -78,7 +78,7 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase { $change = $this->newChange(); $change->triggerCategoryAddedNotification( Title::newFromText( 'CategoryName', NS_CATEGORY ) ); - $this->assertEquals( 1, self::$notifyCallCounter ); + $this->assertSame( 1, self::$notifyCallCounter ); $this->assertTrue( strlen( self::$lastNotifyArgs[0] ) === 14 ); $this->assertEquals( 'Category:CategoryName', self::$lastNotifyArgs[1]->getPrefixedText() ); @@ -89,7 +89,7 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase { $this->assertSame( 0, self::$lastNotifyArgs[5] ); $this->assertSame( 0, self::$lastNotifyArgs[6] ); $this->assertNull( self::$lastNotifyArgs[7] ); - $this->assertEquals( 1, self::$lastNotifyArgs[8] ); + $this->assertSame( 1, self::$lastNotifyArgs[8] ); $this->assertSame( '', self::$lastNotifyArgs[9] ); $this->assertSame( 0, self::$lastNotifyArgs[10] ); } @@ -98,7 +98,7 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase { $change = $this->newChange(); $change->triggerCategoryRemovedNotification( Title::newFromText( 'CategoryName', NS_CATEGORY ) ); - $this->assertEquals( 1, self::$notifyCallCounter ); + $this->assertSame( 1, self::$notifyCallCounter ); $this->assertTrue( strlen( self::$lastNotifyArgs[0] ) === 14 ); $this->assertEquals( 'Category:CategoryName', self::$lastNotifyArgs[1]->getPrefixedText() ); @@ -109,7 +109,7 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase { $this->assertSame( 0, self::$lastNotifyArgs[5] ); $this->assertSame( 0, self::$lastNotifyArgs[6] ); $this->assertNull( self::$lastNotifyArgs[7] ); - $this->assertEquals( 1, self::$lastNotifyArgs[8] ); + $this->assertSame( 1, self::$lastNotifyArgs[8] ); $this->assertSame( '', self::$lastNotifyArgs[9] ); $this->assertSame( 0, self::$lastNotifyArgs[10] ); } @@ -121,7 +121,7 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase { $change = $this->newChange( $revision ); $change->triggerCategoryAddedNotification( Title::newFromText( 'CategoryName', NS_CATEGORY ) ); - $this->assertEquals( 1, self::$notifyCallCounter ); + $this->assertSame( 1, self::$notifyCallCounter ); $this->assertTrue( strlen( self::$lastNotifyArgs[0] ) === 14 ); $this->assertEquals( 'Category:CategoryName', self::$lastNotifyArgs[1]->getPrefixedText() ); @@ -144,7 +144,7 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase { $change = $this->newChange( $revision ); $change->triggerCategoryRemovedNotification( Title::newFromText( 'CategoryName', NS_CATEGORY ) ); - $this->assertEquals( 1, self::$notifyCallCounter ); + $this->assertSame( 1, self::$notifyCallCounter ); $this->assertTrue( strlen( self::$lastNotifyArgs[0] ) === 14 ); $this->assertEquals( 'Category:CategoryName', self::$lastNotifyArgs[1]->getPrefixedText() ); diff --git a/tests/phpunit/includes/db/LBFactoryTest.php b/tests/phpunit/includes/db/LBFactoryTest.php index 2a34a02141d..17034102f85 100644 --- a/tests/phpunit/includes/db/LBFactoryTest.php +++ b/tests/phpunit/includes/db/LBFactoryTest.php @@ -161,7 +161,7 @@ class LBFactoryTest extends MediaWikiTestCase { $factory = $this->newLBFactoryMultiLBs(); $this->assertSame( 0, $countLBsFunc( $factory ) ); $dbw = $factory->getMainLB()->getConnection( DB_MASTER ); - $this->assertEquals( 1, $countLBsFunc( $factory ) ); + $this->assertSame( 1, $countLBsFunc( $factory ) ); // Test that LoadBalancer instances made during pre-commit callbacks in do not // throw DBTransactionError due to transaction ROUND_* stages being mismatched. $factory->beginMasterChanges( __METHOD__ ); @@ -173,7 +173,7 @@ class LBFactoryTest extends MediaWikiTestCase { $factory->getMainLB( 's1wiki' )->getConnection( DB_MASTER ); } ); $factory->commitMasterChanges( __METHOD__ ); - $this->assertEquals( 1, $called ); + $this->assertSame( 1, $called ); $this->assertEquals( 2, $countLBsFunc( $factory ) ); $factory->shutdown(); $factory->closeAll(); @@ -182,7 +182,7 @@ class LBFactoryTest extends MediaWikiTestCase { $factory = $this->newLBFactoryMultiLBs(); $this->assertSame( 0, $countLBsFunc( $factory ) ); $dbw = $factory->getMainLB()->getConnection( DB_MASTER ); - $this->assertEquals( 1, $countLBsFunc( $factory ) ); + $this->assertSame( 1, $countLBsFunc( $factory ) ); // Test that LoadBalancer instances made during pre-commit callbacks in do not // throw DBTransactionError due to transaction ROUND_* stages being mismatched.hrow // DBTransactionError due to transaction ROUND_* stages being mismatched. @@ -196,7 +196,7 @@ class LBFactoryTest extends MediaWikiTestCase { $factory->getMainLB( 's1wiki' )->getConnection( DB_MASTER ); } ); $factory->commitMasterChanges( __METHOD__ ); - $this->assertEquals( 1, $called ); + $this->assertSame( 1, $called ); $this->assertEquals( 2, $countLBsFunc( $factory ) ); $factory->shutdown(); $factory->closeAll(); @@ -209,7 +209,7 @@ class LBFactoryTest extends MediaWikiTestCase { ++$ran; } ); $factory->commitAll( __METHOD__ ); - $this->assertEquals( 1, $ran ); + $this->assertSame( 1, $ran ); $factory->shutdown(); $factory->closeAll(); @@ -341,7 +341,7 @@ class LBFactoryTest extends MediaWikiTestCase { $cpIndex = null; $cp->shutdown( null, 'sync', $cpIndex ); - $this->assertEquals( 1, $cpIndex, "CP write index set" ); + $this->assertSame( 1, $cpIndex, "CP write index set" ); // (b) Second HTTP request diff --git a/tests/phpunit/includes/db/LoadBalancerTest.php b/tests/phpunit/includes/db/LoadBalancerTest.php index b3512a3ce0c..1e442e05440 100644 --- a/tests/phpunit/includes/db/LoadBalancerTest.php +++ b/tests/phpunit/includes/db/LoadBalancerTest.php @@ -73,7 +73,7 @@ class LoadBalancerTest extends MediaWikiTestCase { } ] ); - $this->assertEquals( 1, $lb->getServerCount() ); + $this->assertSame( 1, $lb->getServerCount() ); $this->assertFalse( $lb->hasReplicaServers() ); $this->assertFalse( $lb->hasStreamingReplicaServers() ); diff --git a/tests/phpunit/includes/deferred/DeferredUpdatesTest.php b/tests/phpunit/includes/deferred/DeferredUpdatesTest.php index 4ef4b356e84..8c402949f43 100644 --- a/tests/phpunit/includes/deferred/DeferredUpdatesTest.php +++ b/tests/phpunit/includes/deferred/DeferredUpdatesTest.php @@ -363,7 +363,7 @@ class DeferredUpdatesTest extends MediaWikiTestCase { $this->assertEquals( [], $calls ); $calls[] = 'oti'; } ); - $this->assertEquals( 1, $dbw->trxLevel() ); + $this->assertSame( 1, $dbw->trxLevel() ); $this->assertEquals( [], $calls ); $lbFactory->commitMasterChanges( __METHOD__ ); diff --git a/tests/phpunit/includes/deferred/SiteStatsUpdateTest.php b/tests/phpunit/includes/deferred/SiteStatsUpdateTest.php index f820f60346b..988f7d403c3 100644 --- a/tests/phpunit/includes/deferred/SiteStatsUpdateTest.php +++ b/tests/phpunit/includes/deferred/SiteStatsUpdateTest.php @@ -17,9 +17,9 @@ class SiteStatsUpdateTest extends MediaWikiTestCase { $update1->merge( $update2 ); $wrapped = TestingAccessWrapper::newFromObject( $update1 ); - $this->assertEquals( 1, $wrapped->pages ); + $this->assertSame( 1, $wrapped->pages ); $this->assertEquals( 3, $wrapped->users ); - $this->assertEquals( 1, $wrapped->images ); + $this->assertSame( 1, $wrapped->images ); $this->assertSame( 0, $wrapped->edits ); $this->assertSame( 0, $wrapped->articles ); } @@ -49,7 +49,7 @@ class SiteStatsUpdateTest extends MediaWikiTestCase { DeferredUpdates::addUpdate( SiteStatsUpdate::factory( [ 'pages' => 2, 'images' => 1, 'edits' => 2 ] ) ); - $this->assertEquals( 1, DeferredUpdates::pendingUpdatesCount() ); + $this->assertSame( 1, DeferredUpdates::pendingUpdatesCount() ); // Still the same SiteStats::unload(); @@ -58,11 +58,11 @@ class SiteStatsUpdateTest extends MediaWikiTestCase { $this->assertEquals( $ui, SiteStats::users(), 'user count' ); $this->assertEquals( $fi, SiteStats::images(), 'file count' ); $this->assertEquals( $ai, SiteStats::articles(), 'article count' ); - $this->assertEquals( 1, DeferredUpdates::pendingUpdatesCount() ); + $this->assertSame( 1, DeferredUpdates::pendingUpdatesCount() ); $dbw->commit( __METHOD__ ); - $this->assertEquals( 1, DeferredUpdates::pendingUpdatesCount() ); + $this->assertSame( 1, DeferredUpdates::pendingUpdatesCount() ); DeferredUpdates::doUpdates(); $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount() ); diff --git a/tests/phpunit/includes/filebackend/FileBackendIntegrationTest.php b/tests/phpunit/includes/filebackend/FileBackendIntegrationTest.php index b98a999345c..1552ad0c86d 100644 --- a/tests/phpunit/includes/filebackend/FileBackendIntegrationTest.php +++ b/tests/phpunit/includes/filebackend/FileBackendIntegrationTest.php @@ -2503,7 +2503,7 @@ class FileBackendIntegrationTest extends MediaWikiIntegrationTestCase { ] ) ); - $this->assertEquals( + $this->assertSame( 1, $be->getReadIndexFromParams( [ 'latest' => 1 ] ), 'Reads with "latest" flag use backend 1' diff --git a/tests/phpunit/includes/jobqueue/JobQueueTest.php b/tests/phpunit/includes/jobqueue/JobQueueTest.php index c4e79b0d59d..af7d57d01b3 100644 --- a/tests/phpunit/includes/jobqueue/JobQueueTest.php +++ b/tests/phpunit/includes/jobqueue/JobQueueTest.php @@ -128,11 +128,11 @@ class JobQueueTest extends MediaWikiTestCase { $this->assertFalse( $queue->isEmpty(), "Queue is not empty ($desc)" ); $queue->flushCaches(); - $this->assertEquals( 1, $queue->getSize(), "Queue size is correct ($desc)" ); + $this->assertSame( 1, $queue->getSize(), "Queue size is correct ($desc)" ); $queue->flushCaches(); if ( $recycles ) { - $this->assertEquals( 1, $queue->getAcquiredCount(), "Active job count ($desc)" ); + $this->assertSame( 1, $queue->getAcquiredCount(), "Active job count ($desc)" ); } $job2 = $queue->pop(); @@ -148,7 +148,7 @@ class JobQueueTest extends MediaWikiTestCase { $queue->flushCaches(); if ( $recycles ) { - $this->assertEquals( 1, $queue->getAcquiredCount(), "Active job count ($desc)" ); + $this->assertSame( 1, $queue->getAcquiredCount(), "Active job count ($desc)" ); } $queue->ack( $job2 ); @@ -191,7 +191,7 @@ class JobQueueTest extends MediaWikiTestCase { $this->assertFalse( $queue->isEmpty(), "Queue is not empty ($desc)" ); $queue->flushCaches(); - $this->assertEquals( 1, $queue->getSize(), "Queue size is correct ($desc)" ); + $this->assertSame( 1, $queue->getSize(), "Queue size is correct ($desc)" ); $this->assertSame( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" ); $this->assertNull( @@ -204,7 +204,7 @@ class JobQueueTest extends MediaWikiTestCase { $this->assertFalse( $queue->isEmpty(), "Queue is not empty ($desc)" ); $queue->flushCaches(); - $this->assertEquals( 1, $queue->getSize(), "Queue size is correct ($desc)" ); + $this->assertSame( 1, $queue->getSize(), "Queue size is correct ($desc)" ); $this->assertSame( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" ); $job1 = $queue->pop(); @@ -213,7 +213,7 @@ class JobQueueTest extends MediaWikiTestCase { $queue->flushCaches(); $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" ); if ( $recycles ) { - $this->assertEquals( 1, $queue->getAcquiredCount(), "Active job count ($desc)" ); + $this->assertSame( 1, $queue->getAcquiredCount(), "Active job count ($desc)" ); } $queue->ack( $job1 ); diff --git a/tests/phpunit/includes/jobqueue/jobs/ClearUserWatchlistJobTest.php b/tests/phpunit/includes/jobqueue/jobs/ClearUserWatchlistJobTest.php index 470f942aedd..4ff902623f3 100644 --- a/tests/phpunit/includes/jobqueue/jobs/ClearUserWatchlistJobTest.php +++ b/tests/phpunit/includes/jobqueue/jobs/ClearUserWatchlistJobTest.php @@ -57,13 +57,13 @@ class ClearUserWatchlistJobTest extends MediaWikiTestCase { ] ) ); - $this->assertEquals( 1, JobQueueGroup::singleton()->getQueueSizes()['clearUserWatchlist'] ); + $this->assertSame( 1, JobQueueGroup::singleton()->getQueueSizes()['clearUserWatchlist'] ); $this->assertEquals( 6, $watchedItemStore->countWatchedItems( $user ) ); $this->runJobs( 1 ); - $this->assertEquals( 1, JobQueueGroup::singleton()->getQueueSizes()['clearUserWatchlist'] ); + $this->assertSame( 1, JobQueueGroup::singleton()->getQueueSizes()['clearUserWatchlist'] ); $this->assertEquals( 4, $watchedItemStore->countWatchedItems( $user ) ); $this->runJobs( 1 ); - $this->assertEquals( 1, JobQueueGroup::singleton()->getQueueSizes()['clearUserWatchlist'] ); + $this->assertSame( 1, JobQueueGroup::singleton()->getQueueSizes()['clearUserWatchlist'] ); $this->assertEquals( 2, $watchedItemStore->countWatchedItems( $user ) ); $this->runJobs( 1 ); $this->assertSame( 0, JobQueueGroup::singleton()->getQueueSizes()['clearUserWatchlist'] ); diff --git a/tests/phpunit/includes/libs/objectcache/BagOStuffTest.php b/tests/phpunit/includes/libs/objectcache/BagOStuffTest.php index 1f86c617190..a379cf9b28b 100644 --- a/tests/phpunit/includes/libs/objectcache/BagOStuffTest.php +++ b/tests/phpunit/includes/libs/objectcache/BagOStuffTest.php @@ -106,7 +106,7 @@ class BagOStuffTest extends MediaWikiTestCase { $wrapper = TestingAccessWrapper::newFromObject( $this->cache ); $this->assertEquals( count( $wrapper->caches ), $calls ); } else { - $this->assertEquals( 1, $calls ); + $this->assertSame( 1, $calls ); } } @@ -189,13 +189,13 @@ class BagOStuffTest extends MediaWikiTestCase { $ok = $this->cache->changeTTLMulti( [ $key1, $key2, $key3 ], 300 ); $this->assertTrue( $ok, "TTL bumped for all keys" ); - $this->assertEquals( 1, $this->cache->get( $key1 ) ); + $this->assertSame( 1, $this->cache->get( $key1 ) ); $this->assertEquals( 2, $this->cache->get( $key2 ) ); $this->assertEquals( 3, $this->cache->get( $key3 ) ); $ok = $this->cache->changeTTLMulti( [ $key1, $key2, $key3, $key4 ], 300 ); $this->assertFalse( $ok, "One key missing" ); - $this->assertEquals( 1, $this->cache->get( $key1 ), "Key still live" ); + $this->assertSame( 1, $this->cache->get( $key1 ), "Key still live" ); $now = microtime( true ); // real time $ok = $this->cache->setMulti( [ $key1 => 1, $key2 => 2, $key3 => 3 ] ); @@ -203,7 +203,7 @@ class BagOStuffTest extends MediaWikiTestCase { $ok = $this->cache->changeTTLMulti( [ $key1, $key2, $key3 ], $now + 86400 ); $this->assertTrue( $ok, "Expiry set for all keys" ); - $this->assertEquals( 1, $this->cache->get( $key1 ), "Key still live" ); + $this->assertSame( 1, $this->cache->get( $key1 ), "Key still live" ); $this->assertEquals( 2, $this->cache->incr( $key1 ) ); $this->assertEquals( 3, $this->cache->incr( $key2 ) ); diff --git a/tests/phpunit/includes/libs/objectcache/CachedBagOStuffTest.php b/tests/phpunit/includes/libs/objectcache/CachedBagOStuffTest.php index 8337d786a54..5445e25ec9d 100644 --- a/tests/phpunit/includes/libs/objectcache/CachedBagOStuffTest.php +++ b/tests/phpunit/includes/libs/objectcache/CachedBagOStuffTest.php @@ -34,8 +34,8 @@ class CachedBagOStuffTest extends PHPUnit\Framework\TestCase { for ( $i = 0; $i < 10; $i++ ) { $cache->set( "key$i", 1 ); - $this->assertEquals( 1, $cache->get( "key$i" ) ); - $this->assertEquals( 1, $backend->get( "key$i" ) ); + $this->assertSame( 1, $cache->get( "key$i" ) ); + $this->assertSame( 1, $backend->get( "key$i" ) ); $cache->delete( "key$i" ); $this->assertFalse( $cache->get( "key$i" ) ); diff --git a/tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php b/tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php index 02234f33426..bd5d9e20630 100644 --- a/tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php +++ b/tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php @@ -49,7 +49,7 @@ class HashBagOStuffTest extends PHPUnit\Framework\TestCase { $cache = new HashBagOStuff(); for ( $i = 0; $i < 10; $i++ ) { $cache->set( "key$i", 1 ); - $this->assertEquals( 1, $cache->get( "key$i" ) ); + $this->assertSame( 1, $cache->get( "key$i" ) ); $cache->delete( "key$i" ); $this->assertFalse( $cache->get( "key$i" ) ); } @@ -62,7 +62,7 @@ class HashBagOStuffTest extends PHPUnit\Framework\TestCase { $cache = new HashBagOStuff(); for ( $i = 0; $i < 10; $i++ ) { $cache->set( "key$i", 1 ); - $this->assertEquals( 1, $cache->get( "key$i" ) ); + $this->assertSame( 1, $cache->get( "key$i" ) ); } $cache->clear(); for ( $i = 0; $i < 10; $i++ ) { @@ -96,7 +96,7 @@ class HashBagOStuffTest extends PHPUnit\Framework\TestCase { 'Past' ); - $this->assertEquals( 1, $cache->get( 'bar' ), 'Key not expired' ); + $this->assertSame( 1, $cache->get( 'bar' ), 'Key not expired' ); $this->assertFalse( $cache->get( 'baz' ), 'Key expired' ); } @@ -109,11 +109,11 @@ class HashBagOStuffTest extends PHPUnit\Framework\TestCase { $cache = new HashBagOStuff( [ 'maxKeys' => 10 ] ); for ( $i = 0; $i < 10; $i++ ) { $cache->set( "key$i", 1 ); - $this->assertEquals( 1, $cache->get( "key$i" ) ); + $this->assertSame( 1, $cache->get( "key$i" ) ); } for ( $i = 10; $i < 20; $i++ ) { $cache->set( "key$i", 1 ); - $this->assertEquals( 1, $cache->get( "key$i" ) ); + $this->assertSame( 1, $cache->get( "key$i" ) ); $this->assertFalse( $cache->get( "key" . ( $i - 10 ) ) ); } } @@ -139,7 +139,7 @@ class HashBagOStuffTest extends PHPUnit\Framework\TestCase { // Foo's life should have been extended over Bar foreach ( [ 'foo', 'baz', 'quux' ] as $key ) { - $this->assertEquals( 1, $cache->get( $key ), "Kept $key" ); + $this->assertSame( 1, $cache->get( $key ), "Kept $key" ); } $this->assertFalse( $cache->get( 'bar' ), 'Evicted bar' ); } @@ -165,7 +165,7 @@ class HashBagOStuffTest extends PHPUnit\Framework\TestCase { // Foo's life should have been extended over Bar foreach ( [ 'foo', 'baz', 'quux' ] as $key ) { - $this->assertEquals( 1, $cache->get( $key ), "Kept $key" ); + $this->assertSame( 1, $cache->get( $key ), "Kept $key" ); } $this->assertFalse( $cache->get( 'bar' ), 'Evicted bar' ); } diff --git a/tests/phpunit/includes/libs/rdbms/database/DatabaseSQLTest.php b/tests/phpunit/includes/libs/rdbms/database/DatabaseSQLTest.php index e140368273f..5e72a994b2b 100644 --- a/tests/phpunit/includes/libs/rdbms/database/DatabaseSQLTest.php +++ b/tests/phpunit/includes/libs/rdbms/database/DatabaseSQLTest.php @@ -1982,7 +1982,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->assertNull( $callback1Called ); $this->assertNull( $callback2Called ); $this->assertEquals( IDatabase::TRIGGER_ROLLBACK, $callback3Called ); - $this->assertEquals( 1, $callback4Called ); + $this->assertSame( 1, $callback4Called ); // phpcs:ignore Generic.Files.LineLength $this->assertLastSql( 'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1; SELECT 4; COMMIT; SELECT 3' ); @@ -2003,7 +2003,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->assertNull( $callback1Called ); $this->assertNull( $callback2Called ); $this->assertEquals( IDatabase::TRIGGER_ROLLBACK, $callback3Called ); - $this->assertEquals( 1, $callback4Called ); + $this->assertSame( 1, $callback4Called ); // phpcs:ignore Generic.Files.LineLength $this->assertLastSql( 'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; SAVEPOINT wikimedia_rdbms_atomic2; RELEASE SAVEPOINT wikimedia_rdbms_atomic2; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1; SELECT 4; COMMIT; SELECT 3' ); @@ -2023,7 +2023,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->assertNull( $callback1Called ); $this->assertNull( $callback2Called ); $this->assertEquals( IDatabase::TRIGGER_ROLLBACK, $callback3Called ); - $this->assertEquals( 1, $callback4Called ); + $this->assertSame( 1, $callback4Called ); $callback1Called = null; $callback2Called = null; @@ -2050,7 +2050,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->assertNull( $callback1Called ); $this->assertNull( $callback2Called ); $this->assertEquals( IDatabase::TRIGGER_ROLLBACK, $callback3Called ); - $this->assertEquals( 1, $callback4Called ); + $this->assertSame( 1, $callback4Called ); $callback4Called = 0; $callback5Called = 0; @@ -2065,8 +2065,8 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->database->endAtomic( __METHOD__ . '_outer' ); // phpcs:ignore Generic.Files.LineLength $this->assertLastSql( 'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; SAVEPOINT wikimedia_rdbms_atomic2; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic2; SELECT 4; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1; SELECT 5; COMMIT' ); - $this->assertEquals( 1, $callback4Called ); - $this->assertEquals( 1, $callback5Called ); + $this->assertSame( 1, $callback4Called ); + $this->assertSame( 1, $callback5Called ); $callback4Called = 0; $callback5Called = 0; @@ -2080,8 +2080,8 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->database->endAtomic( __METHOD__ . '_outer' ); // phpcs:ignore Generic.Files.LineLength $this->assertLastSql( 'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; SAVEPOINT wikimedia_rdbms_atomic2; RELEASE SAVEPOINT wikimedia_rdbms_atomic2; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1; SELECT 5; SELECT 4; COMMIT' ); - $this->assertEquals( 1, $callback4Called ); - $this->assertEquals( 1, $callback5Called ); + $this->assertSame( 1, $callback4Called ); + $this->assertSame( 1, $callback5Called ); $callback4Called = 0; $callback5Called = 0; @@ -2094,8 +2094,8 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->database->endAtomic( __METHOD__ . '_outer' ); // phpcs:ignore Generic.Files.LineLength $this->assertLastSql( 'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; SAVEPOINT wikimedia_rdbms_atomic2; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1; SELECT 5; SELECT 4; COMMIT' ); - $this->assertEquals( 1, $callback4Called ); - $this->assertEquals( 1, $callback5Called ); + $this->assertSame( 1, $callback4Called ); + $this->assertSame( 1, $callback5Called ); $wrapper = TestingAccessWrapper::newFromObject( $this->database ); $callback1Called = null; @@ -2116,7 +2116,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->assertNull( $callback1Called ); $this->assertNull( $callback2Called ); $this->assertEquals( IDatabase::TRIGGER_ROLLBACK, $callback3Called ); - $this->assertEquals( 1, $callback4Called ); + $this->assertSame( 1, $callback4Called ); } /** @@ -2454,7 +2454,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { try { $this->database->setFlag( IDatabase::DBO_TRX ); $this->database->delete( 'x', [ 'field' => 3 ], __METHOD__ ); - $this->assertEquals( 1, $this->database->trxLevel() ); + $this->assertSame( 1, $this->database->trxLevel() ); $this->database->close(); $this->fail( 'Expected exception not thrown' ); } catch ( DBUnexpectedError $ex ) { @@ -2476,7 +2476,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { public function testPrematureClose4() { $this->database->setFlag( IDatabase::DBO_TRX ); $this->database->query( 'SELECT 1', __METHOD__ ); - $this->assertEquals( 1, $this->database->trxLevel() ); + $this->assertSame( 1, $this->database->trxLevel() ); $this->database->close(); $this->database->clearFlag( IDatabase::DBO_TRX ); diff --git a/tests/phpunit/includes/libs/rdbms/database/DatabaseTest.php b/tests/phpunit/includes/libs/rdbms/database/DatabaseTest.php index e4a2eaa7d7b..468da39e7b5 100644 --- a/tests/phpunit/includes/libs/rdbms/database/DatabaseTest.php +++ b/tests/phpunit/includes/libs/rdbms/database/DatabaseTest.php @@ -517,7 +517,7 @@ class DatabaseTest extends PHPUnit\Framework\TestCase { $lock = $db->getScopedLockAndFlush( 'meow', __METHOD__, 1 ); $this->fail( "Exception not reached" ); } catch ( DBUnexpectedError $e ) { - $this->assertEquals( 1, $db->trxLevel(), "Transaction not committed." ); + $this->assertSame( 1, $db->trxLevel(), "Transaction not committed." ); $this->assertTrue( $db->lockIsFree( 'meow', __METHOD__ ), 'Lock not acquired' ); } $db->rollback( __METHOD__, IDatabase::FLUSHING_ALL_PEERS ); @@ -531,7 +531,7 @@ class DatabaseTest extends PHPUnit\Framework\TestCase { $lock = $db->getScopedLockAndFlush( 'meow2', __METHOD__, 1 ); $this->fail( "Exception not reached" ); } catch ( DBUnexpectedError $e ) { - $this->assertEquals( 1, $db->trxLevel(), "Transaction not committed." ); + $this->assertSame( 1, $db->trxLevel(), "Transaction not committed." ); $this->assertTrue( $db->lockIsFree( 'meow2', __METHOD__ ), 'Lock not acquired' ); } $db->rollback( __METHOD__ ); @@ -540,7 +540,7 @@ class DatabaseTest extends PHPUnit\Framework\TestCase { $this->assertSame( 0, $db->trxLevel() ); $this->assertTrue( $db->lockIsFree( 'wuff', __METHOD__ ) ); $db->query( "SELECT 1", __METHOD__ ); - $this->assertEquals( 1, $db->trxLevel() ); + $this->assertSame( 1, $db->trxLevel() ); $lock = $db->getScopedLockAndFlush( 'wuff', __METHOD__, 1 ); $this->assertSame( 0, $db->trxLevel() ); $this->assertFalse( $db->lockIsFree( 'wuff', __METHOD__ ), 'Lock already acquired' ); @@ -554,7 +554,7 @@ class DatabaseTest extends PHPUnit\Framework\TestCase { $lock = $db->getScopedLockAndFlush( 'wuff2', __METHOD__, 1 ); $this->fail( "Exception not reached" ); } catch ( DBUnexpectedError $e ) { - $this->assertEquals( 1, $db->trxLevel(), "Transaction not committed." ); + $this->assertSame( 1, $db->trxLevel(), "Transaction not committed." ); $this->assertFalse( $db->lockIsFree( 'wuff2', __METHOD__ ), 'Lock not acquired' ); } $db->rollback( __METHOD__ ); diff --git a/tests/phpunit/includes/media/PNGMetadataExtractorTest.php b/tests/phpunit/includes/media/PNGMetadataExtractorTest.php index fb5d81428bf..5ee39c21550 100644 --- a/tests/phpunit/includes/media/PNGMetadataExtractorTest.php +++ b/tests/phpunit/includes/media/PNGMetadataExtractorTest.php @@ -73,7 +73,7 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase { 'Png-native-test.png' ); $this->assertSame( 0, $meta['frameCount'] ); - $this->assertEquals( 1, $meta['loopCount'] ); + $this->assertSame( 1, $meta['loopCount'] ); $this->assertSame( 0.0, $meta['duration'] ); } @@ -101,7 +101,7 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase { public function testPngBitDepth1() { $meta = PNGMetadataExtractor::getMetadata( $this->filePath . '1bit-png.png' ); - $this->assertEquals( 1, $meta['bitDepth'] ); + $this->assertSame( 1, $meta['bitDepth'] ); } public function testPngIndexColour() { diff --git a/tests/phpunit/includes/page/WikiPageDbTest.php b/tests/phpunit/includes/page/WikiPageDbTest.php index d1c30e6a8d4..befa5621f4e 100644 --- a/tests/phpunit/includes/page/WikiPageDbTest.php +++ b/tests/phpunit/includes/page/WikiPageDbTest.php @@ -230,7 +230,7 @@ class WikiPageDbTest extends MediaWikiLangTestCase { $n = $res->numRows(); $res->free(); - $this->assertEquals( 1, $n, 'pagelinks should contain only one link if PST was not applied' ); + $this->assertSame( 1, $n, 'pagelinks should contain only one link if PST was not applied' ); } /** @@ -299,7 +299,7 @@ class WikiPageDbTest extends MediaWikiLangTestCase { $n = $res->numRows(); $res->free(); - $this->assertEquals( 1, $n, 'pagelinks should contain one link from the page' ); + $this->assertSame( 1, $n, 'pagelinks should contain one link from the page' ); # ------------------------ $page = new WikiPage( $title ); @@ -1571,23 +1571,23 @@ more stuff // Add an initial category $page->updateCategoryCounts( [ 'A' ], [], 0 ); - $this->assertEquals( 1, Category::newFromName( 'A' )->getPageCount() ); + $this->assertSame( '1', Category::newFromName( 'A' )->getPageCount() ); $this->assertSame( 0, Category::newFromName( 'B' )->getPageCount() ); $this->assertSame( 0, Category::newFromName( 'C' )->getPageCount() ); // Add a new category $page->updateCategoryCounts( [ 'B' ], [], 0 ); - $this->assertEquals( 1, Category::newFromName( 'A' )->getPageCount() ); - $this->assertEquals( 1, Category::newFromName( 'B' )->getPageCount() ); + $this->assertSame( '1', Category::newFromName( 'A' )->getPageCount() ); + $this->assertSame( '1', Category::newFromName( 'B' )->getPageCount() ); $this->assertSame( 0, Category::newFromName( 'C' )->getPageCount() ); // Add and remove a category $page->updateCategoryCounts( [ 'C' ], [ 'A' ], 0 ); $this->assertSame( 0, Category::newFromName( 'A' )->getPageCount() ); - $this->assertEquals( 1, Category::newFromName( 'B' )->getPageCount() ); - $this->assertEquals( 1, Category::newFromName( 'C' )->getPageCount() ); + $this->assertSame( '1', Category::newFromName( 'B' )->getPageCount() ); + $this->assertSame( '1', Category::newFromName( 'C' )->getPageCount() ); } public function provideUpdateRedirectOn() { diff --git a/tests/phpunit/includes/search/SearchEngineTest.php b/tests/phpunit/includes/search/SearchEngineTest.php index 4e66b269af9..b5460fcef36 100644 --- a/tests/phpunit/includes/search/SearchEngineTest.php +++ b/tests/phpunit/includes/search/SearchEngineTest.php @@ -267,7 +267,7 @@ class SearchEngineTest extends MediaWikiLangTestCase { ) { $this->search->setNamespaces( $namespaces ); $results = $this->search->completionSearch( $search ); - $this->assertEquals( 1, $results->getSize() ); + $this->assertSame( 1, $results->getSize() ); $this->assertEquals( $expectedSuggestion, $results->getSuggestions()[0]->getText() ); } @@ -391,7 +391,7 @@ class SearchEngineTest extends MediaWikiLangTestCase { $engine->setLimitOffset( 10, 10 ); $results = $engine->completionSearch( 'foo' ); - $this->assertEquals( 1, $results->getSize() ); + $this->assertSame( 1, $results->getSize() ); $this->assertFalse( $results->hasMoreResults() ); } diff --git a/tests/phpunit/includes/search/SearchNearMatchResultSetTest.php b/tests/phpunit/includes/search/SearchNearMatchResultSetTest.php index 8135d573f12..6c745604b52 100644 --- a/tests/phpunit/includes/search/SearchNearMatchResultSetTest.php +++ b/tests/phpunit/includes/search/SearchNearMatchResultSetTest.php @@ -10,6 +10,6 @@ class SearchNearMatchResultSetTest extends PHPUnit\Framework\TestCase { $this->assertSame( 0, $resultSet->numRows() ); $resultSet = new SearchNearMatchResultSet( Title::newMainPage() ); - $this->assertEquals( 1, $resultSet->numRows() ); + $this->assertSame( 1, $resultSet->numRows() ); } } diff --git a/tests/phpunit/includes/search/SearchResultSetTest.php b/tests/phpunit/includes/search/SearchResultSetTest.php index 97e8b320011..afab6236c60 100644 --- a/tests/phpunit/includes/search/SearchResultSetTest.php +++ b/tests/phpunit/includes/search/SearchResultSetTest.php @@ -9,13 +9,13 @@ class SearchResultSetTest extends MediaWikiTestCase { public function testIterate() { $result = SearchResult::newFromTitle( Title::newMainPage() ); $resultSet = new MockSearchResultSet( [ $result ] ); - $this->assertEquals( 1, $resultSet->numRows() ); + $this->assertSame( 1, $resultSet->numRows() ); $count = 0; foreach ( $resultSet as $iterResult ) { $this->assertEquals( $result, $iterResult ); $count++; } - $this->assertEquals( 1, $count ); + $this->assertSame( 1, $count ); $this->hideDeprecated( 'BaseSearchResultSet::rewind' ); $this->hideDeprecated( 'BaseSearchResultSet::next' ); @@ -25,7 +25,7 @@ class SearchResultSetTest extends MediaWikiTestCase { $this->assertEquals( $result, $iterResult ); $count++; } - $this->assertEquals( 1, $count ); + $this->assertSame( 1, $count ); } /** diff --git a/tests/phpunit/includes/session/CookieSessionProviderTest.php b/tests/phpunit/includes/session/CookieSessionProviderTest.php index 35c451916bf..cd7482f286c 100644 --- a/tests/phpunit/includes/session/CookieSessionProviderTest.php +++ b/tests/phpunit/includes/session/CookieSessionProviderTest.php @@ -92,7 +92,7 @@ class CookieSessionProviderTest extends MediaWikiTestCase { ); $p->setLogger( new \TestLogger() ); $p->setConfig( $config ); - $this->assertEquals( 1, $p->priority ); + $this->assertSame( 1, $p->priority ); $this->assertEquals( [ 'callUserSetCookiesHook' => false, 'sessionName' => 'CookiePrefix_session', diff --git a/tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php b/tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php index cb7143d54b7..87d6acb30e7 100644 --- a/tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php +++ b/tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php @@ -37,7 +37,7 @@ class SpecialPageFactoryTest extends MediaWikiTestCase { $spf = MediaWikiServices::getInstance()->getSpecialPageFactory(); $spf->getNames(); $spf->getNames(); - $this->assertEquals( 1, $count ); + $this->assertSame( 1, $count ); } public function newSpecialAllPages() { diff --git a/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php b/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php index ea2de585c75..b93974eaf26 100644 --- a/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php +++ b/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php @@ -1287,7 +1287,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { new TitleValue( 0, 'SomeDbKey' ) ); $this->assertInstanceOf( WatchedItem::class, $watchedItem ); - $this->assertEquals( 1, $watchedItem->getUser()->getId() ); + $this->assertSame( 1, $watchedItem->getUser()->getId() ); $this->assertEquals( 'SomeDbKey', $watchedItem->getLinkTarget()->getDBkey() ); $this->assertSame( '20300101000000', $watchedItem->getExpiry() ); $this->assertSame( 0, $watchedItem->getLinkTarget()->getNamespace() ); @@ -1479,7 +1479,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { new TitleValue( 0, 'SomeDbKey' ) ); $this->assertInstanceOf( WatchedItem::class, $watchedItem ); - $this->assertEquals( 1, $watchedItem->getUser()->getId() ); + $this->assertSame( 1, $watchedItem->getUser()->getId() ); $this->assertEquals( 'SomeDbKey', $watchedItem->getLinkTarget()->getDBkey() ); $this->assertSame( '20300101000000', $watchedItem->getExpiry() ); $this->assertSame( 0, $watchedItem->getLinkTarget()->getNamespace() ); @@ -2656,7 +2656,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { $this->assertTrue( $store->setNotificationTimestampsForUser( $user, $timestamp ) ); - $this->assertEquals( 1, $callableCallCounter ); + $this->assertSame( 1, $callableCallCounter ); } public function testSetNotificationTimestampsForUser_nullTimestamp() { diff --git a/tests/phpunit/integration/includes/db/DatabaseSqliteTest.php b/tests/phpunit/integration/includes/db/DatabaseSqliteTest.php index 40178d507dc..bae41f8c267 100644 --- a/tests/phpunit/integration/includes/db/DatabaseSqliteTest.php +++ b/tests/phpunit/integration/includes/db/DatabaseSqliteTest.php @@ -549,7 +549,7 @@ class DatabaseSqliteTest extends \MediaWikiIntegrationTestCase { $insertion = $db->insert( 'a', [ 'a_1' => 10 ], __METHOD__ ); $this->assertTrue( $insertion, "Insertion failed" ); $res = $db->select( 'a', '*' ); - $this->assertEquals( 1, $db->numFields( $res ), "wrong number of fields" ); + $this->assertSame( 1, $db->numFields( $res ), "wrong number of fields" ); $this->assertTrue( $db->close(), "closing database" ); } diff --git a/tests/phpunit/languages/classes/LanguageBe_taraskTest.php b/tests/phpunit/languages/classes/LanguageBe_taraskTest.php index 73f220cdba1..1b08fbda527 100644 --- a/tests/phpunit/languages/classes/LanguageBe_taraskTest.php +++ b/tests/phpunit/languages/classes/LanguageBe_taraskTest.php @@ -6,6 +6,7 @@ */ class LanguageBe_taraskTest extends LanguageClassesTestCase { // phpcs:enable + /** * Make sure the language code we are given is indeed * be-tarask. This is to ensure LanguageClassesTestCase diff --git a/tests/phpunit/maintenance/fetchTextTest.php b/tests/phpunit/maintenance/fetchTextTest.php index 2fcb756a506..823268c63bb 100644 --- a/tests/phpunit/maintenance/fetchTextTest.php +++ b/tests/phpunit/maintenance/fetchTextTest.php @@ -192,7 +192,7 @@ class FetchTextTest extends MediaWikiTestCase { $this->fetchText->mockStdin( $input ); $this->fetchText->execute(); $invocations = $this->fetchText->mockGetInvocations(); - $this->assertEquals( 1, $invocations['getStdin'], + $this->assertSame( 1, $invocations['getStdin'], "getStdin invocation counter" ); $this->expectOutputString( $expectedOutput ); } diff --git a/tests/phpunit/unit/includes/libs/MemoizedCallableTest.php b/tests/phpunit/unit/includes/libs/MemoizedCallableTest.php index 876cc03e011..cc707f28a30 100644 --- a/tests/phpunit/unit/includes/libs/MemoizedCallableTest.php +++ b/tests/phpunit/unit/includes/libs/MemoizedCallableTest.php @@ -76,7 +76,7 @@ class MemoizedCallableTest extends PHPUnit\Framework\TestCase { $this->assertEquals( 86400, $memoized->ttl ); $memoized = TestingAccessWrapper::newFromObject( new MemoizedCallable( 'abs', -10 ) ); - $this->assertEquals( 1, $memoized->ttl ); + $this->assertSame( 1, $memoized->ttl ); } /** diff --git a/tests/phpunit/unit/includes/libs/ProcessCacheLRUTest.php b/tests/phpunit/unit/includes/libs/ProcessCacheLRUTest.php index 81d35b15716..d0d58b5ba58 100644 --- a/tests/phpunit/unit/includes/libs/ProcessCacheLRUTest.php +++ b/tests/phpunit/unit/includes/libs/ProcessCacheLRUTest.php @@ -103,7 +103,7 @@ class ProcessCacheLRUTest extends PHPUnit\Framework\TestCase { // First set just one value $oneCache->set( 'cache-key', 'prop1', 'value1' ); - $this->assertEquals( 1, $oneCache->getEntriesCount() ); + $this->assertSame( 1, $oneCache->getEntriesCount() ); $this->assertTrue( $oneCache->has( 'cache-key', 'prop1' ) ); $this->assertEquals( 'value1', $oneCache->get( 'cache-key', 'prop1' ) ); } diff --git a/tests/phpunit/unit/includes/search/SearchSuggestionSetTest.php b/tests/phpunit/unit/includes/search/SearchSuggestionSetTest.php index fce21f76388..7dc6c42e025 100644 --- a/tests/phpunit/unit/includes/search/SearchSuggestionSetTest.php +++ b/tests/phpunit/unit/includes/search/SearchSuggestionSetTest.php @@ -40,9 +40,9 @@ class SearchSuggestionSetTest extends \MediaWikiUnitTestCase { $suggestion = new SearchSuggestion( 2 ); $set->append( $suggestion ); - $this->assertEquals( 1, $set->getWorstScore() ); + $this->assertSame( 1, $set->getWorstScore() ); $this->assertEquals( 3, $set->getBestScore() ); - $this->assertEquals( 1, $suggestion->getScore() ); + $this->assertSame( 1, $suggestion->getScore() ); $scores = $set->map( function ( $s ) { return $s->getScore(); diff --git a/tests/phpunit/unit/includes/session/SessionUnitTest.php b/tests/phpunit/unit/includes/session/SessionUnitTest.php index 6b6f0985998..7a384d8ab6c 100644 --- a/tests/phpunit/unit/includes/session/SessionUnitTest.php +++ b/tests/phpunit/unit/includes/session/SessionUnitTest.php @@ -100,7 +100,7 @@ class SessionUnitTest extends MediaWikiUnitTestCase { $session = TestUtils::getDummySession(); $backend = TestingAccessWrapper::newFromObject( $session )->backend; - $this->assertEquals( 1, $session->get( 'foo' ) ); + $this->assertSame( 1, $session->get( 'foo' ) ); $this->assertEquals( 'zero', $session->get( 0 ) ); $this->assertFalse( $backend->dirty ); @@ -160,7 +160,7 @@ class SessionUnitTest extends MediaWikiUnitTestCase { $session = TestUtils::getDummySession( null, -1, $logger ); $backend = TestingAccessWrapper::newFromObject( $session )->backend; - $this->assertEquals( 1, $session['foo'] ); + $this->assertSame( 1, $session['foo'] ); $this->assertEquals( 'zero', $session[0] ); $this->assertFalse( $backend->dirty );