diff options
author | Joas Schilling <coding@schilljs.com> | 2020-09-11 17:43:48 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-09-11 17:43:48 +0300 |
commit | 75ea1859172695847b014c92fb95d47b7699b5f9 (patch) | |
tree | c704f6f68a576f2ddaf72d79e5416e6eeed2d67c /tests | |
parent | 92043f5d143114c2de94f355bf0883a331faa23e (diff) |
Fix all warnings
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Activity/SettingTest.php | 14 | ||||
-rw-r--r-- | tests/AppInfo/RoutesTest.php | 4 | ||||
-rw-r--r-- | tests/ManagerTest.php | 23 | ||||
-rw-r--r-- | tests/Notification/NotifierTest.php | 25 | ||||
-rw-r--r-- | tests/phpunit.xml | 1 |
5 files changed, 28 insertions, 39 deletions
diff --git a/tests/Activity/SettingTest.php b/tests/Activity/SettingTest.php index 8477394..e72923b 100644 --- a/tests/Activity/SettingTest.php +++ b/tests/Activity/SettingTest.php @@ -48,7 +48,7 @@ class SettingTest extends TestCase { public function testGetIdentifier($settingClass) { /** @var ISetting $setting */ $setting = \OC::$server->query($settingClass); - $this->assertInternalType('string', $setting->getIdentifier()); + $this->assertIsString($setting->getIdentifier()); } /** @@ -58,7 +58,7 @@ class SettingTest extends TestCase { public function testGetName($settingClass) { /** @var ISetting $setting */ $setting = \OC::$server->query($settingClass); - $this->assertInternalType('string', $setting->getName()); + $this->assertIsString($setting->getName()); } /** @@ -69,7 +69,7 @@ class SettingTest extends TestCase { /** @var ISetting $setting */ $setting = \OC::$server->query($settingClass); $priority = $setting->getPriority(); - $this->assertInternalType('int', $setting->getPriority()); + $this->assertIsInt( $setting->getPriority()); $this->assertGreaterThanOrEqual(0, $priority); $this->assertLessThanOrEqual(100, $priority); } @@ -81,7 +81,7 @@ class SettingTest extends TestCase { public function testCanChangeStream($settingClass) { /** @var ISetting $setting */ $setting = \OC::$server->query($settingClass); - $this->assertInternalType('bool', $setting->canChangeStream()); + $this->assertIsBool($setting->canChangeStream()); } /** @@ -91,7 +91,7 @@ class SettingTest extends TestCase { public function testIsDefaultEnabledStream($settingClass) { /** @var ISetting $setting */ $setting = \OC::$server->query($settingClass); - $this->assertInternalType('bool', $setting->isDefaultEnabledStream()); + $this->assertIsBool($setting->isDefaultEnabledStream()); } /** @@ -101,7 +101,7 @@ class SettingTest extends TestCase { public function testCanChangeMail($settingClass) { /** @var ISetting $setting */ $setting = \OC::$server->query($settingClass); - $this->assertInternalType('bool', $setting->canChangeMail()); + $this->assertIsBool($setting->canChangeMail()); } /** @@ -111,6 +111,6 @@ class SettingTest extends TestCase { public function testIsDefaultEnabledMail($settingClass) { /** @var ISetting $setting */ $setting = \OC::$server->query($settingClass); - $this->assertInternalType('bool', $setting->isDefaultEnabledMail()); + $this->assertIsBool($setting->isDefaultEnabledMail()); } } diff --git a/tests/AppInfo/RoutesTest.php b/tests/AppInfo/RoutesTest.php index 5bf7936..e62be89 100644 --- a/tests/AppInfo/RoutesTest.php +++ b/tests/AppInfo/RoutesTest.php @@ -26,10 +26,10 @@ namespace OCA\AnnouncementCenter\Tests; class RoutesTest extends TestCase { public function testRoutes() { $routes = include __DIR__ . '/../../appinfo/routes.php'; - $this->assertInternalType('array', $routes); + $this->assertIsArray($routes); $this->assertCount(1, $routes); $this->assertArrayHasKey('routes', $routes); - $this->assertInternalType('array', $routes['routes']); + $this->assertIsArray($routes['routes']); $this->assertGreaterThanOrEqual(1, \count($routes['routes'])); } } diff --git a/tests/ManagerTest.php b/tests/ManagerTest.php index 6eff0f2..1ea4285 100644 --- a/tests/ManagerTest.php +++ b/tests/ManagerTest.php @@ -26,6 +26,7 @@ namespace OCA\AnnouncementCenter\Tests; use OCA\AnnouncementCenter\BackgroundJob; use OCA\AnnouncementCenter\Manager; use OCA\AnnouncementCenter\Model\Announcement; +use OCA\AnnouncementCenter\Model\AnnouncementDoesNotExistException; use OCA\AnnouncementCenter\Model\AnnouncementMapper; use OCA\AnnouncementCenter\Model\GroupMapper; use OCP\AppFramework\Db\DoesNotExistException; @@ -102,33 +103,27 @@ class ManagerTest extends TestCase { $query->delete('announcements_groups')->execute(); } - /** - * @expectedException \OCA\AnnouncementCenter\Model\AnnouncementDoesNotExistException - * @expectedMessage Invalid ID - */ public function testGetAnnouncementNotExist(): void { $this->announcementMapper->expects($this->once()) ->method('getById') ->with(42) ->willThrowException(new DoesNotExistException('Entity does not exist')); + $this->expectException(AnnouncementDoesNotExistException::class); + $this->expectExceptionMessage('Announcement does not exist'); $this->manager->getAnnouncement(42); } - /** - * @expectedException \InvalidArgumentException - * @expectedMessage Invalid subject - * @expectedCode 2 - */ public function testAnnounceNoSubject(): void { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid subject'); + $this->expectExceptionCode(2); $this->manager->announce('', '', '', 0, [], false); } - /** - * @expectedException \InvalidArgumentException - * @expectedMessage Invalid subject - * @expectedCode 1 - */ public function testAnnounceSubjectTooLong(): void { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid subject'); + $this->expectExceptionCode(1); $this->manager->announce(str_repeat('a', 513), '', '', 0, [], false); } diff --git a/tests/Notification/NotifierTest.php b/tests/Notification/NotifierTest.php index ddf5c5b..2701bce 100644 --- a/tests/Notification/NotifierTest.php +++ b/tests/Notification/NotifierTest.php @@ -32,6 +32,7 @@ use OCP\IL10N; use OCP\IURLGenerator; use OCP\IUserManager; use OCP\L10N\IFactory; +use OCP\Notification\AlreadyProcessedException; use OCP\Notification\IManager; use OCP\Notification\INotification; use OCP\IUser; @@ -81,10 +82,6 @@ class NotifierTest extends TestCase { ); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Unknown app - */ public function testPrepareWrongApp(): void { /** @var \OCP\Notification\INotification|MockObject $notification */ $notification = $this->createMock(INotification::class); @@ -95,13 +92,11 @@ class NotifierTest extends TestCase { $notification->expects($this->never()) ->method('getSubject'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Unknown app'); $this->notifier->prepare($notification, 'en'); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Unknown subject - */ public function testPrepareWrongSubject(): void { /** @var \OCP\Notification\INotification|MockObject $notification */ $notification = $this->createMock(INotification::class); @@ -113,12 +108,11 @@ class NotifierTest extends TestCase { ->method('getSubject') ->willReturn('wrong subject'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Unknown subject'); $this->notifier->prepare($notification, 'en'); } - /** - * @expectedException \OCP\Notification\AlreadyProcessedException - */ public function testPrepareDoesNotExist(): void { /** @var INotification|MockObject $notification */ $notification = $this->createMock(INotification::class); @@ -131,13 +125,14 @@ class NotifierTest extends TestCase { ->willReturn('announced'); $notification->expects($this->once()) ->method('getObjectId') - ->willReturn(42); + ->willReturn('42'); $this->manager->expects($this->once()) ->method('getAnnouncement') ->with(42, false) ->willThrowException(new AnnouncementDoesNotExistException()); + $this->expectException(AlreadyProcessedException::class); $this->notifier->prepare($notification, 'en'); } @@ -155,9 +150,9 @@ class NotifierTest extends TestCase { public function dataPrepare(): array { $message = "message\nmessage message message message message message message message message message message messagemessagemessagemessagemessagemessagemessage"; return [ - ['author', 'subject', 'message', 42, null, 'author announced “subject”', 'message'], - ['author1', 'subject', 'message', 42, $this->getUserMock(), 'Author announced “subject”', 'message'], - ['author2', "subject\nsubject", $message, 21, null, 'author2 announced “subject subject”', $message], + ['author', 'subject', 'message', '42', null, 'author announced “subject”', 'message'], + ['author1', 'subject', 'message', '42', $this->getUserMock(), 'Author announced “subject”', 'message'], + ['author2', "subject\nsubject", $message, '21', null, 'author2 announced “subject subject”', $message], ]; } diff --git a/tests/phpunit.xml b/tests/phpunit.xml index 02b97f5..8ca38d1 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8" ?> <phpunit bootstrap="bootstrap.php" - strict="true" verbose="true" timeoutForSmallTests="900" timeoutForMediumTests="900" |