Merge "Prefer strict assertSame() for all numeric assertions"

This commit is contained in:
jenkins-bot 2019-10-24 07:12:31 +00:00 committed by Gerrit Code Review
commit 41fd67da53
6 changed files with 26 additions and 30 deletions

View file

@ -139,10 +139,10 @@ class EchoAttributeManagerTest extends MediaWikiTestCase {
'category_four' => [] 'category_four' => []
]; ];
$manager = new EchoAttributeManager( $notif, $category, [], [] ); $manager = new EchoAttributeManager( $notif, $category, [], [] );
$this->assertEquals( 6, $manager->getCategoryPriority( 'category_one' ) ); $this->assertSame( 6, $manager->getCategoryPriority( 'category_one' ) );
$this->assertEquals( 10, $manager->getCategoryPriority( 'category_two' ) ); $this->assertSame( 10, $manager->getCategoryPriority( 'category_two' ) );
$this->assertEquals( 10, $manager->getCategoryPriority( 'category_three' ) ); $this->assertSame( 10, $manager->getCategoryPriority( 'category_three' ) );
$this->assertEquals( 10, $manager->getCategoryPriority( 'category_four' ) ); $this->assertSame( 10, $manager->getCategoryPriority( 'category_four' ) );
} }
public function testGetNotificationPriority() { public function testGetNotificationPriority() {
@ -173,10 +173,10 @@ class EchoAttributeManagerTest extends MediaWikiTestCase {
'category_four' => [] 'category_four' => []
]; ];
$manager = new EchoAttributeManager( $notif, $category, [], [] ); $manager = new EchoAttributeManager( $notif, $category, [], [] );
$this->assertEquals( 6, $manager->getNotificationPriority( 'event_one' ) ); $this->assertSame( 6, $manager->getNotificationPriority( 'event_one' ) );
$this->assertEquals( 10, $manager->getNotificationPriority( 'event_two' ) ); $this->assertSame( 10, $manager->getNotificationPriority( 'event_two' ) );
$this->assertEquals( 10, $manager->getNotificationPriority( 'event_three' ) ); $this->assertSame( 10, $manager->getNotificationPriority( 'event_three' ) );
$this->assertEquals( 10, $manager->getNotificationPriority( 'event_four' ) ); $this->assertSame( 10, $manager->getNotificationPriority( 'event_four' ) );
} }
public static function getEventsForSectionProvider() { public static function getEventsForSectionProvider() {

View file

@ -1014,13 +1014,13 @@ TEXT
$timestampRegex = EchoDiscussionParser::getTimestampRegex(); $timestampRegex = EchoDiscussionParser::getTimestampRegex();
$match = preg_match( '/' . $timestampRegex . '/u', $exemplarTimestamp ); $match = preg_match( '/' . $timestampRegex . '/u', $exemplarTimestamp );
$this->assertEquals( 1, $match ); $this->assertSame( 1, $match );
} }
public function testGetTimestampPosition() { public function testGetTimestampPosition() {
$line = 'Hello World. ' . self::getExemplarTimestamp(); $line = 'Hello World. ' . self::getExemplarTimestamp();
$pos = EchoDiscussionParser::getTimestampPosition( $line ); $pos = EchoDiscussionParser::getTimestampPosition( $line );
$this->assertEquals( 13, $pos ); $this->assertSame( 13, $pos );
} }
/** /**
@ -1041,7 +1041,7 @@ TEXT
$output = EchoDiscussionParser::getUserFromLine( $line ); $output = EchoDiscussionParser::getUserFromLine( $line );
if ( $output === false ) { if ( $output === false ) {
$this->assertEquals( false, $expectedUser ); $this->assertFalse( $expectedUser );
} elseif ( is_array( $expectedUser ) ) { } elseif ( is_array( $expectedUser ) ) {
// Sometimes testing for correct user detection, // Sometimes testing for correct user detection,
// sometimes testing for offset detection // sometimes testing for offset detection
@ -1690,11 +1690,11 @@ TEXT
$two = "===SubZomg===\nHi there\n"; $two = "===SubZomg===\nHi there\n";
$three = "==Header==\nOh Hai!\n"; $three = "==Header==\nOh Hai!\n";
$this->assertEquals( 1, EchoDiscussionParser::getSectionCount( $one ) ); $this->assertSame( 1, EchoDiscussionParser::getSectionCount( $one ) );
$this->assertEquals( 2, EchoDiscussionParser::getSectionCount( $one . $two ) ); $this->assertSame( 2, EchoDiscussionParser::getSectionCount( $one . $two ) );
$this->assertEquals( 2, EchoDiscussionParser::getSectionCount( $one . $three ) ); $this->assertSame( 2, EchoDiscussionParser::getSectionCount( $one . $three ) );
$this->assertEquals( 3, EchoDiscussionParser::getSectionCount( $one . $two . $three ) ); $this->assertSame( 3, EchoDiscussionParser::getSectionCount( $one . $two . $three ) );
$this->assertEquals( 30, EchoDiscussionParser::getSectionCount( $this->assertSame( 30, EchoDiscussionParser::getSectionCount(
file_get_contents( __DIR__ . '/revision_txt/637638133.txt' ) file_get_contents( __DIR__ . '/revision_txt/637638133.txt' )
) ); ) );
} }
@ -1707,7 +1707,7 @@ TEXT
]; ];
$discussionParser = TestingAccessWrapper::newFromClass( EchoDiscussionParser::class ); $discussionParser = TestingAccessWrapper::newFromClass( EchoDiscussionParser::class );
$this->assertEquals( 4, $discussionParser->getOverallUserMentionsCount( $userMentions ) ); $this->assertSame( 4, $discussionParser->getOverallUserMentionsCount( $userMentions ) );
} }
public function provider_getUserMentions() { public function provider_getUserMentions() {
@ -1784,7 +1784,7 @@ TEXT
$title = Title::newFromText( 'Test' ); $title = Title::newFromText( 'Test' );
$discussionParser = TestingAccessWrapper::newFromClass( EchoDiscussionParser::class ); $discussionParser = TestingAccessWrapper::newFromClass( EchoDiscussionParser::class );
$this->assertEquals( 4, $discussionParser->getOverallUserMentionsCount( $discussionParser->getUserMentions( $title, 1, $userLinks ) ) ); $this->assertSame( 4, $discussionParser->getOverallUserMentionsCount( $discussionParser->getUserMentions( $title, 1, $userLinks ) ) );
} }
protected function isParserFunctionsInstalled() { protected function isParserFunctionsInstalled() {

View file

@ -37,7 +37,7 @@ class MWEchoThankYouEditTest extends MediaWikiTestCase {
/** @var EchoNotification $notification */ /** @var EchoNotification $notification */
$notification = reset( $notifications ); $notification = reset( $notifications );
$this->assertEquals( 1, $notification->getEvent()->getExtraParam( 'editCount', 'not found' ) ); $this->assertSame( 1, $notification->getEvent()->getExtraParam( 'editCount', 'not found' ) );
} }
/** /**
@ -66,7 +66,7 @@ class MWEchoThankYouEditTest extends MediaWikiTestCase {
/** @var EchoNotification $notification */ /** @var EchoNotification $notification */
$notification = reset( $notifications ); $notification = reset( $notifications );
$this->assertEquals( 10, $notification->getEvent()->getExtraParam( 'editCount', 'not found' ) ); $this->assertSame( 10, $notification->getEvent()->getExtraParam( 'editCount', 'not found' ) );
} }
private function edit( Title $title, User $user, $text ) { private function edit( Title $title, User $user, $text ) {

View file

@ -29,11 +29,7 @@ class EchoUserLocatorTest extends MediaWikiTestCase {
->will( $this->returnValue( $title ) ); ->will( $this->returnValue( $title ) );
$it = EchoUserLocator::locateUsersWatchingTitle( $event, 10 ); $it = EchoUserLocator::locateUsersWatchingTitle( $event, 10 );
$count = 0; $this->assertCount( 50, $it );
foreach ( $it as $user ) {
++$count;
}
$this->assertEquals( 50, $count );
// @todo assert more than one query was issued // @todo assert more than one query was issued
} }

View file

@ -65,7 +65,7 @@ class EchoTitleLocalCacheTest extends MediaWikiTestCase {
$cache->add( 3 ); $cache->add( 3 );
$cache->clearAll(); $cache->clearAll();
$this->assertSame( null, $cache->get( 1 ), 'Cache was cleared' ); $this->assertNull( $cache->get( 1 ), 'Cache was cleared' );
// Lookups batch was cleared // Lookups batch was cleared
$cache->expects( $this->exactly( 1 ) )->method( 'resolve' ) $cache->expects( $this->exactly( 1 ) )->method( 'resolve' )

View file

@ -58,7 +58,7 @@ class EchoUserNotificationGatewayTest extends MediaWikiUnitTestCase {
$this->mockMWEchoDbFactory( [ 'selectRowCount' => 0 ] ), $this->mockMWEchoDbFactory( [ 'selectRowCount' => 0 ] ),
$this->mockConfig() $this->mockConfig()
); );
$this->assertEquals( 0, $gateway->getCappedNotificationCount( DB_REPLICA, [ 'event_one' ] ) ); $this->assertSame( 0, $gateway->getCappedNotificationCount( DB_REPLICA, [ 'event_one' ] ) );
// successful select of alert // successful select of alert
$gateway = new EchoUserNotificationGateway( $gateway = new EchoUserNotificationGateway(
@ -66,7 +66,7 @@ class EchoUserNotificationGatewayTest extends MediaWikiUnitTestCase {
$this->mockMWEchoDbFactory( [ 'selectRowCount' => 2 ] ), $this->mockMWEchoDbFactory( [ 'selectRowCount' => 2 ] ),
$this->mockConfig() $this->mockConfig()
); );
$this->assertEquals( 2, $gateway->getCappedNotificationCount( DB_REPLICA, [ 'event_one', 'event_two' ] ) ); $this->assertSame( 2, $gateway->getCappedNotificationCount( DB_REPLICA, [ 'event_one', 'event_two' ] ) );
// there is event, should return 0 // there is event, should return 0
$gateway = new EchoUserNotificationGateway( $gateway = new EchoUserNotificationGateway(
@ -74,7 +74,7 @@ class EchoUserNotificationGatewayTest extends MediaWikiUnitTestCase {
$this->mockMWEchoDbFactory( [ 'selectRowCount' => 2 ] ), $this->mockMWEchoDbFactory( [ 'selectRowCount' => 2 ] ),
$this->mockConfig() $this->mockConfig()
); );
$this->assertEquals( 0, $gateway->getCappedNotificationCount( DB_REPLICA, [] ) ); $this->assertSame( 0, $gateway->getCappedNotificationCount( DB_REPLICA, [] ) );
// successful select // successful select
$gateway = new EchoUserNotificationGateway( $gateway = new EchoUserNotificationGateway(
@ -82,7 +82,7 @@ class EchoUserNotificationGatewayTest extends MediaWikiUnitTestCase {
$this->mockMWEchoDbFactory( [ 'selectRowCount' => 3 ] ), $this->mockMWEchoDbFactory( [ 'selectRowCount' => 3 ] ),
$this->mockConfig() $this->mockConfig()
); );
$this->assertEquals( 3, $gateway->getCappedNotificationCount( DB_REPLICA, [ 'event_one' ] ) ); $this->assertSame( 3, $gateway->getCappedNotificationCount( DB_REPLICA, [ 'event_one' ] ) );
} }
public function testGetUnreadNotifications() { public function testGetUnreadNotifications() {