diff --git a/tests/phpunit/AttributeManagerTest.php b/tests/phpunit/AttributeManagerTest.php index 42ccb992a..099c658e2 100644 --- a/tests/phpunit/AttributeManagerTest.php +++ b/tests/phpunit/AttributeManagerTest.php @@ -6,7 +6,7 @@ class EchoAttributeManagerTest extends MediaWikiTestCase { public function testNewFromGlobalVars() { - $this->assertInstanceOf( 'EchoAttributeManager', EchoAttributeManager::newFromGlobalVars() ); + $this->assertInstanceOf( EchoAttributeManager::class, EchoAttributeManager::newFromGlobalVars() ); } public static function getUserLocatorsProvider() { @@ -479,7 +479,7 @@ class EchoAttributeManagerTest extends MediaWikiTestCase { * Mock object of User */ protected function mockUser() { - $user = $this->getMockBuilder( 'User' ) + $user = $this->getMockBuilder( User::class ) ->disableOriginalConstructor() ->getMock(); $user->expects( $this->any() ) diff --git a/tests/phpunit/BundlerTest.php b/tests/phpunit/BundlerTest.php index a4a2e2581..3e76f4a4f 100644 --- a/tests/phpunit/BundlerTest.php +++ b/tests/phpunit/BundlerTest.php @@ -28,7 +28,7 @@ class BundlerTest extends MediaWikiTestCase { } private function createNotificationForBundling( $bundleHash, $timestamp, $readStatus ) { - $mock = $this->getMockBuilder( 'EchoNotification' ) + $mock = $this->getMockBuilder( EchoNotification::class ) ->disableOriginalConstructor() ->setMethods( [ 'getBundlingKey', diff --git a/tests/phpunit/ContainmentSetTest.php b/tests/phpunit/ContainmentSetTest.php index 1f538291a..4853a69fd 100644 --- a/tests/phpunit/ContainmentSetTest.php +++ b/tests/phpunit/ContainmentSetTest.php @@ -31,7 +31,7 @@ class ContainmentSetTest extends MediaWikiTestCase { $inner = [ 'bing', 'bang' ]; // We use a mock instead of the real thing for the $this->once() assertion // verifying that the cache doesn't just keep asking the inner object - $list = $this->getMockBuilder( 'EchoArrayList' ) + $list = $this->getMockBuilder( EchoArrayList::class ) ->disableOriginalConstructor() ->getMock(); $list->expects( $this->once() ) diff --git a/tests/phpunit/DiscussionParserTest.php b/tests/phpunit/DiscussionParserTest.php index a2757dc20..41c612da7 100644 --- a/tests/phpunit/DiscussionParserTest.php +++ b/tests/phpunit/DiscussionParserTest.php @@ -878,7 +878,7 @@ TEXT * @dataProvider provider_extractSections */ public function testExtractSections( $content, $result ) { - $discussionParser = TestingAccessWrapper::newFromClass( 'EchoDiscussionParser' ); + $discussionParser = TestingAccessWrapper::newFromClass( EchoDiscussionParser::class ); $sections = $discussionParser->extractSections( $content ); $this->assertEquals( $result, $sections ); @@ -979,7 +979,7 @@ TEXT // store diff in some local cache var, to circumvent // EchoDiscussionParser::getChangeInterpretationForRevision's attempt to // retrieve parent revision from DB - $class = new ReflectionClass( 'EchoDiscussionParser' ); + $class = new ReflectionClass( EchoDiscussionParser::class ); $property = $class->getProperty( 'revisionInterpretationCache' ); $property->setAccessible( true ); $property->setValue( [ $revision->getId() => $output ] ); @@ -1698,7 +1698,7 @@ TEXT 'anonymousUsers' => [ '127.0.0.1' ], ]; - $discussionParser = TestingAccessWrapper::newFromClass( 'EchoDiscussionParser' ); + $discussionParser = TestingAccessWrapper::newFromClass( EchoDiscussionParser::class ); $this->assertEquals( 4, $discussionParser->getOverallUserMentionsCount( $userMentions ) ); } @@ -1730,7 +1730,7 @@ TEXT */ public function testGetUserMentions( $userLinks, $expectedUserMentions, $agent ) { $title = Title::newFromText( 'Test' ); - $discussionParser = TestingAccessWrapper::newFromClass( 'EchoDiscussionParser' ); + $discussionParser = TestingAccessWrapper::newFromClass( EchoDiscussionParser::class ); $this->assertEquals( $expectedUserMentions, $discussionParser->getUserMentions( $title, $agent, $userLinks ) ); } @@ -1775,7 +1775,7 @@ TEXT ] ); $title = Title::newFromText( 'Test' ); - $discussionParser = TestingAccessWrapper::newFromClass( 'EchoDiscussionParser' ); + $discussionParser = TestingAccessWrapper::newFromClass( EchoDiscussionParser::class ); $this->assertEquals( 4, $discussionParser->getOverallUserMentionsCount( $discussionParser->getUserMentions( $title, 1, $userLinks ) ) ); } diff --git a/tests/phpunit/EchoDbFactoryTest.php b/tests/phpunit/EchoDbFactoryTest.php index 337c92d34..bf7ddde0c 100644 --- a/tests/phpunit/EchoDbFactoryTest.php +++ b/tests/phpunit/EchoDbFactoryTest.php @@ -10,7 +10,7 @@ class MWEchoDbFactoryTest extends MediaWikiTestCase { public function testNewFromDefault() { $db = MWEchoDbFactory::newFromDefault(); - $this->assertInstanceOf( 'MWEchoDbFactory', $db ); + $this->assertInstanceOf( MWEchoDbFactory::class, $db ); return $db; } @@ -27,7 +27,7 @@ class MWEchoDbFactoryTest extends MediaWikiTestCase { * @depends testNewFromDefault */ public function testGetLB( MWEchoDbFactory $db ) { - $reflection = new ReflectionClass( 'MWEchoDbFactory' ); + $reflection = new ReflectionClass( MWEchoDbFactory::class ); $method = $reflection->getMethod( 'getLB' ); $method->setAccessible( true ); $this->assertInstanceOf( ILoadBalancer::class, $method->invoke( $db ) ); diff --git a/tests/phpunit/NotifUserTest.php b/tests/phpunit/NotifUserTest.php index b25f3dc5b..6369df201 100644 --- a/tests/phpunit/NotifUserTest.php +++ b/tests/phpunit/NotifUserTest.php @@ -32,7 +32,7 @@ class MWEchoNotifUserTest extends MediaWikiTestCase { $this->assertTrue( $exception, "Got exception" ); $notifUser = MWEchoNotifUser::newFromUser( User::newFromId( 2 ) ); - $this->assertInstanceOf( 'MWEchoNotifUser', $notifUser ); + $this->assertInstanceOf( MWEchoNotifUser::class, $notifUser ); } public function testGetEmailFormat() { @@ -113,7 +113,7 @@ class MWEchoNotifUserTest extends MediaWikiTestCase { $dbResult += [ 'markRead' => true ]; - $gateway = $this->getMockBuilder( 'EchoUserNotificationGateway' ) + $gateway = $this->getMockBuilder( EchoUserNotificationGateway::class ) ->disableOriginalConstructor() ->getMock(); $gateway->expects( $this->any() ) @@ -130,7 +130,7 @@ class MWEchoNotifUserTest extends MediaWikiTestCase { } public function mockEchoNotificationMapper( array $result = [] ) { - $mapper = $this->getMockBuilder( 'EchoNotificationMapper' ) + $mapper = $this->getMockBuilder( EchoNotificationMapper::class ) ->disableOriginalConstructor() ->getMock(); $mapper->expects( $this->any() ) @@ -147,7 +147,7 @@ class MWEchoNotifUserTest extends MediaWikiTestCase { } protected function mockEchoNotification() { - $notification = $this->getMockBuilder( 'EchoNotification' ) + $notification = $this->getMockBuilder( EchoNotification::class ) ->disableOriginalConstructor() ->getMock(); $notification->expects( $this->any() ) @@ -158,7 +158,7 @@ class MWEchoNotifUserTest extends MediaWikiTestCase { } protected function mockEchoEvent() { - $event = $this->getMockBuilder( 'EchoEvent' ) + $event = $this->getMockBuilder( EchoEvent::class ) ->disableOriginalConstructor() ->getMock(); $event->expects( $this->any() ) diff --git a/tests/phpunit/UserLocatorTest.php b/tests/phpunit/UserLocatorTest.php index 514c82266..a420d8df9 100644 --- a/tests/phpunit/UserLocatorTest.php +++ b/tests/phpunit/UserLocatorTest.php @@ -21,7 +21,7 @@ class EchoUserLocatorTest extends MediaWikiTestCase { } wfGetDB( DB_MASTER )->insert( 'watchlist', $rows, __METHOD__ ); - $event = $this->getMockBuilder( 'EchoEvent' ) + $event = $this->getMockBuilder( EchoEvent::class ) ->disableOriginalConstructor() ->getMock(); $event->expects( $this->any() ) @@ -264,7 +264,7 @@ class EchoUserLocatorTest extends MediaWikiTestCase { } protected function mockEchoEvent() { - return $this->getMockBuilder( 'EchoEvent' ) + return $this->getMockBuilder( EchoEvent::class ) ->disableOriginalConstructor() ->getMock(); } diff --git a/tests/phpunit/controller/NotificationControllerTest.php b/tests/phpunit/controller/NotificationControllerTest.php index 9e4970245..049024926 100644 --- a/tests/phpunit/controller/NotificationControllerTest.php +++ b/tests/phpunit/controller/NotificationControllerTest.php @@ -54,7 +54,7 @@ class NotificationControllerTest extends MediaWikiTestCase { [ [ 123 ] ], // event user locator config [ - [ 'EchoUserLocator::locateFromEventExtra', [ 'other-user' ] ], + [ [ EchoUserLocator::class, 'locateFromEventExtra' ], [ 'other-user' ] ], ], // additional setup function ( $test, $event ) { @@ -79,7 +79,7 @@ class NotificationControllerTest extends MediaWikiTestCase { ], ] ); - $event = $this->getMockBuilder( 'EchoEvent' ) + $event = $this->getMockBuilder( EchoEvent::class ) ->disableOriginalConstructor() ->getMock(); $event->expects( $this->any() ) @@ -97,7 +97,7 @@ class NotificationControllerTest extends MediaWikiTestCase { public function testEvaluateUserLocatorPassesParameters() { $test = $this; $callback = function ( $event, $firstOption, $secondOption ) use ( $test ) { - $test->assertInstanceOf( 'EchoEvent', $event ); + $test->assertInstanceOf( EchoEvent::class, $event ); $test->assertEquals( 'first', $firstOption ); $test->assertEquals( 'second', $secondOption ); @@ -157,7 +157,7 @@ class NotificationControllerTest extends MediaWikiTestCase { ], ] ); - $event = $this->getMockBuilder( 'EchoEvent' ) + $event = $this->getMockBuilder( EchoEvent::class ) ->disableOriginalConstructor() ->getMock(); $event->expects( $this->any() ) @@ -173,7 +173,7 @@ class NotificationControllerTest extends MediaWikiTestCase { } public function testDoesNotDeliverDisabledEvent() { - $event = $this->getMockBuilder( 'EchoEvent' ) + $event = $this->getMockBuilder( EchoEvent::class ) ->disableOriginalConstructor() ->getMock(); $event->expects( $this->any() ) diff --git a/tests/phpunit/gateway/UserNotificationGatewayTest.php b/tests/phpunit/gateway/UserNotificationGatewayTest.php index 4fd2f00c0..b22721659 100644 --- a/tests/phpunit/gateway/UserNotificationGatewayTest.php +++ b/tests/phpunit/gateway/UserNotificationGatewayTest.php @@ -65,7 +65,7 @@ class EchoUserNotificationGatewayTest extends MediaWikiTestCase { * Mock object of User */ protected function mockUser( $group = 'echo_group' ) { - $user = $this->getMockBuilder( 'User' ) + $user = $this->getMockBuilder( User::class ) ->disableOriginalConstructor() ->getMock(); $user->expects( $this->any() ) @@ -85,7 +85,7 @@ class EchoUserNotificationGatewayTest extends MediaWikiTestCase { * Mock object of MWEchoDbFactory */ protected function mockMWEchoDbFactory( array $dbResult = [] ) { - $dbFactory = $this->getMockBuilder( 'MWEchoDbFactory' ) + $dbFactory = $this->getMockBuilder( MWEchoDbFactory::class ) ->disableOriginalConstructor() ->getMock(); $dbFactory->expects( $this->any() ) @@ -106,7 +106,7 @@ class EchoUserNotificationGatewayTest extends MediaWikiTestCase { 'selectRow' => '', 'selectRowCount' => '', ]; - $db = $this->getMockBuilder( 'DatabaseMysqli' ) + $db = $this->getMockBuilder( DatabaseMysqli::class ) ->disableOriginalConstructor() ->getMock(); $db->expects( $this->any() ) diff --git a/tests/phpunit/maintenance/SupressionMaintenanceTest.php b/tests/phpunit/maintenance/SupressionMaintenanceTest.php index 029be88fa..60c440cf6 100644 --- a/tests/phpunit/maintenance/SupressionMaintenanceTest.php +++ b/tests/phpunit/maintenance/SupressionMaintenanceTest.php @@ -102,7 +102,7 @@ class SuppressionMaintenanceTest extends MediaWikiTestCase { protected static function attachTitleFor( $id, $providedText, $providedNamespace ) { return function ( $test, $gen ) use ( $id, $providedText, $providedNamespace ) { - $title = $test->getMock( 'Title' ); + $title = $test->getMock( Title::class ); $title->expects( $test->any() ) ->method( 'getArticleId' ) ->will( $test->returnValue( $id ) ); diff --git a/tests/phpunit/mapper/AbstractMapperTest.php b/tests/phpunit/mapper/AbstractMapperTest.php index 02194a029..06e6e068d 100644 --- a/tests/phpunit/mapper/AbstractMapperTest.php +++ b/tests/phpunit/mapper/AbstractMapperTest.php @@ -10,7 +10,7 @@ class EchoAbstractMapperTest extends MediaWikiTestCase { $mapper->attachListener( 'testMethod', 'key_a', function () { } ); - $class = new ReflectionClass( 'EchoAbstractMapperStub' ); + $class = new ReflectionClass( EchoAbstractMapperStub::class ); $property = $class->getProperty( 'listeners' ); $property->setAccessible( true ); $listeners = $property->getValue( $mapper ); diff --git a/tests/phpunit/mapper/EventMapperTest.php b/tests/phpunit/mapper/EventMapperTest.php index 330e3628d..2cc8ded0e 100644 --- a/tests/phpunit/mapper/EventMapperTest.php +++ b/tests/phpunit/mapper/EventMapperTest.php @@ -50,7 +50,7 @@ class EchoEventMapperTest extends MediaWikiTestCase { ) ); $res = $eventMapper->fetchById( 1 ); - $this->assertInstanceOf( 'EchoEvent', $res ); + $this->assertInstanceOf( EchoEvent::class, $res ); } /** @@ -72,7 +72,7 @@ class EchoEventMapperTest extends MediaWikiTestCase { * Mock object of EchoEvent */ protected function mockEchoEvent() { - $event = $this->getMockBuilder( 'EchoEvent' ) + $event = $this->getMockBuilder( EchoEvent::class ) ->disableOriginalConstructor() ->getMock(); $event->expects( $this->any() ) @@ -86,7 +86,7 @@ class EchoEventMapperTest extends MediaWikiTestCase { * Mock object of MWEchoDbFactory */ protected function mockMWEchoDbFactory( $dbResult ) { - $dbFactory = $this->getMockBuilder( 'MWEchoDbFactory' ) + $dbFactory = $this->getMockBuilder( MWEchoDbFactory::class ) ->disableOriginalConstructor() ->getMock(); $dbFactory->expects( $this->any() ) @@ -107,7 +107,7 @@ class EchoEventMapperTest extends MediaWikiTestCase { 'select' => '', 'selectRow' => '' ]; - $db = $this->getMockBuilder( 'DatabaseMysqli' ) + $db = $this->getMockBuilder( DatabaseMysqli::class ) ->disableOriginalConstructor() ->getMock(); $db->expects( $this->any() ) diff --git a/tests/phpunit/mapper/NotificationMapperTest.php b/tests/phpunit/mapper/NotificationMapperTest.php index 62359a9cb..e12fae09a 100644 --- a/tests/phpunit/mapper/NotificationMapperTest.php +++ b/tests/phpunit/mapper/NotificationMapperTest.php @@ -45,7 +45,7 @@ class EchoNotificationMapperTest extends MediaWikiTestCase { $this->assertInternalType( 'array', $res ); $this->assertNotEmpty( $res ); foreach ( $res as $row ) { - $this->assertInstanceOf( 'EchoNotification', $row ); + $this->assertInstanceOf( EchoNotification::class, $row ); } } @@ -96,7 +96,7 @@ class EchoNotificationMapperTest extends MediaWikiTestCase { $this->assertInternalType( 'array', $res ); $this->assertNotEmpty( $res ); foreach ( $res as $row ) { - $this->assertInstanceOf( 'EchoNotification', $row ); + $this->assertInstanceOf( EchoNotification::class, $row ); } $notifMapper = new EchoNotificationMapper( $this->mockMWEchoDbFactory( [] ) ); @@ -129,7 +129,7 @@ class EchoNotificationMapperTest extends MediaWikiTestCase { ]; $notifMapper = new EchoNotificationMapper( $this->mockMWEchoDbFactory( [ 'selectRow' => $dbResult ] ) ); $row = $notifMapper->fetchNewestByUserBundleHash( User::newFromId( 1 ), 'testdisplayhash' ); - $this->assertInstanceOf( 'EchoNotification', $row ); + $this->assertInstanceOf( EchoNotification::class, $row ); } public function testFetchByUserOffset() { @@ -157,12 +157,12 @@ class EchoNotificationMapperTest extends MediaWikiTestCase { ]; $notifMapper = new EchoNotificationMapper( $this->mockMWEchoDbFactory( [ 'selectRow' => $dbResult ] ) ); $row = $notifMapper->fetchByUserOffset( User::newFromId( 1 ), 500 ); - $this->assertInstanceOf( 'EchoNotification', $row ); + $this->assertInstanceOf( EchoNotification::class, $row ); } public function testDeleteByUserEventOffset() { $this->setMwGlobals( [ 'wgUpdateRowsPerQuery' => 4 ] ); - $mockDb = $this->getMockBuilder( 'DatabaseMysqli' ) + $mockDb = $this->getMockBuilder( DatabaseMysqli::class ) ->disableOriginalConstructor() ->getMock(); $mockDb->expects( $this->any() ) @@ -197,7 +197,7 @@ class EchoNotificationMapperTest extends MediaWikiTestCase { * Mock object of User */ protected function mockUser() { - $user = $this->getMockBuilder( 'User' ) + $user = $this->getMockBuilder( User::class ) ->disableOriginalConstructor() ->getMock(); $user->expects( $this->any() ) @@ -217,7 +217,7 @@ class EchoNotificationMapperTest extends MediaWikiTestCase { * Mock object of EchoNotification */ protected function mockEchoNotification() { - $event = $this->getMockBuilder( 'EchoNotification' ) + $event = $this->getMockBuilder( EchoNotification::class ) ->disableOriginalConstructor() ->getMock(); $event->expects( $this->any() ) @@ -233,7 +233,7 @@ class EchoNotificationMapperTest extends MediaWikiTestCase { */ protected function mockMWEchoDbFactory( $dbResultOrMockDb ) { $mockDb = is_array( $dbResultOrMockDb ) ? $this->mockDb( $dbResultOrMockDb ) : $dbResultOrMockDb; - $dbFactory = $this->getMockBuilder( 'MWEchoDbFactory' ) + $dbFactory = $this->getMockBuilder( MWEchoDbFactory::class ) ->disableOriginalConstructor() ->getMock(); $dbFactory->expects( $this->any() ) @@ -255,7 +255,7 @@ class EchoNotificationMapperTest extends MediaWikiTestCase { 'delete' => '' ]; - $db = $this->getMockBuilder( 'DatabaseMysqli' ) + $db = $this->getMockBuilder( DatabaseMysqli::class ) ->disableOriginalConstructor() ->getMock(); $db->expects( $this->any() ) diff --git a/tests/phpunit/mapper/TargetPageMapperTest.php b/tests/phpunit/mapper/TargetPageMapperTest.php index a939a1a28..74ce6f950 100644 --- a/tests/phpunit/mapper/TargetPageMapperTest.php +++ b/tests/phpunit/mapper/TargetPageMapperTest.php @@ -53,7 +53,7 @@ class EchoTargetPageMapperTest extends MediaWikiTestCase { * Mock object of MWEchoDbFactory */ protected function mockMWEchoDbFactory( $dbResult ) { - $dbFactory = $this->getMockBuilder( 'MWEchoDbFactory' ) + $dbFactory = $this->getMockBuilder( MWEchoDbFactory::class ) ->disableOriginalConstructor() ->getMock(); $dbFactory->expects( $this->any() ) @@ -74,7 +74,7 @@ class EchoTargetPageMapperTest extends MediaWikiTestCase { 'select' => '', 'delete' => '' ]; - $db = $this->getMockBuilder( 'DatabaseMysqli' ) + $db = $this->getMockBuilder( DatabaseMysqli::class ) ->disableOriginalConstructor() ->getMock(); $db->expects( $this->any() ) diff --git a/tests/phpunit/model/NotificationTest.php b/tests/phpunit/model/NotificationTest.php index 92522303b..9e9948e80 100644 --- a/tests/phpunit/model/NotificationTest.php +++ b/tests/phpunit/model/NotificationTest.php @@ -9,14 +9,14 @@ class EchoNotificationTest extends MediaWikiTestCase { $row = $this->mockNotificationRow() + $this->mockEventRow(); $notif = EchoNotification::newFromRow( (object)$row ); - $this->assertInstanceOf( 'EchoNotification', $notif ); + $this->assertInstanceOf( EchoNotification::class, $notif ); // getReadTimestamp() should return null $this->assertNull( $notif->getReadTimestamp() ); $this->assertEquals( $notif->getTimestamp(), wfTimestamp( TS_MW, $row['notification_timestamp'] ) ); - $this->assertInstanceOf( 'EchoEvent', $notif->getEvent() ); + $this->assertInstanceOf( EchoEvent::class, $notif->getEvent() ); $this->assertNull( $notif->getTargetPages() ); // Provide a read timestamp @@ -33,7 +33,7 @@ class EchoNotificationTest extends MediaWikiTestCase { ] ); $this->assertNotEmpty( $notif->getTargetPages() ); foreach ( $notif->getTargetPages() as $targetPage ) { - $this->assertInstanceOf( 'EchoTargetPage', $targetPage ); + $this->assertInstanceOf( EchoTargetPage::class, $targetPage ); } } diff --git a/tests/phpunit/model/TargetPageTest.php b/tests/phpunit/model/TargetPageTest.php index f925cfebe..bbe5810a9 100644 --- a/tests/phpunit/model/TargetPageTest.php +++ b/tests/phpunit/model/TargetPageTest.php @@ -14,7 +14,7 @@ class EchoTargetPageTest extends MediaWikiTestCase { ); $this->assertInstanceOf( - 'EchoTargetPage', + EchoTargetPage::class, EchoTargetPage::create( $this->mockTitle( 1 ), $this->mockEchoEvent() @@ -28,7 +28,7 @@ class EchoTargetPageTest extends MediaWikiTestCase { 'etp_event' => 3 ]; $obj = EchoTargetPage::newFromRow( $row ); - $this->assertInstanceOf( 'EchoTargetPage', $obj ); + $this->assertInstanceOf( EchoTargetPage::class, $obj ); return $obj; } @@ -62,7 +62,7 @@ class EchoTargetPageTest extends MediaWikiTestCase { * Mock object of Title */ protected function mockTitle( $pageId ) { - $event = $this->getMockBuilder( 'Title' ) + $event = $this->getMockBuilder( Title::class ) ->disableOriginalConstructor() ->getMock(); $event->expects( $this->any() ) @@ -76,7 +76,7 @@ class EchoTargetPageTest extends MediaWikiTestCase { * Mock object of EchoEvent */ protected function mockEchoEvent( $eventId = 1 ) { - $event = $this->getMockBuilder( 'EchoEvent' ) + $event = $this->getMockBuilder( EchoEvent::class ) ->disableOriginalConstructor() ->getMock(); $event->expects( $this->any() )