From 32a429e8c455688b9613660b91db51dcf4eb8c19 Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Tue, 17 Sep 2019 16:31:49 +0200 Subject: [PATCH] tests: Prefer assertSame() when comparing the integer 0 assertSame() is guaranteed to not do any type conversion. This can be critical when acciden tially comparing, for example, 0 to 0.0. Change-Id: Iffcc9bda69573623ba14af655dcd697d0fcce525 --- tests/phpunit/includes/EditPageTest.php | 2 +- tests/phpunit/includes/LinkerTest.php | 2 +- .../includes/MediaWikiServicesTest.php | 2 +- tests/phpunit/includes/OutputPageTest.php | 2 +- tests/phpunit/includes/SiteStatsTest.php | 4 +- .../Storage/DerivedPageDataUpdaterTest.php | 4 +- tests/phpunit/includes/TitleMethodsTest.php | 2 +- tests/phpunit/includes/api/ApiPageSetTest.php | 2 +- .../api/ApiQueryWatchlistIntegrationTest.php | 2 +- .../ApiQueryWatchlistRawIntegrationTest.php | 2 +- tests/phpunit/includes/api/ApiWatchTest.php | 2 +- .../phpunit/includes/auth/AuthManagerTest.php | 56 +++++++++---------- .../block/BlockRestrictionStoreTest.php | 2 +- .../includes/block/DatabaseBlockTest.php | 2 +- .../includes/cache/MessageCacheTest.php | 14 ++--- .../changes/CategoryMembershipChangeTest.php | 20 +++---- .../changes/RCCacheEntryFactoryTest.php | 6 +- .../includes/context/RequestContextTest.php | 2 +- tests/phpunit/includes/db/LBFactoryTest.php | 6 +- .../includes/deferred/SiteStatsUpdateTest.php | 8 +-- .../includes/filebackend/FileBackendTest.php | 2 +- .../includes/http/GuzzleHttpRequestTest.php | 6 +- .../includes/jobqueue/JobQueueTest.php | 38 ++++++------- .../jobs/ClearUserWatchlistJobTest.php | 2 +- .../includes/libs/ProcessCacheLRUTest.php | 2 +- tests/phpunit/includes/libs/TimingTest.php | 2 +- .../libs/objectcache/HashBagOStuffTest.php | 2 +- .../libs/objectcache/WANObjectCacheTest.php | 14 ++--- .../libs/rdbms/database/DatabaseSQLTest.php | 16 +++--- .../libs/rdbms/database/DatabaseTest.php | 14 ++--- .../includes/media/JpegPixelFormatTest.php | 2 +- .../media/PNGMetadataExtractorTest.php | 6 +- .../includes/page/WikiPageDbTestBase.php | 12 ++-- .../search/SearchNearMatchResultSetTest.php | 2 +- tests/phpunit/includes/shell/ShellTest.php | 2 +- .../includes/site/CachingSiteStoreTest.php | 2 +- .../phpunit/includes/site/DBSiteStoreTest.php | 2 +- tests/phpunit/includes/user/UserTest.php | 4 +- .../watcheditem/WatchedItemStoreUnitTest.php | 4 +- .../includes/db/DatabaseSqliteTest.php | 4 +- .../phpunit/unit/includes/diff/DiffOpTest.php | 4 +- .../search/SearchSuggestionSetTest.php | 6 +- 42 files changed, 145 insertions(+), 145 deletions(-) diff --git a/tests/phpunit/includes/EditPageTest.php b/tests/phpunit/includes/EditPageTest.php index d2540f6f4d..1f9465dee3 100644 --- a/tests/phpunit/includes/EditPageTest.php +++ b/tests/phpunit/includes/EditPageTest.php @@ -351,7 +351,7 @@ class EditPageTest extends MediaWikiLangTestCase { wfGetDB( DB_MASTER )->commit( __METHOD__ ); - $this->assertEquals( 0, DeferredUpdates::pendingUpdatesCount(), 'No deferred updates' ); + $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount(), 'No deferred updates' ); if ( $expectedCode != EditPage::AS_BLANK_ARTICLE ) { $latest = $page->getLatest(); diff --git a/tests/phpunit/includes/LinkerTest.php b/tests/phpunit/includes/LinkerTest.php index fe325075d5..dcac47146c 100644 --- a/tests/phpunit/includes/LinkerTest.php +++ b/tests/phpunit/includes/LinkerTest.php @@ -453,7 +453,7 @@ class LinkerTest extends MediaWikiLangTestCase { $user = $context->getUser(); $user->setOption( 'showrollbackconfirmation', $rollbackEnabled ); - $this->assertEquals( 0, Title::newFromText( $title )->getArticleID() ); + $this->assertSame( 0, Title::newFromText( $title )->getArticleID() ); $pageData = $this->insertPage( $title ); $page = WikiPage::factory( $pageData['title'] ); diff --git a/tests/phpunit/includes/MediaWikiServicesTest.php b/tests/phpunit/includes/MediaWikiServicesTest.php index d34ba0a542..e4c068fbd7 100644 --- a/tests/phpunit/includes/MediaWikiServicesTest.php +++ b/tests/phpunit/includes/MediaWikiServicesTest.php @@ -227,7 +227,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase { // This should do nothing. In particular, it should not create a service instance. $services->resetServiceForTesting( 'Test' ); - $this->assertEquals( 0, $serviceCounter, 'No service instance should be created yet.' ); + $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.' ); diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php index aa6e49479a..6ab56eb10a 100644 --- a/tests/phpunit/includes/OutputPageTest.php +++ b/tests/phpunit/includes/OutputPageTest.php @@ -93,7 +93,7 @@ class OutputPageTest extends MediaWikiTestCase { 'Some syndication links should be there' ); } else { $this->assertFalse( $outputPage->isSyndicated(), 'No syndication should be offered' ); - $this->assertEquals( 0, count( $outputPage->getSyndicationLinks() ), + $this->assertSame( 0, count( $outputPage->getSyndicationLinks() ), 'No syndication links should be there' ); } } diff --git a/tests/phpunit/includes/SiteStatsTest.php b/tests/phpunit/includes/SiteStatsTest.php index b0d89a6ae5..ff9fa7b34a 100644 --- a/tests/phpunit/includes/SiteStatsTest.php +++ b/tests/phpunit/includes/SiteStatsTest.php @@ -21,7 +21,7 @@ class SiteStatsTest extends MediaWikiTestCase { ); $jobq->get( 'null' )->delete(); // clear jobqueue - $this->assertEquals( 0, $jobq->get( 'null' )->getSize(), + $this->assertSame( 0, $jobq->get( 'null' )->getSize(), 'Job queue for NullJob has been cleaned' ); $cache->delete( $cache->makeKey( 'SiteStats', 'jobscount' ) ); @@ -29,7 +29,7 @@ class SiteStatsTest extends MediaWikiTestCase { 'jobs count is kept in process cache' ); $cache->clearProcessCache(); - $this->assertEquals( 0, SiteStats::jobs() ); + $this->assertSame( 0, SiteStats::jobs() ); } } diff --git a/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php b/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php index 2148411cbf..c64169fd8c 100644 --- a/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php +++ b/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php @@ -1062,7 +1062,7 @@ class DerivedPageDataUpdaterTest extends MediaWikiTestCase { $this->db->endAtomic( __METHOD__ ); // run deferred updates - $this->assertEquals( 0, DeferredUpdates::pendingUpdatesCount(), 'No pending updates' ); + $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount(), 'No pending updates' ); } /** @@ -1095,7 +1095,7 @@ class DerivedPageDataUpdaterTest extends MediaWikiTestCase { $this->db->endAtomic( __METHOD__ ); // run deferred updates - $this->assertEquals( 0, DeferredUpdates::pendingUpdatesCount(), 'No pending updates' ); + $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount(), 'No pending updates' ); $this->assertNotFalse( $pcache->get( $page, $updater->getCanonicalParserOptions() ) ); } diff --git a/tests/phpunit/includes/TitleMethodsTest.php b/tests/phpunit/includes/TitleMethodsTest.php index 77d6f59d21..ec002e0aec 100644 --- a/tests/phpunit/includes/TitleMethodsTest.php +++ b/tests/phpunit/includes/TitleMethodsTest.php @@ -327,7 +327,7 @@ class TitleMethodsTest extends MediaWikiLangTestCase { $title2 = Title::newFromText( 'Foo' ); $this->assertNotSame( $title1, $title2, 'title cache should be empty' ); - $this->assertEquals( 0, $linkCache->getGoodLinkID( 'Foo' ), 'link cache should be empty' ); + $this->assertSame( 0, $linkCache->getGoodLinkID( 'Foo' ), 'link cache should be empty' ); } public function provideGetLinkURL() { diff --git a/tests/phpunit/includes/api/ApiPageSetTest.php b/tests/phpunit/includes/api/ApiPageSetTest.php index fdc9c1b2b3..b1b8a42523 100644 --- a/tests/phpunit/includes/api/ApiPageSetTest.php +++ b/tests/phpunit/includes/api/ApiPageSetTest.php @@ -214,7 +214,7 @@ class ApiPageSetTest extends ApiTestCase { 'titles' => 'User:' . implode( '|User:', $userNames ), ] ); - $this->assertEquals( 0, $genderCache->misses, + $this->assertSame( 0, $genderCache->misses, 'ApiPageSet does not prefill the gender cache correctly' ); $this->assertEquals( $userNames, array_keys( $genderCache->cache ), 'ApiPageSet does not prefill all users into the gender cache' ); diff --git a/tests/phpunit/includes/api/ApiQueryWatchlistIntegrationTest.php b/tests/phpunit/includes/api/ApiQueryWatchlistIntegrationTest.php index 2b08a81c2e..26fedba1b3 100644 --- a/tests/phpunit/includes/api/ApiQueryWatchlistIntegrationTest.php +++ b/tests/phpunit/includes/api/ApiQueryWatchlistIntegrationTest.php @@ -1575,7 +1575,7 @@ class ApiQueryWatchlistIntegrationTest extends ApiTestCase { $pages = array_values( $result[0]['query']['pages'] ); $this->assertCount( 1, $pages ); - $this->assertEquals( 0, $pages[0]['ns'] ); + $this->assertSame( 0, $pages[0]['ns'] ); $this->assertEquals( $this->getPrefixedText( $target ), $pages[0]['title'] ); $this->assertArraySubsetsEqual( $pages[0]['revisions'], diff --git a/tests/phpunit/includes/api/ApiQueryWatchlistRawIntegrationTest.php b/tests/phpunit/includes/api/ApiQueryWatchlistRawIntegrationTest.php index c554fb3f49..b41c3e5b2f 100644 --- a/tests/phpunit/includes/api/ApiQueryWatchlistRawIntegrationTest.php +++ b/tests/phpunit/includes/api/ApiQueryWatchlistRawIntegrationTest.php @@ -535,7 +535,7 @@ class ApiQueryWatchlistRawIntegrationTest extends ApiTestCase { // $result[0]['query']['pages'] uses page ids as keys $item = array_values( $result[0]['query']['pages'] )[0]; - $this->assertEquals( 0, $item['ns'] ); + $this->assertSame( 0, $item['ns'] ); $this->assertEquals( 'ApiQueryWatchlistRawIntegrationTestPage', $item['title'] ); } diff --git a/tests/phpunit/includes/api/ApiWatchTest.php b/tests/phpunit/includes/api/ApiWatchTest.php index 6d64a178df..24d016e697 100644 --- a/tests/phpunit/includes/api/ApiWatchTest.php +++ b/tests/phpunit/includes/api/ApiWatchTest.php @@ -64,7 +64,7 @@ class ApiWatchTest extends ApiTestCase { unset( $data[0]['query']['watchlist'][$index] ); } } - $this->assertEquals( 0, count( $data[0]['query']['watchlist'] ) ); + $this->assertSame( 0, count( $data[0]['query']['watchlist'] ) ); return $data; } diff --git a/tests/phpunit/includes/auth/AuthManagerTest.php b/tests/phpunit/includes/auth/AuthManagerTest.php index f8be1d437f..55d4e10ab9 100644 --- a/tests/phpunit/includes/auth/AuthManagerTest.php +++ b/tests/phpunit/includes/auth/AuthManagerTest.php @@ -2120,9 +2120,9 @@ class AuthManagerTest extends \MediaWikiTestCase { } if ( $created ) { - $this->assertNotEquals( 0, \User::idFromName( $username ) ); + $this->assertNotNull( \User::idFromName( $username ) ); } else { - $this->assertEquals( 0, \User::idFromName( $username ) ); + $this->assertNull( \User::idFromName( $username ) ); } $first = false; @@ -2474,7 +2474,7 @@ class AuthManagerTest extends \MediaWikiTestCase { $this->assertEquals( $expect, $ret ); $this->assertNotEquals( 0, $user->getId() ); $this->assertSame( 'UTSysop', $user->getName() ); - $this->assertEquals( 0, $session->getUser()->getId() ); + $this->assertSame( 0, $session->getUser()->getId() ); $this->assertSame( [ [ LogLevel::DEBUG, '{username} already exists locally' ], ], $logger->getBuffer() ); @@ -2489,9 +2489,9 @@ class AuthManagerTest extends \MediaWikiTestCase { $ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true ); $this->unhook( 'LocalUserCreated' ); $this->assertEquals( \Status::newFatal( wfMessage( 'readonlytext', 'Because' ) ), $ret ); - $this->assertEquals( 0, $user->getId() ); + $this->assertSame( 0, $user->getId() ); $this->assertNotEquals( $username, $user->getName() ); - $this->assertEquals( 0, $session->getUser()->getId() ); + $this->assertSame( 0, $session->getUser()->getId() ); $this->assertSame( [ [ LogLevel::DEBUG, 'denied by wfReadOnly(): {reason}' ], ], $logger->getBuffer() ); @@ -2506,9 +2506,9 @@ class AuthManagerTest extends \MediaWikiTestCase { $ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true ); $this->unhook( 'LocalUserCreated' ); $this->assertEquals( \Status::newFatal( 'test' ), $ret ); - $this->assertEquals( 0, $user->getId() ); + $this->assertSame( 0, $user->getId() ); $this->assertNotEquals( $username, $user->getName() ); - $this->assertEquals( 0, $session->getUser()->getId() ); + $this->assertSame( 0, $session->getUser()->getId() ); $this->assertSame( [ [ LogLevel::DEBUG, 'blacklisted in session {sessionid}' ], ], $logger->getBuffer() ); @@ -2521,9 +2521,9 @@ class AuthManagerTest extends \MediaWikiTestCase { $ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true ); $this->unhook( 'LocalUserCreated' ); $this->assertEquals( \Status::newFatal( 'test2' ), $ret ); - $this->assertEquals( 0, $user->getId() ); + $this->assertSame( 0, $user->getId() ); $this->assertNotEquals( $username, $user->getName() ); - $this->assertEquals( 0, $session->getUser()->getId() ); + $this->assertSame( 0, $session->getUser()->getId() ); $this->assertSame( [ [ LogLevel::DEBUG, 'blacklisted in session {sessionid}' ], ], $logger->getBuffer() ); @@ -2536,9 +2536,9 @@ class AuthManagerTest extends \MediaWikiTestCase { $ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true ); $this->unhook( 'LocalUserCreated' ); $this->assertEquals( \Status::newFatal( 'noname' ), $ret ); - $this->assertEquals( 0, $user->getId() ); + $this->assertSame( 0, $user->getId() ); $this->assertNotEquals( $username . '@', $user->getId() ); - $this->assertEquals( 0, $session->getUser()->getId() ); + $this->assertSame( 0, $session->getUser()->getId() ); $this->assertSame( [ [ LogLevel::DEBUG, 'name "{username}" is not creatable' ], ], $logger->getBuffer() ); @@ -2554,9 +2554,9 @@ class AuthManagerTest extends \MediaWikiTestCase { $ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true ); $this->unhook( 'LocalUserCreated' ); $this->assertEquals( \Status::newFatal( 'authmanager-autocreate-noperm' ), $ret ); - $this->assertEquals( 0, $user->getId() ); + $this->assertSame( 0, $user->getId() ); $this->assertNotEquals( $username, $user->getName() ); - $this->assertEquals( 0, $session->getUser()->getId() ); + $this->assertSame( 0, $session->getUser()->getId() ); $this->assertSame( [ [ LogLevel::DEBUG, 'IP lacks the ability to create or autocreate accounts' ], ], $logger->getBuffer() ); @@ -2608,9 +2608,9 @@ class AuthManagerTest extends \MediaWikiTestCase { unset( $lock ); $this->unhook( 'LocalUserCreated' ); $this->assertEquals( \Status::newFatal( 'usernameinprogress' ), $ret ); - $this->assertEquals( 0, $user->getId() ); + $this->assertSame( 0, $user->getId() ); $this->assertNotEquals( $username, $user->getName() ); - $this->assertEquals( 0, $session->getUser()->getId() ); + $this->assertSame( 0, $session->getUser()->getId() ); $this->assertSame( [ [ LogLevel::DEBUG, 'Could not acquire account creation lock' ], ], $logger->getBuffer() ); @@ -2623,9 +2623,9 @@ class AuthManagerTest extends \MediaWikiTestCase { $ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true ); $this->unhook( 'LocalUserCreated' ); $this->assertEquals( \Status::newFatal( 'fail-in-pre' ), $ret ); - $this->assertEquals( 0, $user->getId() ); + $this->assertSame( 0, $user->getId() ); $this->assertNotEquals( $username, $user->getName() ); - $this->assertEquals( 0, $session->getUser()->getId() ); + $this->assertSame( 0, $session->getUser()->getId() ); $this->assertSame( [ [ LogLevel::DEBUG, 'Provider denied creation of {username}: {reason}' ], ], $logger->getBuffer() ); @@ -2640,9 +2640,9 @@ class AuthManagerTest extends \MediaWikiTestCase { $ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true ); $this->unhook( 'LocalUserCreated' ); $this->assertEquals( \Status::newFatal( 'fail-in-primary' ), $ret ); - $this->assertEquals( 0, $user->getId() ); + $this->assertSame( 0, $user->getId() ); $this->assertNotEquals( $username, $user->getName() ); - $this->assertEquals( 0, $session->getUser()->getId() ); + $this->assertSame( 0, $session->getUser()->getId() ); $this->assertSame( [ [ LogLevel::DEBUG, 'Provider denied creation of {username}: {reason}' ], ], $logger->getBuffer() ); @@ -2657,9 +2657,9 @@ class AuthManagerTest extends \MediaWikiTestCase { $ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true ); $this->unhook( 'LocalUserCreated' ); $this->assertEquals( \Status::newFatal( 'fail-in-secondary' ), $ret ); - $this->assertEquals( 0, $user->getId() ); + $this->assertSame( 0, $user->getId() ); $this->assertNotEquals( $username, $user->getName() ); - $this->assertEquals( 0, $session->getUser()->getId() ); + $this->assertSame( 0, $session->getUser()->getId() ); $this->assertSame( [ [ LogLevel::DEBUG, 'Provider denied creation of {username}: {reason}' ], ], $logger->getBuffer() ); @@ -2678,9 +2678,9 @@ class AuthManagerTest extends \MediaWikiTestCase { $ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true ); $this->unhook( 'LocalUserCreated' ); $this->assertEquals( \Status::newFatal( 'authmanager-autocreate-exception' ), $ret ); - $this->assertEquals( 0, $user->getId() ); + $this->assertSame( 0, $user->getId() ); $this->assertNotEquals( $username, $user->getName() ); - $this->assertEquals( 0, $session->getUser()->getId() ); + $this->assertSame( 0, $session->getUser()->getId() ); $this->assertSame( [ [ LogLevel::DEBUG, '{username} denied by prior creation attempt failures' ], ], $logger->getBuffer() ); @@ -2697,9 +2697,9 @@ class AuthManagerTest extends \MediaWikiTestCase { $user->setName( $username ); $ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true ); $this->assertEquals( \Status::newFatal( 'because' ), $ret ); - $this->assertEquals( 0, $user->getId() ); + $this->assertSame( 0, $user->getId() ); $this->assertNotEquals( $username, $user->getName() ); - $this->assertEquals( 0, $session->getUser()->getId() ); + $this->assertSame( 0, $session->getUser()->getId() ); $this->assertSame( [ [ LogLevel::INFO, 'creating new user ({username}) - from: {from}' ], [ LogLevel::ERROR, '{username} failed with message {msg}' ], @@ -2723,8 +2723,8 @@ class AuthManagerTest extends \MediaWikiTestCase { } catch ( \Exception $ex ) { $this->assertSame( 'Excepted', $ex->getMessage() ); } - $this->assertEquals( 0, $user->getId() ); - $this->assertEquals( 0, $session->getUser()->getId() ); + $this->assertSame( 0, $user->getId() ); + $this->assertSame( 0, $session->getUser()->getId() ); $this->assertSame( [ [ LogLevel::INFO, 'creating new user ({username}) - from: {from}' ], [ LogLevel::ERROR, '{username} failed with exception {exception}' ], @@ -2790,7 +2790,7 @@ class AuthManagerTest extends \MediaWikiTestCase { $this->assertEquals( \Status::newGood(), $ret ); $this->assertNotEquals( 0, $user->getId() ); $this->assertEquals( $username, $user->getName() ); - $this->assertEquals( 0, $session->getUser()->getId() ); + $this->assertSame( 0, $session->getUser()->getId() ); $this->assertSame( [ [ LogLevel::INFO, 'creating new user ({username}) - from: {from}' ], ], $logger->getBuffer() ); diff --git a/tests/phpunit/includes/block/BlockRestrictionStoreTest.php b/tests/phpunit/includes/block/BlockRestrictionStoreTest.php index ebbfde27c0..b1e23baabf 100644 --- a/tests/phpunit/includes/block/BlockRestrictionStoreTest.php +++ b/tests/phpunit/includes/block/BlockRestrictionStoreTest.php @@ -282,7 +282,7 @@ class BlockRestrictionStoreTest extends \MediaWikiLangTestCase { [ 'ir_ipb_id' => $block->getId() ] ); - $this->assertEquals( 0, $result->numRows() ); + $this->assertSame( 0, $result->numRows() ); } /** diff --git a/tests/phpunit/includes/block/DatabaseBlockTest.php b/tests/phpunit/includes/block/DatabaseBlockTest.php index 0ef571db73..9182609ff7 100644 --- a/tests/phpunit/includes/block/DatabaseBlockTest.php +++ b/tests/phpunit/includes/block/DatabaseBlockTest.php @@ -314,7 +314,7 @@ class DatabaseBlockTest extends MediaWikiLangTestCase { $this->assertEquals( 'Meta>MetaWikiUser', $block->getBlocker()->getName(), 'Correct blocker name' ); $this->assertEquals( 'Meta>MetaWikiUser', $block->getByName(), 'Correct blocker name' ); - $this->assertEquals( 0, $block->getBy(), 'Correct blocker id' ); + $this->assertSame( 0, $block->getBy(), 'Correct blocker id' ); } protected function addXffBlocks() { diff --git a/tests/phpunit/includes/cache/MessageCacheTest.php b/tests/phpunit/includes/cache/MessageCacheTest.php index 7abddd44ad..869236b43f 100644 --- a/tests/phpunit/includes/cache/MessageCacheTest.php +++ b/tests/phpunit/includes/cache/MessageCacheTest.php @@ -124,7 +124,7 @@ class MessageCacheTest extends MediaWikiLangTestCase { $this->makePage( 'Go', 'de', 'Race!' ); $dbw->endAtomic( __METHOD__ ); - $this->assertEquals( 0, + $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount(), 'Post-commit deferred update triggers a run of all updates' ); @@ -155,7 +155,7 @@ class MessageCacheTest extends MediaWikiLangTestCase { // Populate one key $this->makePage( 'Key1', 'de', 'Value1' ); - $this->assertEquals( 0, + $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount(), 'Post-commit deferred update triggers a run of all updates' ); $this->assertEquals( 'Value1', $messageCache->get( 'Key1' ), 'Key1 was successfully edited' ); @@ -168,7 +168,7 @@ class MessageCacheTest extends MediaWikiLangTestCase { // Populate the second key $this->makePage( 'Key2', 'de', 'Value2' ); - $this->assertEquals( 0, + $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount(), 'Post-commit deferred update triggers a run of all updates' ); $this->assertEquals( 'Value2', $messageCache->get( 'Key2' ), 'Key2 was successfully edited' ); @@ -208,14 +208,14 @@ class MessageCacheTest extends MediaWikiLangTestCase { MessageCache::singleton()->getMsgFromNamespace( 'allpages', $wgContLanguageCode ); - $this->assertEquals( 0, $dbr->trxLevel() ); + $this->assertSame( 0, $dbr->trxLevel() ); $dbr->setFlag( DBO_TRX, $dbr::REMEMBER_PRIOR ); // make queries trigger TRX MessageCache::singleton()->getMsgFromNamespace( 'go', $wgContLanguageCode ); $dbr->restoreFlags(); - $this->assertEquals( 0, $dbr->trxLevel(), "No DB read queries (content language)" ); + $this->assertSame( 0, $dbr->trxLevel(), "No DB read queries (content language)" ); } public function testNoDBAccessNonContentLanguage() { @@ -223,14 +223,14 @@ class MessageCacheTest extends MediaWikiLangTestCase { MessageCache::singleton()->getMsgFromNamespace( 'allpages/nl', 'nl' ); - $this->assertEquals( 0, $dbr->trxLevel() ); + $this->assertSame( 0, $dbr->trxLevel() ); $dbr->setFlag( DBO_TRX, $dbr::REMEMBER_PRIOR ); // make queries trigger TRX MessageCache::singleton()->getMsgFromNamespace( 'go/nl', 'nl' ); $dbr->restoreFlags(); - $this->assertEquals( 0, $dbr->trxLevel(), "No DB read queries (non-content language)" ); + $this->assertSame( 0, $dbr->trxLevel(), "No DB read queries (non-content language)" ); } /** diff --git a/tests/phpunit/includes/changes/CategoryMembershipChangeTest.php b/tests/phpunit/includes/changes/CategoryMembershipChangeTest.php index 7ad654136d..31929d386a 100644 --- a/tests/phpunit/includes/changes/CategoryMembershipChangeTest.php +++ b/tests/phpunit/includes/changes/CategoryMembershipChangeTest.php @@ -83,12 +83,12 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase { $this->assertEquals( '(recentchanges-page-added-to-category: ' . self::$pageName . ')', self::$lastNotifyArgs[3] ); $this->assertEquals( self::$pageName, self::$lastNotifyArgs[4]->getPrefixedText() ); - $this->assertEquals( 0, self::$lastNotifyArgs[5] ); - $this->assertEquals( 0, self::$lastNotifyArgs[6] ); + $this->assertSame( 0, self::$lastNotifyArgs[5] ); + $this->assertSame( 0, self::$lastNotifyArgs[6] ); $this->assertEquals( null, self::$lastNotifyArgs[7] ); $this->assertEquals( 1, self::$lastNotifyArgs[8] ); $this->assertEquals( null, self::$lastNotifyArgs[9] ); - $this->assertEquals( 0, self::$lastNotifyArgs[10] ); + $this->assertSame( 0, self::$lastNotifyArgs[10] ); } public function testChangeRemovedNoRev() { @@ -103,12 +103,12 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase { $this->assertEquals( '(recentchanges-page-removed-from-category: ' . self::$pageName . ')', self::$lastNotifyArgs[3] ); $this->assertEquals( self::$pageName, self::$lastNotifyArgs[4]->getPrefixedText() ); - $this->assertEquals( 0, self::$lastNotifyArgs[5] ); - $this->assertEquals( 0, self::$lastNotifyArgs[6] ); + $this->assertSame( 0, self::$lastNotifyArgs[5] ); + $this->assertSame( 0, self::$lastNotifyArgs[6] ); $this->assertEquals( null, self::$lastNotifyArgs[7] ); $this->assertEquals( 1, self::$lastNotifyArgs[8] ); $this->assertEquals( null, self::$lastNotifyArgs[9] ); - $this->assertEquals( 0, self::$lastNotifyArgs[10] ); + $this->assertSame( 0, self::$lastNotifyArgs[10] ); } public function testChangeAddedWithRev() { @@ -127,9 +127,9 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase { $this->assertEquals( self::$pageRev->getParentId(), self::$lastNotifyArgs[5] ); $this->assertEquals( $revision->getId(), self::$lastNotifyArgs[6] ); $this->assertEquals( null, self::$lastNotifyArgs[7] ); - $this->assertEquals( 0, self::$lastNotifyArgs[8] ); + $this->assertSame( 0, self::$lastNotifyArgs[8] ); $this->assertEquals( '127.0.0.1', self::$lastNotifyArgs[9] ); - $this->assertEquals( 0, self::$lastNotifyArgs[10] ); + $this->assertSame( 0, self::$lastNotifyArgs[10] ); } public function testChangeRemovedWithRev() { @@ -148,9 +148,9 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase { $this->assertEquals( self::$pageRev->getParentId(), self::$lastNotifyArgs[5] ); $this->assertEquals( $revision->getId(), self::$lastNotifyArgs[6] ); $this->assertEquals( null, self::$lastNotifyArgs[7] ); - $this->assertEquals( 0, self::$lastNotifyArgs[8] ); + $this->assertSame( 0, self::$lastNotifyArgs[8] ); $this->assertEquals( '127.0.0.1', self::$lastNotifyArgs[9] ); - $this->assertEquals( 0, self::$lastNotifyArgs[10] ); + $this->assertSame( 0, self::$lastNotifyArgs[10] ); } } diff --git a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php index 8f914b714a..a59ba7dcff 100644 --- a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php +++ b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php @@ -61,7 +61,7 @@ class RCCacheEntryFactoryTest extends MediaWikiLangTestCase { $this->assertEquals( false, $cacheEntry->watched, 'watched' ); $this->assertEquals( '21:21', $cacheEntry->timestamp, 'timestamp' ); - $this->assertEquals( 0, $cacheEntry->numberofWatchingusers, 'watching users' ); + $this->assertSame( 0, $cacheEntry->numberofWatchingusers, 'watching users' ); $this->assertEquals( false, $cacheEntry->unpatrolled, 'unpatrolled' ); $this->assertUserLinks( $user->getName(), $cacheEntry ); @@ -96,7 +96,7 @@ class RCCacheEntryFactoryTest extends MediaWikiLangTestCase { $this->assertEquals( false, $cacheEntry->watched, 'watched' ); $this->assertEquals( '21:21', $cacheEntry->timestamp, 'timestamp' ); - $this->assertEquals( 0, $cacheEntry->numberofWatchingusers, 'watching users' ); + $this->assertSame( 0, $cacheEntry->numberofWatchingusers, 'watching users' ); $this->assertEquals( false, $cacheEntry->unpatrolled, 'unpatrolled' ); $this->assertDeleteLogLink( $cacheEntry ); @@ -130,7 +130,7 @@ class RCCacheEntryFactoryTest extends MediaWikiLangTestCase { $this->assertEquals( false, $cacheEntry->watched, 'watched' ); $this->assertEquals( '21:21', $cacheEntry->timestamp, 'timestamp' ); - $this->assertEquals( 0, $cacheEntry->numberofWatchingusers, 'watching users' ); + $this->assertSame( 0, $cacheEntry->numberofWatchingusers, 'watching users' ); $this->assertEquals( false, $cacheEntry->unpatrolled, 'unpatrolled' ); $this->assertRevDel( $cacheEntry ); diff --git a/tests/phpunit/includes/context/RequestContextTest.php b/tests/phpunit/includes/context/RequestContextTest.php index 32e71e055c..3bb79e4a0f 100644 --- a/tests/phpunit/includes/context/RequestContextTest.php +++ b/tests/phpunit/includes/context/RequestContextTest.php @@ -49,7 +49,7 @@ class RequestContextTest extends MediaWikiTestCase { $oInfo = $context->exportSession(); $this->assertEquals( '127.0.0.1', $oInfo['ip'], "Correct initial IP address." ); - $this->assertEquals( 0, $oInfo['userId'], "Correct initial user ID." ); + $this->assertSame( 0, $oInfo['userId'], "Correct initial user ID." ); $this->assertFalse( MediaWiki\Session\SessionManager::getGlobalSession()->isPersistent(), 'Global session isn\'t persistent to start' ); diff --git a/tests/phpunit/includes/db/LBFactoryTest.php b/tests/phpunit/includes/db/LBFactoryTest.php index c789e83082..033b3f98d2 100644 --- a/tests/phpunit/includes/db/LBFactoryTest.php +++ b/tests/phpunit/includes/db/LBFactoryTest.php @@ -187,7 +187,7 @@ class LBFactoryTest extends MediaWikiTestCase { }; $factory = $this->newLBFactoryMultiLBs(); - $this->assertEquals( 0, $countLBsFunc( $factory ) ); + $this->assertSame( 0, $countLBsFunc( $factory ) ); $dbw = $factory->getMainLB()->getConnection( DB_MASTER ); $this->assertEquals( 1, $countLBsFunc( $factory ) ); // Test that LoadBalancer instances made during pre-commit callbacks in do not @@ -208,7 +208,7 @@ class LBFactoryTest extends MediaWikiTestCase { $called = 0; $factory = $this->newLBFactoryMultiLBs(); - $this->assertEquals( 0, $countLBsFunc( $factory ) ); + $this->assertSame( 0, $countLBsFunc( $factory ) ); $dbw = $factory->getMainLB()->getConnection( DB_MASTER ); $this->assertEquals( 1, $countLBsFunc( $factory ) ); // Test that LoadBalancer instances made during pre-commit callbacks in do not @@ -717,7 +717,7 @@ class LBFactoryTest extends MediaWikiTestCase { $lb->forEachOpenConnection( function () use ( &$n ) { ++$n; } ); - $this->assertEquals( 0, $n, "Connections closed" ); + $this->assertSame( 0, $n, "Connections closed" ); $conn2 = $lb->getConnectionRef( DB_MASTER ); $this->assertEquals( diff --git a/tests/phpunit/includes/deferred/SiteStatsUpdateTest.php b/tests/phpunit/includes/deferred/SiteStatsUpdateTest.php index ccfcc181ee..f820f60346 100644 --- a/tests/phpunit/includes/deferred/SiteStatsUpdateTest.php +++ b/tests/phpunit/includes/deferred/SiteStatsUpdateTest.php @@ -20,8 +20,8 @@ class SiteStatsUpdateTest extends MediaWikiTestCase { $this->assertEquals( 1, $wrapped->pages ); $this->assertEquals( 3, $wrapped->users ); $this->assertEquals( 1, $wrapped->images ); - $this->assertEquals( 0, $wrapped->edits ); - $this->assertEquals( 0, $wrapped->articles ); + $this->assertSame( 0, $wrapped->edits ); + $this->assertSame( 0, $wrapped->articles ); } /** @@ -42,7 +42,7 @@ class SiteStatsUpdateTest extends MediaWikiTestCase { $fi = SiteStats::images(); $ai = SiteStats::articles(); - $this->assertEquals( 0, DeferredUpdates::pendingUpdatesCount() ); + $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount() ); $dbw->begin( __METHOD__ ); // block opportunistic updates @@ -64,7 +64,7 @@ class SiteStatsUpdateTest extends MediaWikiTestCase { $this->assertEquals( 1, DeferredUpdates::pendingUpdatesCount() ); DeferredUpdates::doUpdates(); - $this->assertEquals( 0, DeferredUpdates::pendingUpdatesCount() ); + $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount() ); SiteStats::unload(); $this->assertEquals( $pi + 2, SiteStats::pages(), 'page count' ); diff --git a/tests/phpunit/includes/filebackend/FileBackendTest.php b/tests/phpunit/includes/filebackend/FileBackendTest.php index e344d57d42..7bc7918776 100644 --- a/tests/phpunit/includes/filebackend/FileBackendTest.php +++ b/tests/phpunit/includes/filebackend/FileBackendTest.php @@ -2554,7 +2554,7 @@ class FileBackendTest extends MediaWikiTestCase { $be->getReadIndexFromParams( [ 'latest' => 1 ] ), 'Reads with "latest" flag use backend 1' ); - $this->assertEquals( + $this->assertSame( 0, $be->getReadIndexFromParams( [ 'latest' => 0 ] ), 'Reads without "latest" flag use backend 0' diff --git a/tests/phpunit/includes/http/GuzzleHttpRequestTest.php b/tests/phpunit/includes/http/GuzzleHttpRequestTest.php index c9356b6b10..ff0a9eb0bc 100644 --- a/tests/phpunit/includes/http/GuzzleHttpRequestTest.php +++ b/tests/phpunit/includes/http/GuzzleHttpRequestTest.php @@ -109,7 +109,7 @@ class GuzzleHttpRequestTest extends MediaWikiTestCase { $s = $r->execute(); $errorMsg = $s->getErrorsByType( 'error' )[0]['message']; - $this->assertEquals( 0, $r->getStatus() ); + $this->assertSame( 0, $r->getStatus() ); $this->assertEquals( 'http-invalid-url', $errorMsg ); } @@ -121,7 +121,7 @@ class GuzzleHttpRequestTest extends MediaWikiTestCase { $s = $r->execute(); $errorMsg = $s->getErrorsByType( 'error' )[0]['message']; - $this->assertEquals( 0, $r->getStatus() ); + $this->assertSame( 0, $r->getStatus() ); $this->assertEquals( 'http-request-error', $errorMsg ); } @@ -133,7 +133,7 @@ class GuzzleHttpRequestTest extends MediaWikiTestCase { $s = $r->execute(); $errorMsg = $s->getErrorsByType( 'error' )[0]['message']; - $this->assertEquals( 0, $r->getStatus() ); + $this->assertSame( 0, $r->getStatus() ); $this->assertEquals( 'http-timed-out', $errorMsg ); } diff --git a/tests/phpunit/includes/jobqueue/JobQueueTest.php b/tests/phpunit/includes/jobqueue/JobQueueTest.php index 8f8dde5559..1db708540f 100644 --- a/tests/phpunit/includes/jobqueue/JobQueueTest.php +++ b/tests/phpunit/includes/jobqueue/JobQueueTest.php @@ -108,8 +108,8 @@ class JobQueueTest extends MediaWikiTestCase { $this->assertTrue( $queue->isEmpty(), "Queue is empty ($desc)" ); $queue->flushCaches(); - $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" ); - $this->assertEquals( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" ); + $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" ); + $this->assertSame( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" ); $this->assertNull( $queue->push( $this->newJob() ), "Push worked ($desc)" ); $this->assertNull( $queue->batchPush( [ $this->newJob() ] ), "Push worked ($desc)" ); @@ -118,7 +118,7 @@ class JobQueueTest extends MediaWikiTestCase { $queue->flushCaches(); $this->assertEquals( 2, $queue->getSize(), "Queue size is correct ($desc)" ); - $this->assertEquals( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" ); + $this->assertSame( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" ); $jobs = iterator_to_array( $queue->getAllQueuedJobs() ); $this->assertEquals( 2, count( $jobs ), "Queue iterator size is correct ($desc)" ); @@ -135,7 +135,7 @@ class JobQueueTest extends MediaWikiTestCase { $job2 = $queue->pop(); $this->assertTrue( $queue->isEmpty(), "Queue is empty ($desc)" ); - $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" ); + $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" ); $queue->flushCaches(); if ( $recycles ) { @@ -152,7 +152,7 @@ class JobQueueTest extends MediaWikiTestCase { $queue->ack( $job2 ); $queue->flushCaches(); - $this->assertEquals( 0, $queue->getAcquiredCount(), "Active job count ($desc)" ); + $this->assertSame( 0, $queue->getAcquiredCount(), "Active job count ($desc)" ); $this->assertNull( $queue->batchPush( [ $this->newJob(), $this->newJob() ] ), "Push worked ($desc)" ); @@ -161,7 +161,7 @@ class JobQueueTest extends MediaWikiTestCase { $queue->delete(); $queue->flushCaches(); $this->assertTrue( $queue->isEmpty(), "Queue is empty ($desc)" ); - $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" ); + $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" ); } /** @@ -177,8 +177,8 @@ class JobQueueTest extends MediaWikiTestCase { $this->assertTrue( $queue->isEmpty(), "Queue is empty ($desc)" ); $queue->flushCaches(); - $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" ); - $this->assertEquals( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" ); + $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" ); + $this->assertSame( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" ); $this->assertNull( $queue->batchPush( @@ -190,7 +190,7 @@ class JobQueueTest extends MediaWikiTestCase { $queue->flushCaches(); $this->assertEquals( 1, $queue->getSize(), "Queue size is correct ($desc)" ); - $this->assertEquals( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" ); + $this->assertSame( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" ); $this->assertNull( $queue->batchPush( @@ -203,13 +203,13 @@ class JobQueueTest extends MediaWikiTestCase { $queue->flushCaches(); $this->assertEquals( 1, $queue->getSize(), "Queue size is correct ($desc)" ); - $this->assertEquals( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" ); + $this->assertSame( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" ); $job1 = $queue->pop(); $this->assertTrue( $queue->isEmpty(), "Queue is empty ($desc)" ); $queue->flushCaches(); - $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" ); + $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" ); if ( $recycles ) { $this->assertEquals( 1, $queue->getAcquiredCount(), "Active job count ($desc)" ); } @@ -217,7 +217,7 @@ class JobQueueTest extends MediaWikiTestCase { $queue->ack( $job1 ); $queue->flushCaches(); - $this->assertEquals( 0, $queue->getAcquiredCount(), "Active job count ($desc)" ); + $this->assertSame( 0, $queue->getAcquiredCount(), "Active job count ($desc)" ); } /** @@ -256,8 +256,8 @@ class JobQueueTest extends MediaWikiTestCase { $this->assertTrue( $queue->isEmpty(), "Queue is empty ($desc)" ); $queue->flushCaches(); - $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" ); - $this->assertEquals( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" ); + $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" ); + $this->assertSame( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" ); $root1 = Job::newRootJobParams( "nulljobspam:testId" ); // task ID/timestamp for ( $i = 0; $i < 5; ++$i ) { @@ -282,7 +282,7 @@ class JobQueueTest extends MediaWikiTestCase { $queue->flushCaches(); $this->assertEquals( 10, $queue->getSize(), "Queue size is correct ($desc)" ); - $this->assertEquals( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" ); + $this->assertSame( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" ); $dupcount = 0; $jobs = []; @@ -314,8 +314,8 @@ class JobQueueTest extends MediaWikiTestCase { $this->assertTrue( $queue->isEmpty(), "Queue is empty ($desc)" ); $queue->flushCaches(); - $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" ); - $this->assertEquals( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" ); + $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" ); + $this->assertSame( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" ); for ( $i = 0; $i < 10; ++$i ) { $this->assertNull( $queue->push( $this->newJob( $i ) ), "Push worked ($desc)" ); @@ -332,8 +332,8 @@ class JobQueueTest extends MediaWikiTestCase { $this->assertFalse( $queue->pop(), "Queue is not empty ($desc)" ); $queue->flushCaches(); - $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" ); - $this->assertEquals( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" ); + $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" ); + $this->assertSame( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" ); } /** diff --git a/tests/phpunit/includes/jobqueue/jobs/ClearUserWatchlistJobTest.php b/tests/phpunit/includes/jobqueue/jobs/ClearUserWatchlistJobTest.php index 90b57f2aff..c7596bf46f 100644 --- a/tests/phpunit/includes/jobqueue/jobs/ClearUserWatchlistJobTest.php +++ b/tests/phpunit/includes/jobqueue/jobs/ClearUserWatchlistJobTest.php @@ -66,7 +66,7 @@ class ClearUserWatchlistJobTest extends MediaWikiTestCase { $this->assertEquals( 1, JobQueueGroup::singleton()->getQueueSizes()['clearUserWatchlist'] ); $this->assertEquals( 2, $watchedItemStore->countWatchedItems( $user ) ); $this->runJobs( 1 ); - $this->assertEquals( 0, JobQueueGroup::singleton()->getQueueSizes()['clearUserWatchlist'] ); + $this->assertSame( 0, JobQueueGroup::singleton()->getQueueSizes()['clearUserWatchlist'] ); $this->assertEquals( 2, $watchedItemStore->countWatchedItems( $user ) ); $this->assertTrue( $watchedItemStore->isWatched( $user, new TitleValue( 0, 'C' ) ) ); diff --git a/tests/phpunit/includes/libs/ProcessCacheLRUTest.php b/tests/phpunit/includes/libs/ProcessCacheLRUTest.php index 8e91e70cb0..78af366e6b 100644 --- a/tests/phpunit/includes/libs/ProcessCacheLRUTest.php +++ b/tests/phpunit/includes/libs/ProcessCacheLRUTest.php @@ -16,7 +16,7 @@ class ProcessCacheLRUTest extends PHPUnit\Framework\TestCase { * Compare against an array so we get the cache content difference. */ protected function assertCacheEmpty( $cache, $msg = 'Cache should be empty' ) { - $this->assertEquals( 0, $cache->getEntriesCount(), $msg ); + $this->assertSame( 0, $cache->getEntriesCount(), $msg ); } /** diff --git a/tests/phpunit/includes/libs/TimingTest.php b/tests/phpunit/includes/libs/TimingTest.php index 581a518626..90abd8cf7d 100644 --- a/tests/phpunit/includes/libs/TimingTest.php +++ b/tests/phpunit/includes/libs/TimingTest.php @@ -55,7 +55,7 @@ class TimingTest extends PHPUnit\Framework\TestCase { $this->assertEquals( 'a', $entry['name'] ); $this->assertEquals( 'mark', $entry['entryType'] ); $this->assertArrayHasKey( 'startTime', $entry ); - $this->assertEquals( 0, $entry['duration'] ); + $this->assertSame( 0, $entry['duration'] ); usleep( 100 ); $timing->mark( 'a' ); diff --git a/tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php b/tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php index 332e23b25b..3e082503c1 100644 --- a/tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php +++ b/tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php @@ -82,7 +82,7 @@ class HashBagOStuffTest extends PHPUnit\Framework\TestCase { $cache->set( 'bar', 1, 10 ); $cache->set( 'baz', 1, -10 ); - $this->assertEquals( 0, $cacheInternal->bag['foo'][$cache::KEY_EXP], 'Indefinite' ); + $this->assertSame( 0, $cacheInternal->bag['foo'][$cache::KEY_EXP], 'Indefinite' ); // 2 seconds tolerance $this->assertEquals( time() + 10, $cacheInternal->bag['bar'][$cache::KEY_EXP], 'Future', 2 ); $this->assertEquals( time() - 10, $cacheInternal->bag['baz'][$cache::KEY_EXP], 'Past', 2 ); diff --git a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php index ac988e6467..ba2b435bf3 100644 --- a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php +++ b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php @@ -318,7 +318,7 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { $v = $cache->getWithSetCallback( $key, 30, $func, [ 'lowTTL' => 0, 'lockTSE' => 5 ] + $extOpts ); $this->assertEquals( $value, $v, "Value returned" ); - $this->assertEquals( 0, $wasSet, "Value not regenerated" ); + $this->assertSame( 0, $wasSet, "Value not regenerated" ); $mockWallClock += 1; @@ -584,7 +584,7 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { $asycList[0](); // run the refresh callback $asycList = []; $this->assertEquals( 2, $wasSet, "Value calculated at later time" ); - $this->assertEquals( 0, count( $asycList ), "No deferred refreshes added." ); + $this->assertSame( 0, count( $asycList ), "No deferred refreshes added." ); $v = $cache->getWithSetCallback( $key, 300, $func, $opts ); $this->assertEquals( $value, $v, "New value stored" ); @@ -678,13 +678,13 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { $keyedIds, 30, $genFunc, [ 'lowTTL' => 0, 'lockTSE' => 5 ] + $extOpts ); $this->assertEquals( $value, $v[$keyB], "Value returned" ); $this->assertEquals( 1, $wasSet, "Value regenerated" ); - $this->assertEquals( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" ); + $this->assertSame( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" ); $v = $cache->getMultiWithSetCallback( $keyedIds, 30, $genFunc, [ 'lowTTL' => 0, 'lockTSE' => 5 ] + $extOpts ); $this->assertEquals( $value, $v[$keyB], "Value returned" ); $this->assertEquals( 1, $wasSet, "Value not regenerated" ); - $this->assertEquals( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" ); + $this->assertSame( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" ); $mockWallClock += 1; @@ -846,13 +846,13 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { $keyedIds, 30, $genFunc, [ 'lowTTL' => 0 ] + $extOpts ); $this->assertEquals( $value, $v[$keyB], "Value returned" ); $this->assertEquals( 1, $wasSet, "Value regenerated" ); - $this->assertEquals( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" ); + $this->assertSame( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" ); $v = $cache->getMultiWithUnionSetCallback( $keyedIds, 30, $genFunc, [ 'lowTTL' => 0 ] + $extOpts ); $this->assertEquals( $value, $v[$keyB], "Value returned" ); $this->assertEquals( 1, $wasSet, "Value not regenerated" ); - $this->assertEquals( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" ); + $this->assertSame( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" ); $mockWallClock += 1; @@ -1478,7 +1478,7 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { $wasSet = 0; $v = $cache->getWithSetCallback( $key, 30, $funcV2, $verOpts + $extOpts ); $this->assertEquals( $valueV2, $v, "Value not regenerated (secondary key)" ); - $this->assertEquals( 0, $wasSet, "Value not regenerated (secondary key)" ); + $this->assertSame( 0, $wasSet, "Value not regenerated (secondary key)" ); // Clear out the older or unversioned key $cache->delete( $key, 0 ); diff --git a/tests/phpunit/includes/libs/rdbms/database/DatabaseSQLTest.php b/tests/phpunit/includes/libs/rdbms/database/DatabaseSQLTest.php index 4419533fed..16f6a6c053 100644 --- a/tests/phpunit/includes/libs/rdbms/database/DatabaseSQLTest.php +++ b/tests/phpunit/includes/libs/rdbms/database/DatabaseSQLTest.php @@ -2014,7 +2014,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->database->startAtomic( __METHOD__ ); $wrapper->trxStatus = Database::STATUS_TRX_ERROR; $this->database->rollback( __METHOD__ ); - $this->assertEquals( 0, $this->database->trxLevel() ); + $this->assertSame( 0, $this->database->trxLevel() ); $this->assertEquals( Database::STATUS_TRX_NONE, $wrapper->trxStatus() ); $this->assertLastSql( 'BEGIN; ROLLBACK' ); @@ -2024,7 +2024,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->database->endAtomic( __METHOD__ ); $this->assertEquals( Database::STATUS_TRX_NONE, $wrapper->trxStatus() ); $this->assertLastSql( 'BEGIN; DELETE FROM x WHERE field = \'1\'; COMMIT' ); - $this->assertEquals( 0, $this->database->trxLevel(), 'Use after rollback()' ); + $this->assertSame( 0, $this->database->trxLevel(), 'Use after rollback()' ); $this->database->begin( __METHOD__ ); $this->database->startAtomic( __METHOD__, Database::ATOMIC_CANCELABLE ); @@ -2038,7 +2038,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->database->commit( __METHOD__ ); // phpcs:ignore Generic.Files.LineLength $this->assertLastSql( 'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; UPDATE y SET a = \'1\' WHERE field = \'1\'; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1; DELETE FROM y WHERE field = \'1\'; COMMIT' ); - $this->assertEquals( 0, $this->database->trxLevel(), 'Use after rollback()' ); + $this->assertSame( 0, $this->database->trxLevel(), 'Use after rollback()' ); // Next transaction $this->database->startAtomic( __METHOD__ ); @@ -2047,7 +2047,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->database->endAtomic( __METHOD__ ); $this->assertEquals( Database::STATUS_TRX_NONE, $wrapper->trxStatus() ); $this->assertLastSql( 'BEGIN; DELETE FROM x WHERE field = \'3\'; COMMIT' ); - $this->assertEquals( 0, $this->database->trxLevel() ); + $this->assertSame( 0, $this->database->trxLevel() ); } /** @@ -2194,7 +2194,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->assertFalse( $this->database->isOpen() ); $this->assertLastSql( 'BEGIN; DELETE FROM x WHERE field = \'3\'; ROLLBACK; SELECT 2' ); - $this->assertEquals( 0, $this->database->trxLevel() ); + $this->assertSame( 0, $this->database->trxLevel() ); } /** @@ -2223,7 +2223,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->assertFalse( $this->database->isOpen() ); $this->assertLastSql( 'BEGIN; DELETE FROM x WHERE field = \'3\'; ROLLBACK; SELECT 2' ); - $this->assertEquals( 0, $this->database->trxLevel() ); + $this->assertSame( 0, $this->database->trxLevel() ); } /** @@ -2246,7 +2246,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->assertFalse( $this->database->isOpen() ); $this->assertLastSql( 'BEGIN; DELETE FROM x WHERE field = \'3\'; ROLLBACK' ); - $this->assertEquals( 0, $this->database->trxLevel() ); + $this->assertSame( 0, $this->database->trxLevel() ); } /** @@ -2261,7 +2261,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase { $this->assertFalse( $this->database->isOpen() ); $this->assertLastSql( 'BEGIN; SELECT 1; ROLLBACK' ); - $this->assertEquals( 0, $this->database->trxLevel() ); + $this->assertSame( 0, $this->database->trxLevel() ); } /** diff --git a/tests/phpunit/includes/libs/rdbms/database/DatabaseTest.php b/tests/phpunit/includes/libs/rdbms/database/DatabaseTest.php index 93b1bf82ba..fddbab2b37 100644 --- a/tests/phpunit/includes/libs/rdbms/database/DatabaseTest.php +++ b/tests/phpunit/includes/libs/rdbms/database/DatabaseTest.php @@ -490,13 +490,13 @@ class DatabaseTest extends PHPUnit\Framework\TestCase { $db->method( 'isOpen' )->willReturn( true ); $db->method( 'getDBname' )->willReturn( 'unittest' ); - $this->assertEquals( 0, $db->trxLevel() ); + $this->assertSame( 0, $db->trxLevel() ); $this->assertEquals( true, $db->lockIsFree( 'x', __METHOD__ ) ); $this->assertEquals( true, $db->lock( 'x', __METHOD__ ) ); $this->assertEquals( false, $db->lockIsFree( 'x', __METHOD__ ) ); $this->assertEquals( true, $db->unlock( 'x', __METHOD__ ) ); $this->assertEquals( true, $db->lockIsFree( 'x', __METHOD__ ) ); - $this->assertEquals( 0, $db->trxLevel() ); + $this->assertSame( 0, $db->trxLevel() ); $db->setFlag( DBO_TRX ); $this->assertEquals( true, $db->lockIsFree( 'x', __METHOD__ ) ); @@ -507,7 +507,7 @@ class DatabaseTest extends PHPUnit\Framework\TestCase { $db->clearFlag( DBO_TRX ); // Pending writes with DBO_TRX - $this->assertEquals( 0, $db->trxLevel() ); + $this->assertSame( 0, $db->trxLevel() ); $this->assertTrue( $db->lockIsFree( 'meow', __METHOD__ ) ); $db->setFlag( DBO_TRX ); $db->query( "DELETE FROM test WHERE t = 1" ); // trigger DBO_TRX transaction before lock @@ -521,7 +521,7 @@ class DatabaseTest extends PHPUnit\Framework\TestCase { $db->rollback( __METHOD__, IDatabase::FLUSHING_ALL_PEERS ); // Pending writes without DBO_TRX $db->clearFlag( DBO_TRX ); - $this->assertEquals( 0, $db->trxLevel() ); + $this->assertSame( 0, $db->trxLevel() ); $this->assertTrue( $db->lockIsFree( 'meow2', __METHOD__ ) ); $db->begin( __METHOD__ ); $db->query( "DELETE FROM test WHERE t = 1" ); // trigger DBO_TRX transaction before lock @@ -535,17 +535,17 @@ class DatabaseTest extends PHPUnit\Framework\TestCase { $db->rollback( __METHOD__ ); // No pending writes, with DBO_TRX $db->setFlag( DBO_TRX ); - $this->assertEquals( 0, $db->trxLevel() ); + $this->assertSame( 0, $db->trxLevel() ); $this->assertTrue( $db->lockIsFree( 'wuff', __METHOD__ ) ); $db->query( "SELECT 1", __METHOD__ ); $this->assertEquals( 1, $db->trxLevel() ); $lock = $db->getScopedLockAndFlush( 'wuff', __METHOD__, 1 ); - $this->assertEquals( 0, $db->trxLevel() ); + $this->assertSame( 0, $db->trxLevel() ); $this->assertFalse( $db->lockIsFree( 'wuff', __METHOD__ ), 'Lock already acquired' ); $db->rollback( __METHOD__, IDatabase::FLUSHING_ALL_PEERS ); // No pending writes, without DBO_TRX $db->clearFlag( DBO_TRX ); - $this->assertEquals( 0, $db->trxLevel() ); + $this->assertSame( 0, $db->trxLevel() ); $this->assertTrue( $db->lockIsFree( 'wuff2', __METHOD__ ) ); $db->begin( __METHOD__ ); try { diff --git a/tests/phpunit/includes/media/JpegPixelFormatTest.php b/tests/phpunit/includes/media/JpegPixelFormatTest.php index 630df54335..8d0ddf8df4 100644 --- a/tests/phpunit/includes/media/JpegPixelFormatTest.php +++ b/tests/phpunit/includes/media/JpegPixelFormatTest.php @@ -54,7 +54,7 @@ class JpegPixelFormatTest extends MediaWikiMediaTestCase { '%[jpeg:sampling-factor]', $path )->execute(); - $this->assertEquals( 0, + $this->assertSame( 0, $result->getExitCode(), "ImageMagick's identify command should return success" ); diff --git a/tests/phpunit/includes/media/PNGMetadataExtractorTest.php b/tests/phpunit/includes/media/PNGMetadataExtractorTest.php index 22de935793..4d7ff48bbc 100644 --- a/tests/phpunit/includes/media/PNGMetadataExtractorTest.php +++ b/tests/phpunit/includes/media/PNGMetadataExtractorTest.php @@ -72,9 +72,9 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase { $meta = PNGMetadataExtractor::getMetadata( $this->filePath . 'Png-native-test.png' ); - $this->assertEquals( 0, $meta['frameCount'] ); + $this->assertSame( 0, $meta['frameCount'] ); $this->assertEquals( 1, $meta['loopCount'] ); - $this->assertEquals( 0, $meta['duration'] ); + $this->assertSame( 0.0, $meta['duration'] ); } /** @@ -87,7 +87,7 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase { $this->assertEquals( 20, $meta['frameCount'] ); // Note loop count of 0 = infinity - $this->assertEquals( 0, $meta['loopCount'] ); + $this->assertSame( 0, $meta['loopCount'] ); $this->assertEquals( 1.5, $meta['duration'], '', 0.00001 ); } diff --git a/tests/phpunit/includes/page/WikiPageDbTestBase.php b/tests/phpunit/includes/page/WikiPageDbTestBase.php index f071e4b198..f0d895ee9e 100644 --- a/tests/phpunit/includes/page/WikiPageDbTestBase.php +++ b/tests/phpunit/includes/page/WikiPageDbTestBase.php @@ -439,7 +439,7 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase { $n = $res->numRows(); $res->free(); - $this->assertEquals( 0, $n, 'pagelinks should contain no more links from the page' ); + $this->assertSame( 0, $n, 'pagelinks should contain no more links from the page' ); } /** @@ -637,7 +637,7 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase { $n = $res->numRows(); $res->free(); - $this->assertEquals( 0, $n, 'pagelinks should contain no more links from the page' ); + $this->assertSame( 0, $n, 'pagelinks should contain no more links from the page' ); } /** @@ -1577,20 +1577,20 @@ more stuff $page->updateCategoryCounts( [ 'A' ], [], 0 ); $this->assertEquals( 1, Category::newFromName( 'A' )->getPageCount() ); - $this->assertEquals( 0, Category::newFromName( 'B' )->getPageCount() ); - $this->assertEquals( 0, Category::newFromName( 'C' )->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->assertEquals( 0, Category::newFromName( 'C' )->getPageCount() ); + $this->assertSame( 0, Category::newFromName( 'C' )->getPageCount() ); // Add and remove a category $page->updateCategoryCounts( [ 'C' ], [ 'A' ], 0 ); - $this->assertEquals( 0, Category::newFromName( 'A' )->getPageCount() ); + $this->assertSame( 0, Category::newFromName( 'A' )->getPageCount() ); $this->assertEquals( 1, Category::newFromName( 'B' )->getPageCount() ); $this->assertEquals( 1, Category::newFromName( 'C' )->getPageCount() ); } diff --git a/tests/phpunit/includes/search/SearchNearMatchResultSetTest.php b/tests/phpunit/includes/search/SearchNearMatchResultSetTest.php index 67493c4243..8135d573f1 100644 --- a/tests/phpunit/includes/search/SearchNearMatchResultSetTest.php +++ b/tests/phpunit/includes/search/SearchNearMatchResultSetTest.php @@ -7,7 +7,7 @@ class SearchNearMatchResultSetTest extends PHPUnit\Framework\TestCase { */ public function testNumRows() { $resultSet = new SearchNearMatchResultSet( null ); - $this->assertEquals( 0, $resultSet->numRows() ); + $this->assertSame( 0, $resultSet->numRows() ); $resultSet = new SearchNearMatchResultSet( Title::newMainPage() ); $this->assertEquals( 1, $resultSet->numRows() ); diff --git a/tests/phpunit/includes/shell/ShellTest.php b/tests/phpunit/includes/shell/ShellTest.php index 5fb3ac0f5f..0dd88bb868 100644 --- a/tests/phpunit/includes/shell/ShellTest.php +++ b/tests/phpunit/includes/shell/ShellTest.php @@ -65,7 +65,7 @@ class ShellTest extends MediaWikiTestCase { $wrapper = TestingAccessWrapper::newFromObject( $command ); $this->assertEquals( $expected, $wrapper->command ); - $this->assertEquals( 0, $wrapper->restrictions & Shell::NO_LOCALSETTINGS ); + $this->assertSame( 0, $wrapper->restrictions & Shell::NO_LOCALSETTINGS ); } public function provideMakeScriptCommand() { diff --git a/tests/phpunit/includes/site/CachingSiteStoreTest.php b/tests/phpunit/includes/site/CachingSiteStoreTest.php index df12eba765..fc04fb7066 100644 --- a/tests/phpunit/includes/site/CachingSiteStoreTest.php +++ b/tests/phpunit/includes/site/CachingSiteStoreTest.php @@ -149,7 +149,7 @@ class CachingSiteStoreTest extends \MediaWikiIntegrationTestCase { $this->assertNull( $site ); $sites = $store->getSites(); - $this->assertEquals( 0, $sites->count() ); + $this->assertSame( 0, $sites->count() ); } /** diff --git a/tests/phpunit/includes/site/DBSiteStoreTest.php b/tests/phpunit/includes/site/DBSiteStoreTest.php index 14ee15b635..e125d71741 100644 --- a/tests/phpunit/includes/site/DBSiteStoreTest.php +++ b/tests/phpunit/includes/site/DBSiteStoreTest.php @@ -138,7 +138,7 @@ class DBSiteStoreTest extends MediaWikiTestCase { $this->assertNull( $site ); $sites = $store->getSites(); - $this->assertEquals( 0, $sites->count() ); + $this->assertSame( 0, $sites->count() ); } /** diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php index 2a4ba4bc06..f24255b8da 100644 --- a/tests/phpunit/includes/user/UserTest.php +++ b/tests/phpunit/includes/user/UserTest.php @@ -559,10 +559,10 @@ class UserTest extends MediaWikiTestCase { $this->markTestSkippedIfDbType( 'postgres' ); $users = User::findUsersByGroup( [] ); - $this->assertEquals( 0, iterator_count( $users ) ); + $this->assertSame( 0, iterator_count( $users ) ); $users = User::findUsersByGroup( 'foo' ); - $this->assertEquals( 0, iterator_count( $users ) ); + $this->assertSame( 0, iterator_count( $users ) ); $user = $this->getMutableTestUser( [ 'foo' ] )->getUser(); $users = User::findUsersByGroup( 'foo' ); diff --git a/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php b/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php index fbb893e204..e40417c63c 100644 --- a/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php +++ b/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php @@ -1180,7 +1180,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { $this->assertInstanceOf( WatchedItem::class, $watchedItem ); $this->assertEquals( 1, $watchedItem->getUser()->getId() ); $this->assertEquals( 'SomeDbKey', $watchedItem->getLinkTarget()->getDBkey() ); - $this->assertEquals( 0, $watchedItem->getLinkTarget()->getNamespace() ); + $this->assertSame( 0, $watchedItem->getLinkTarget()->getNamespace() ); } public function testLoadWatchedItem_noItem() { @@ -1382,7 +1382,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { $this->assertInstanceOf( WatchedItem::class, $watchedItem ); $this->assertEquals( 1, $watchedItem->getUser()->getId() ); $this->assertEquals( 'SomeDbKey', $watchedItem->getLinkTarget()->getDBkey() ); - $this->assertEquals( 0, $watchedItem->getLinkTarget()->getNamespace() ); + $this->assertSame( 0, $watchedItem->getLinkTarget()->getNamespace() ); } public function testGetWatchedItem_cachedItem() { diff --git a/tests/phpunit/integration/includes/db/DatabaseSqliteTest.php b/tests/phpunit/integration/includes/db/DatabaseSqliteTest.php index 53edbf2688..77fcff27f3 100644 --- a/tests/phpunit/integration/includes/db/DatabaseSqliteTest.php +++ b/tests/phpunit/integration/includes/db/DatabaseSqliteTest.php @@ -233,7 +233,7 @@ class DatabaseSqliteTest extends \MediaWikiIntegrationTestCase { $index = $indexList->next(); $this->assertEquals( 'baz_index2', $index->name ); $this->assertEquals( '1', $index->unique ); - $this->assertEquals( 0, + $this->assertSame( 0, $db->selectField( 'sqlite_master', 'COUNT(*)', [ 'name' => 'baz' ] ), 'Create a temporary duplicate only' ); @@ -524,7 +524,7 @@ class DatabaseSqliteTest extends \MediaWikiIntegrationTestCase { $databaseCreation = $db->query( 'CREATE TABLE a ( a_1 )', __METHOD__ ); $this->assertInstanceOf( ResultWrapper::class, $databaseCreation, "Failed to create table a" ); $res = $db->select( 'a', '*' ); - $this->assertEquals( 0, $db->numFields( $res ), "expects to get 0 fields for an empty table" ); + $this->assertSame( 0, $db->numFields( $res ), "expects to get 0 fields for an empty table" ); $insertion = $db->insert( 'a', [ 'a_1' => 10 ], __METHOD__ ); $this->assertTrue( $insertion, "Insertion failed" ); $res = $db->select( 'a', '*' ); diff --git a/tests/phpunit/unit/includes/diff/DiffOpTest.php b/tests/phpunit/unit/includes/diff/DiffOpTest.php index 4e1aced7a6..17487acbca 100644 --- a/tests/phpunit/unit/includes/diff/DiffOpTest.php +++ b/tests/phpunit/unit/includes/diff/DiffOpTest.php @@ -50,7 +50,7 @@ class DiffOpTest extends \MediaWikiUnitTestCase { */ public function testNorig() { $obj = new FakeDiffOp(); - $this->assertEquals( 0, $obj->norig() ); + $this->assertSame( 0, $obj->norig() ); $obj->orig = [ 'foo' ]; $this->assertEquals( 1, $obj->norig() ); } @@ -60,7 +60,7 @@ class DiffOpTest extends \MediaWikiUnitTestCase { */ public function testNclosing() { $obj = new FakeDiffOp(); - $this->assertEquals( 0, $obj->nclosing() ); + $this->assertSame( 0, $obj->nclosing() ); $obj->closing = [ 'foo' ]; $this->assertEquals( 1, $obj->nclosing() ); } diff --git a/tests/phpunit/unit/includes/search/SearchSuggestionSetTest.php b/tests/phpunit/unit/includes/search/SearchSuggestionSetTest.php index fb0309def5..fce21f7638 100644 --- a/tests/phpunit/unit/includes/search/SearchSuggestionSetTest.php +++ b/tests/phpunit/unit/includes/search/SearchSuggestionSetTest.php @@ -27,7 +27,7 @@ class SearchSuggestionSetTest extends \MediaWikiUnitTestCase { */ public function testAppend() { $set = SearchSuggestionSet::emptySuggestionSet(); - $this->assertEquals( 0, $set->getSize() ); + $this->assertSame( 0, $set->getSize() ); $set->append( new SearchSuggestion( 3 ) ); $this->assertEquals( 3, $set->getWorstScore() ); $this->assertEquals( 3, $set->getBestScore() ); @@ -61,7 +61,7 @@ class SearchSuggestionSetTest extends \MediaWikiUnitTestCase { */ public function testInsertBest() { $set = SearchSuggestionSet::emptySuggestionSet(); - $this->assertEquals( 0, $set->getSize() ); + $this->assertSame( 0, $set->getSize() ); $set->prepend( new SearchSuggestion( 3 ) ); $this->assertEquals( 3, $set->getWorstScore() ); $this->assertEquals( 3, $set->getBestScore() ); @@ -104,7 +104,7 @@ class SearchSuggestionSetTest extends \MediaWikiUnitTestCase { $this->assertEquals( 10, $set->getSize() ); $set->shrink( 0 ); - $this->assertEquals( 0, $set->getSize() ); + $this->assertSame( 0, $set->getSize() ); } // TODO: test for fromTitles -- 2.20.1