diff options
Diffstat (limited to 'tests/lib/Notification')
-rw-r--r-- | tests/lib/Notification/ActionTest.php | 14 | ||||
-rw-r--r-- | tests/lib/Notification/ManagerTest.php | 10 | ||||
-rw-r--r-- | tests/lib/Notification/NotificationTest.php | 86 |
3 files changed, 55 insertions, 55 deletions
diff --git a/tests/lib/Notification/ActionTest.php b/tests/lib/Notification/ActionTest.php index 3ae4b1db7e7..241e08048a0 100644 --- a/tests/lib/Notification/ActionTest.php +++ b/tests/lib/Notification/ActionTest.php @@ -20,7 +20,7 @@ class ActionTest extends TestCase { $this->action = new Action(); } - public function dataSetLabel() { + public static function dataSetLabel(): array { return [ ['test1'], [str_repeat('a', 1)], @@ -38,7 +38,7 @@ class ActionTest extends TestCase { $this->assertSame($label, $this->action->getLabel()); } - public function dataSetLabelInvalid() { + public static function dataSetLabelInvalid(): array { return [ [''], [str_repeat('a', 33)], @@ -56,7 +56,7 @@ class ActionTest extends TestCase { $this->action->setLabel($label); } - public function dataSetParsedLabel() { + public static function dataSetParsedLabel(): array { return [ ['test1'], [str_repeat('a', 1)], @@ -74,7 +74,7 @@ class ActionTest extends TestCase { $this->assertSame($label, $this->action->getParsedLabel()); } - public function dataSetParsedLabelInvalid() { + public static function dataSetParsedLabelInvalid(): array { return [ [''], ]; @@ -91,7 +91,7 @@ class ActionTest extends TestCase { $this->action->setParsedLabel($label); } - public function dataSetLink() { + public static function dataSetLink(): array { return [ ['test1', 'GET'], ['test2', 'POST'], @@ -112,7 +112,7 @@ class ActionTest extends TestCase { $this->assertSame($type, $this->action->getRequestType()); } - public function dataSetLinkInvalid() { + public static function dataSetLinkInvalid(): array { return [ // Invalid link ['', 'GET'], @@ -135,7 +135,7 @@ class ActionTest extends TestCase { $this->action->setLink($link, $type); } - public function dataSetPrimary() { + public static function dataSetPrimary(): array { return [ [true], [false], diff --git a/tests/lib/Notification/ManagerTest.php b/tests/lib/Notification/ManagerTest.php index 2a85316d7c4..418d642317e 100644 --- a/tests/lib/Notification/ManagerTest.php +++ b/tests/lib/Notification/ManagerTest.php @@ -153,7 +153,7 @@ class ManagerTest extends TestCase { $this->coordinator, $this->richTextFormatter, ]) - ->setMethods(['getApps']) + ->onlyMethods(['getApps']) ->getMock(); $manager->expects($this->once()) @@ -185,7 +185,7 @@ class ManagerTest extends TestCase { $this->coordinator, $this->richTextFormatter, ]) - ->setMethods(['getApps']) + ->onlyMethods(['getApps']) ->getMock(); $manager->expects($this->never()) @@ -210,7 +210,7 @@ class ManagerTest extends TestCase { $this->coordinator, $this->richTextFormatter, ]) - ->setMethods(['getApps']) + ->onlyMethods(['getApps']) ->getMock(); $manager->expects($this->once()) @@ -236,7 +236,7 @@ class ManagerTest extends TestCase { $this->coordinator, $this->richTextFormatter, ]) - ->setMethods(['getApps']) + ->onlyMethods(['getApps']) ->getMock(); $manager->expects($this->once()) @@ -246,7 +246,7 @@ class ManagerTest extends TestCase { $manager->getCount($notification); } - public function dataIsFairUseOfFreePushService(): array { + public static function dataIsFairUseOfFreePushService(): array { return [ [true, 999, true], [true, 1000, true], diff --git a/tests/lib/Notification/NotificationTest.php b/tests/lib/Notification/NotificationTest.php index 957d74233be..93b1746be3c 100644 --- a/tests/lib/Notification/NotificationTest.php +++ b/tests/lib/Notification/NotificationTest.php @@ -30,7 +30,7 @@ class NotificationTest extends TestCase { $this->notification = new Notification($this->validator, $this->richTextFormatter); } - protected function dataValidString($maxLength) { + protected static function dataValidString($maxLength): array { $dataSets = [ ['test1'], ['1564'], @@ -42,7 +42,7 @@ class NotificationTest extends TestCase { return $dataSets; } - protected function dataInvalidString($maxLength) { + protected static function dataInvalidString($maxLength): array { $dataSets = [ [''] ]; @@ -52,8 +52,8 @@ class NotificationTest extends TestCase { return $dataSets; } - public function dataSetApp() { - return $this->dataValidString(32); + public static function dataSetApp(): array { + return self::dataValidString(32); } /** @@ -66,8 +66,8 @@ class NotificationTest extends TestCase { $this->assertSame($app, $this->notification->getApp()); } - public function dataSetAppInvalid() { - return $this->dataInvalidString(32); + public static function dataSetAppInvalid(): array { + return self::dataInvalidString(32); } /** @@ -82,8 +82,8 @@ class NotificationTest extends TestCase { } - public function dataSetUser() { - return $this->dataValidString(64); + public static function dataSetUser(): array { + return self::dataValidString(64); } /** @@ -96,8 +96,8 @@ class NotificationTest extends TestCase { $this->assertSame($user, $this->notification->getUser()); } - public function dataSetUserInvalid() { - return $this->dataInvalidString(64); + public static function dataSetUserInvalid(): array { + return self::dataInvalidString(64); } /** @@ -111,7 +111,7 @@ class NotificationTest extends TestCase { $this->notification->setUser($user); } - public function dataSetDateTime() { + public static function dataSetDateTime(): array { $past = new \DateTime(); $past->sub(new \DateInterval('P1Y')); $current = new \DateTime(); @@ -135,7 +135,7 @@ class NotificationTest extends TestCase { $this->assertSame($dateTime, $this->notification->getDateTime()); } - public function dataSetDateTimeZero() { + public static function dataSetDateTimeZero(): array { $nineTeenSeventy = new \DateTime(); $nineTeenSeventy->setTimestamp(0); return [ @@ -155,7 +155,7 @@ class NotificationTest extends TestCase { $this->notification->setDateTime($dateTime); } - public function dataSetObject() { + public static function dataSetObject(): array { return [ ['a', '21'], [str_repeat('a', 64), '42'], @@ -175,11 +175,11 @@ class NotificationTest extends TestCase { $this->assertSame($id, $this->notification->getObjectId()); } - public function dataSetObjectTypeInvalid() { - return $this->dataInvalidString(64); + public static function dataSetObjectTypeInvalid(): array { + return self::dataInvalidString(64); } - public function dataSetObjectIdInvalid() { + public static function dataSetObjectIdInvalid(): array { return [ [''], [str_repeat('a', 64 + 1)], @@ -198,7 +198,7 @@ class NotificationTest extends TestCase { $this->notification->setObject('object', $id); } - public function dataSetSubject() { + public static function dataSetSubject(): array { return [ ['a', []], [str_repeat('a', 64), [str_repeat('a', 160)]], @@ -219,8 +219,8 @@ class NotificationTest extends TestCase { $this->assertSame($parameters, $this->notification->getSubjectParameters()); } - public function dataSetSubjectInvalidSubject() { - return $this->dataInvalidString(64); + public static function dataSetSubjectInvalidSubject(): array { + return self::dataInvalidString(64); } /** @@ -234,8 +234,8 @@ class NotificationTest extends TestCase { $this->notification->setSubject($subject, []); } - public function dataSetParsedSubject() { - return $this->dataValidString(false); + public static function dataSetParsedSubject(): array { + return self::dataValidString(false); } /** @@ -248,8 +248,8 @@ class NotificationTest extends TestCase { $this->assertSame($subject, $this->notification->getParsedSubject()); } - public function dataSetParsedSubjectInvalid() { - return $this->dataInvalidString(false); + public static function dataSetParsedSubjectInvalid(): array { + return self::dataInvalidString(false); } /** @@ -263,7 +263,7 @@ class NotificationTest extends TestCase { $this->notification->setParsedSubject($subject); } - public function dataSetMessage() { + public static function dataSetMessage(): array { return [ ['a', []], [str_repeat('a', 64), [str_repeat('a', 160)]], @@ -284,8 +284,8 @@ class NotificationTest extends TestCase { $this->assertSame($parameters, $this->notification->getMessageParameters()); } - public function dataSetMessageInvalidMessage() { - return $this->dataInvalidString(64); + public static function dataSetMessageInvalidMessage(): array { + return self::dataInvalidString(64); } /** @@ -299,8 +299,8 @@ class NotificationTest extends TestCase { $this->notification->setMessage($message, []); } - public function dataSetParsedMessage() { - return $this->dataValidString(false); + public static function dataSetParsedMessage(): array { + return self::dataValidString(false); } /** @@ -313,8 +313,8 @@ class NotificationTest extends TestCase { $this->assertSame($message, $this->notification->getParsedMessage()); } - public function dataSetParsedMessageInvalid() { - return $this->dataInvalidString(false); + public static function dataSetParsedMessageInvalid(): array { + return self::dataInvalidString(false); } /** @@ -328,8 +328,8 @@ class NotificationTest extends TestCase { $this->notification->setParsedMessage($message); } - public function dataSetLink() { - return $this->dataValidString(4000); + public static function dataSetLink(): array { + return self::dataValidString(4000); } /** @@ -342,8 +342,8 @@ class NotificationTest extends TestCase { $this->assertSame($link, $this->notification->getLink()); } - public function dataSetLinkInvalid() { - return $this->dataInvalidString(4000); + public static function dataSetLinkInvalid(): array { + return self::dataInvalidString(4000); } /** @@ -357,8 +357,8 @@ class NotificationTest extends TestCase { $this->notification->setLink($link); } - public function dataSetIcon() { - return $this->dataValidString(4000); + public static function dataSetIcon(): array { + return self::dataValidString(4000); } /** @@ -371,8 +371,8 @@ class NotificationTest extends TestCase { $this->assertSame($icon, $this->notification->getIcon()); } - public function dataSetIconInvalid() { - return $this->dataInvalidString(4000); + public static function dataSetIconInvalid(): array { + return self::dataInvalidString(4000); } /** @@ -508,7 +508,7 @@ class NotificationTest extends TestCase { $this->assertEquals([$action2, $action1, $action1], $this->notification->getParsedActions()); } - public function dataIsValid() { + public static function dataIsValid(): array { return [ [false, '', false], [true, '', false], @@ -527,7 +527,7 @@ class NotificationTest extends TestCase { public function testIsValid($isValidCommon, $subject, $expected): void { /** @var \OCP\Notification\INotification|\PHPUnit\Framework\MockObject\MockObject $notification */ $notification = $this->getMockBuilder(Notification::class) - ->setMethods([ + ->onlyMethods([ 'isValidCommon', 'getSubject', 'getParsedSubject', @@ -560,7 +560,7 @@ class NotificationTest extends TestCase { public function testIsParsedValid($isValidCommon, $subject, $expected): void { /** @var \OCP\Notification\INotification|\PHPUnit\Framework\MockObject\MockObject $notification */ $notification = $this->getMockBuilder(Notification::class) - ->setMethods([ + ->onlyMethods([ 'isValidCommon', 'getParsedSubject', 'getSubject', @@ -583,7 +583,7 @@ class NotificationTest extends TestCase { $this->assertEquals($expected, $notification->isValidParsed()); } - public function dataIsValidCommon() { + public static function dataIsValidCommon(): array { return [ ['', '', 0, '', '', false], ['app', '', 0, '', '', false], @@ -607,7 +607,7 @@ class NotificationTest extends TestCase { public function testIsValidCommon($app, $user, $timestamp, $objectType, $objectId, $expected): void { /** @var \OCP\Notification\INotification|\PHPUnit\Framework\MockObject\MockObject $notification */ $notification = $this->getMockBuilder(Notification::class) - ->setMethods([ + ->onlyMethods([ 'getApp', 'getUser', 'getDateTime', |