tests: Replace assertEmpty with assertSame

assertSame avoids use of loose comparisons and
allows to check the expected type

Change-Id: I7220be39f824226f55d966474b58ac12491910a3
This commit is contained in:
Umherirrender 2022-11-24 23:03:18 +01:00
parent d7fde11f16
commit bb6cb2de0b
3 changed files with 6 additions and 7 deletions

View file

@ -7,7 +7,6 @@
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
<exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName" />
<exclude name="MediaWiki.PHPUnit.AssertEmpty.AssertEmptyUsed" />
</rule>
<arg name="encoding" value="UTF-8" />
<arg name="extensions" value="php" />

View file

@ -20,7 +20,7 @@ class NotificationMapperTest extends MediaWikiIntegrationTestCase {
// Unsuccessful select
$notifMapper = new NotificationMapper( $this->mockMWEchoDbFactory( [ 'select' => false ] ) );
$res = $notifMapper->fetchUnreadByUser( $this->mockUser(), 10, null, '' );
$this->assertEmpty( $res );
$this->assertSame( [], $res );
// Successful select
$dbResult = [
@ -40,7 +40,7 @@ class NotificationMapperTest extends MediaWikiIntegrationTestCase {
];
$notifMapper = new NotificationMapper( $this->mockMWEchoDbFactory( [ 'select' => $dbResult ] ) );
$res = $notifMapper->fetchUnreadByUser( $this->mockUser(), 10, null, '', [] );
$this->assertEmpty( $res );
$this->assertSame( [], $res );
$notifMapper = new NotificationMapper( $this->mockMWEchoDbFactory( [ 'select' => $dbResult ] ) );
$res = $notifMapper->fetchUnreadByUser( $this->mockUser(), 10, null, '', [ 'test_event' ] );
@ -55,7 +55,7 @@ class NotificationMapperTest extends MediaWikiIntegrationTestCase {
// Unsuccessful select
$notifMapper = new NotificationMapper( $this->mockMWEchoDbFactory( [ 'select' => false ] ) );
$res = $notifMapper->fetchByUser( $this->mockUser(), 10, '' );
$this->assertEmpty( $res );
$this->assertSame( [], $res );
// Successful select
$notifDbResult = [
@ -77,7 +77,7 @@ class NotificationMapperTest extends MediaWikiIntegrationTestCase {
$notifMapper = new NotificationMapper( $this->mockMWEchoDbFactory( [ 'select' => $notifDbResult ] ) );
$res = $notifMapper->fetchByUser( $this->mockUser(), 10, '', [] );
$this->assertEmpty( $res );
$this->assertSame( [], $res );
$notifMapper = new NotificationMapper(
$this->mockMWEchoDbFactory( [ 'select' => $notifDbResult ] )
@ -91,7 +91,7 @@ class NotificationMapperTest extends MediaWikiIntegrationTestCase {
$notifMapper = new NotificationMapper( $this->mockMWEchoDbFactory( [] ) );
$res = $notifMapper->fetchByUser( $this->mockUser(), 10, '' );
$this->assertEmpty( $res );
$this->assertSame( [], $res );
}
public function testFetchByUserOffset() {

View file

@ -92,7 +92,7 @@ class UserNotificationGatewayTest extends MediaWikiUnitTestCase {
$this->mockMWEchoDbFactory( [ 'select' => false ] ),
$this->mockConfig()
);
$this->assertEmpty( $gateway->getUnreadNotifications( 'user_talk' ) );
$this->assertSame( [], $gateway->getUnreadNotifications( 'user_talk' ) );
$dbResult = [
(object)[ 'notification_event' => 1 ],