diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-07-17 20:22:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-17 20:22:03 +0200 |
commit | 5b604eaeaba7d5ee5dd12a92f37c9e8e7519c9c2 (patch) | |
tree | a507ff70a162b7c779a62faa1f341ec025539b9f /tests | |
parent | 782554d2acdfd48b322753500906e8b291035250 (diff) | |
parent | 594efca1e3b936d0d86f2d80ebf366980a425713 (diff) | |
download | nextcloud-server-5b604eaeaba7d5ee5dd12a92f37c9e8e7519c9c2.tar.gz nextcloud-server-5b604eaeaba7d5ee5dd12a92f37c9e8e7519c9c2.zip |
Merge pull request #15040 from nextcloud/feature/13980/push-for-deleted-notifications
Notifications overhaul
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Notification/ActionTest.php | 45 | ||||
-rw-r--r-- | tests/lib/Notification/DummyApp.php | 56 | ||||
-rw-r--r-- | tests/lib/Notification/DummyNotifier.php | 63 | ||||
-rw-r--r-- | tests/lib/Notification/ManagerTest.php | 378 | ||||
-rw-r--r-- | tests/lib/Notification/NotificationTest.php | 77 |
6 files changed, 198 insertions, 425 deletions
diff --git a/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php b/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php index 27d386ca5b3..e3e526e401b 100644 --- a/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php +++ b/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php @@ -92,7 +92,7 @@ class RemoteWipeNotificationListenerTests extends TestCase { $token->method('getId')->willReturn(123); $notification->expects($this->once()) ->method('setObject') - ->with('token', 123) + ->with('token', '123') ->willReturnSelf(); $token->method('getName')->willReturn('Token 1'); $notification->expects($this->once()) @@ -132,7 +132,7 @@ class RemoteWipeNotificationListenerTests extends TestCase { $token->method('getId')->willReturn(123); $notification->expects($this->once()) ->method('setObject') - ->with('token', 123) + ->with('token', '123') ->willReturnSelf(); $token->method('getName')->willReturn('Token 1'); $notification->expects($this->once()) diff --git a/tests/lib/Notification/ActionTest.php b/tests/lib/Notification/ActionTest.php index 74c995280c9..9160ea7a7c3 100644 --- a/tests/lib/Notification/ActionTest.php +++ b/tests/lib/Notification/ActionTest.php @@ -55,14 +55,8 @@ class ActionTest extends TestCase { public function dataSetLabelInvalid() { return [ - [true], - [false], - [0], - [1], [''], [str_repeat('a', 33)], - [[]], - [[str_repeat('a', 33)]], ]; } @@ -96,13 +90,7 @@ class ActionTest extends TestCase { public function dataSetParsedLabelInvalid() { return [ - [true], - [false], - [0], - [1], [''], - [[]], - [[str_repeat('a', 33)]], ]; } @@ -140,23 +128,11 @@ class ActionTest extends TestCase { public function dataSetLinkInvalid() { return [ // Invalid link - [true, 'GET'], - [false, 'GET'], - [0, 'GET'], - [1, 'GET'], ['', 'GET'], [str_repeat('a', 257), 'GET'], - [[], 'GET'], - [[str_repeat('a', 257)], 'GET'], // Invalid type ['url', 'notGET'], - ['url', true], - ['url', false], - ['url', 0], - ['url', 1], - ['url', []], - ['url', ['GET']], ]; } @@ -188,27 +164,6 @@ class ActionTest extends TestCase { $this->assertSame($primary, $this->action->isPrimary()); } - public function dataSetPrimaryInvalid() { - return [ - [0], - [1], - [''], - [str_repeat('a', 257)], - [[]], - [[str_repeat('a', 257)]], - ]; - } - - /** - * @dataProvider dataSetPrimaryInvalid - * @param mixed $primary - * - * @expectedException \InvalidArgumentException - */ - public function testSetPrimaryInvalid($primary) { - $this->action->setPrimary($primary); - } - public function testIsValid() { $this->assertFalse($this->action->isValid()); $this->assertFalse($this->action->isValidParsed()); diff --git a/tests/lib/Notification/DummyApp.php b/tests/lib/Notification/DummyApp.php new file mode 100644 index 00000000000..680fb44d009 --- /dev/null +++ b/tests/lib/Notification/DummyApp.php @@ -0,0 +1,56 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace Test\Notification; + + +use OCP\Notification\IApp; +use OCP\Notification\INotification; + +class DummyApp implements IApp { + + /** + * @param INotification $notification + * @throws \InvalidArgumentException When the notification is not valid + * @since 9.0.0 + */ + public function notify(INotification $notification): void { + // TODO: Implement notify() method. + } + + /** + * @param INotification $notification + * @since 9.0.0 + */ + public function markProcessed(INotification $notification): void { + // TODO: Implement markProcessed() method. + } + + /** + * @param INotification $notification + * @return int + * @since 9.0.0 + */ + public function getCount(INotification $notification): int { + // TODO: Implement getCount() method. + } +} diff --git a/tests/lib/Notification/DummyNotifier.php b/tests/lib/Notification/DummyNotifier.php new file mode 100644 index 00000000000..849fb3c275f --- /dev/null +++ b/tests/lib/Notification/DummyNotifier.php @@ -0,0 +1,63 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace Test\Notification; + + +use OCP\Notification\AlreadyProcessedException; +use OCP\Notification\INotification; +use OCP\Notification\INotifier; + +class DummyNotifier implements INotifier { + + /** + * Identifier of the notifier, only use [a-z0-9_] + * + * @return string + * @since 17.0.0 + */ + public function getID(): string { + // TODO: Implement getID() method. + } + + /** + * Human readable name describing the notifier + * + * @return string + * @since 17.0.0 + */ + public function getName(): string { + // TODO: Implement getName() method. + } + + /** + * @param INotification $notification + * @param string $languageCode The code of the language that should be used to prepare the notification + * @return INotification + * @throws \InvalidArgumentException When the notification was not prepared by a notifier + * @throws AlreadyProcessedException When the notification is not needed anymore and should be deleted + * @since 9.0.0 + */ + public function prepare(INotification $notification, string $languageCode): INotification { + // TODO: Implement prepare() method. + } +} diff --git a/tests/lib/Notification/ManagerTest.php b/tests/lib/Notification/ManagerTest.php index cb6504b67e7..259ac0beefe 100644 --- a/tests/lib/Notification/ManagerTest.php +++ b/tests/lib/Notification/ManagerTest.php @@ -22,162 +22,72 @@ namespace Test\Notification; use OC\Notification\Manager; +use OCP\ILogger; use OCP\Notification\IApp; use OCP\Notification\IManager; use OCP\Notification\INotification; use OCP\Notification\INotifier; use OCP\RichObjectStrings\IValidator; +use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class ManagerTest extends TestCase { /** @var IManager */ protected $manager; + /** @var IValidator|MockObject */ + protected $validator; + /** @var ILogger|MockObject */ + protected $logger; + public function setUp() { parent::setUp(); - $validator = $this->createMock(IValidator::class); - $this->manager = new Manager($validator); + $this->validator = $this->createMock(IValidator::class); + $this->logger = $this->createMock(ILogger::class); + $this->manager = new Manager($this->validator, $this->logger); } public function testRegisterApp() { - $app = $this->getMockBuilder(IApp::class) - ->disableOriginalConstructor() - ->getMock(); - - $closure = function() use ($app) { - return $app; - }; - $this->assertEquals([], $this->invokePrivate($this->manager, 'getApps')); + $this->assertEquals([], self::invokePrivate($this->manager, 'getApps')); - $this->manager->registerApp($closure); + $this->manager->registerApp(DummyApp::class); - $this->assertEquals([$app], $this->invokePrivate($this->manager, 'getApps')); - $this->assertEquals([$app], $this->invokePrivate($this->manager, 'getApps')); + $this->assertCount(1, self::invokePrivate($this->manager, 'getApps')); + $this->assertCount(1, self::invokePrivate($this->manager, 'getApps')); - $this->manager->registerApp($closure); + $this->manager->registerApp(DummyApp::class); - $this->assertEquals([$app, $app], $this->invokePrivate($this->manager, 'getApps')); + $this->assertCount(2, self::invokePrivate($this->manager, 'getApps')); } - /** - * @expectedException \InvalidArgumentException - */ public function testRegisterAppInvalid() { - $notifier = $this->getMockBuilder(INotifier::class) - ->disableOriginalConstructor() - ->getMock(); - - $closure = function() use ($notifier) { - return $notifier; - }; - - $this->manager->registerApp($closure); + $this->manager->registerApp(DummyNotifier::class); - $this->invokePrivate($this->manager, 'getApps'); + $this->logger->expects($this->once()) + ->method('error'); + self::invokePrivate($this->manager, 'getApps'); } public function testRegisterNotifier() { - $notifier = $this->getMockBuilder(INotifier::class) - ->disableOriginalConstructor() - ->getMock(); - - $closure = function() use ($notifier) { - return $notifier; - }; + $this->assertEquals([], self::invokePrivate($this->manager, 'getNotifiers')); - $this->assertEquals([], $this->invokePrivate($this->manager, 'getNotifiers')); - $this->assertEquals([], $this->invokePrivate($this->manager, 'listNotifiers')); + $this->manager->registerNotifierService(DummyNotifier::class); - $this->manager->registerNotifier($closure, function() { - return ['id' => 'test1', 'name' => 'Test One']; - }); + $this->assertCount(1, self::invokePrivate($this->manager, 'getNotifiers')); + $this->assertCount(1, self::invokePrivate($this->manager, 'getNotifiers')); - $this->assertEquals([$notifier], $this->invokePrivate($this->manager, 'getNotifiers')); - $this->assertEquals(['test1' => 'Test One'], $this->invokePrivate($this->manager, 'listNotifiers')); - $this->assertEquals([$notifier], $this->invokePrivate($this->manager, 'getNotifiers')); - $this->assertEquals(['test1' => 'Test One'], $this->invokePrivate($this->manager, 'listNotifiers')); + $this->manager->registerNotifierService(DummyNotifier::class); - $this->manager->registerNotifier($closure, function() { - return ['id' => 'test2', 'name' => 'Test Two']; - }); - - $this->assertEquals([$notifier, $notifier], $this->invokePrivate($this->manager, 'getNotifiers')); - $this->assertEquals(['test1' => 'Test One', 'test2' => 'Test Two'], $this->invokePrivate($this->manager, 'listNotifiers')); + $this->assertCount(2, self::invokePrivate($this->manager, 'getNotifiers')); } - /** - * @expectedException \InvalidArgumentException - */ public function testRegisterNotifierInvalid() { - $app = $this->getMockBuilder(IApp::class) - ->disableOriginalConstructor() - ->getMock(); - - $closure = function() use ($app) { - return $app; - }; - - $this->manager->registerNotifier($closure, function() { - return ['id' => 'test1', 'name' => 'Test One']; - }); - - $this->invokePrivate($this->manager, 'getNotifiers'); - } - - public function dataRegisterNotifierInfoInvalid() { - return [ - [null], - ['No array'], - [['id' => 'test1', 'name' => 'Test One', 'size' => 'Invalid']], - [['no-id' => 'test1', 'name' => 'Test One']], - [['id' => 'test1', 'no-name' => 'Test One']], - ]; - } - - /** - * @dataProvider dataRegisterNotifierInfoInvalid - * @expectedException \InvalidArgumentException - * @param mixed $data - */ - public function testRegisterNotifierInfoInvalid($data) { - $app = $this->getMockBuilder(IApp::class) - ->disableOriginalConstructor() - ->getMock(); - - $closure = function() use ($app) { - return $app; - }; - - $this->manager->registerNotifier($closure, function() use ($data) { - return $data; - }); + $this->manager->registerNotifierService(DummyApp::class); - $this->manager->listNotifiers(); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The given notifier ID test1 is already in use - */ - public function testRegisterNotifierInfoDuplicate() { - $app = $this->getMockBuilder(IApp::class) - ->disableOriginalConstructor() - ->getMock(); - - $closure = function() use ($app) { - return $app; - }; - - $this->manager->registerNotifier($closure, function() { - return ['id' => 'test1', 'name' => 'Test One']; - }); - - $this->manager->registerNotifier($closure, function() { - return ['id' => 'test1', 'name' => 'Test One']; - }); - - $this->manager->listNotifiers(); + $this->logger->expects($this->once()) + ->method('error'); + self::invokePrivate($this->manager, 'getNotifiers'); } public function testCreateNotification() { @@ -194,30 +104,19 @@ class ManagerTest extends TestCase { ->method('isValid') ->willReturn(true); - /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app */ - $app = $this->getMockBuilder(IApp::class) - ->disableOriginalConstructor() + $manager = $this->getMockBuilder(Manager::class) + ->setConstructorArgs([ + $this->validator, + $this->logger, + ]) + ->setMethods(['getApps']) ->getMock(); - $app->expects($this->once()) - ->method('notify') - ->with($notification); - /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app2 */ - $app2 = $this->getMockBuilder(IApp::class) - ->disableOriginalConstructor() - ->getMock(); - $app2->expects($this->once()) - ->method('notify') - ->with($notification); - - $this->manager->registerApp(function() use ($app) { - return $app; - }); - $this->manager->registerApp(function() use ($app2) { - return $app2; - }); - - $this->manager->notify($notification); + $manager->expects($this->once()) + ->method('getApps') + ->willReturn([]); + + $manager->notify($notification); } /** @@ -232,127 +131,18 @@ class ManagerTest extends TestCase { ->method('isValid') ->willReturn(false); - $this->manager->notify($notification); - } - - public function testPrepare() { - /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ - $notification = $this->getMockBuilder(INotification::class) - ->disableOriginalConstructor() - ->getMock(); - $notification->expects($this->once()) - ->method('isValidParsed') - ->willReturn(true); - /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification2 */ - $notification2 = $this->getMockBuilder(INotification::class) - ->disableOriginalConstructor() - ->getMock(); - $notification2->expects($this->exactly(2)) - ->method('isValidParsed') - ->willReturn(true); - - /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $notifier */ - $notifier = $this->getMockBuilder(INotifier::class) - ->disableOriginalConstructor() - ->getMock(); - $notifier->expects($this->once()) - ->method('prepare') - ->with($notification, 'en') - ->willReturnArgument(0); - - /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $notifier2 */ - $notifier2 = $this->getMockBuilder(INotifier::class) - ->disableOriginalConstructor() - ->getMock(); - $notifier2->expects($this->once()) - ->method('prepare') - ->with($notification, 'en') - ->willReturn($notification2); - - $this->manager->registerNotifier(function() use ($notifier) { - return $notifier; - }, function() { - return ['id' => 'test1', 'name' => 'Test One']; - }); - $this->manager->registerNotifier(function() use ($notifier2) { - return $notifier2; - }, function() { - return ['id' => 'test2', 'name' => 'Test Two']; - }); - - $this->assertEquals($notification2, $this->manager->prepare($notification, 'en')); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testPrepareInvalid() { - /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ - $notification = $this->getMockBuilder(INotification::class) - ->disableOriginalConstructor() - ->getMock(); - $notification->expects($this->once()) - ->method('isValidParsed') - ->willReturn(false); - - /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $notifier */ - $notifier = $this->getMockBuilder(INotifier::class) - ->disableOriginalConstructor() - ->getMock(); - $notifier->expects($this->once()) - ->method('prepare') - ->with($notification, 'de') - ->willReturnArgument(0); - - $this->manager->registerNotifier(function() use ($notifier) { - return $notifier; - }, function() { - return ['id' => 'test1', 'name' => 'Test One']; - }); - - $this->manager->prepare($notification, 'de'); - } - - public function testPrepareNotifierThrows() { - /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ - $notification = $this->getMockBuilder(INotification::class) - ->disableOriginalConstructor() + $manager = $this->getMockBuilder(Manager::class) + ->setConstructorArgs([ + $this->validator, + $this->logger, + ]) + ->setMethods(['getApps']) ->getMock(); - $notification->expects($this->once()) - ->method('isValidParsed') - ->willReturn(true); - /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $notifier */ - $notifier = $this->getMockBuilder(INotifier::class) - ->disableOriginalConstructor() - ->getMock(); - $notifier->expects($this->once()) - ->method('prepare') - ->with($notification, 'de') - ->willThrowException(new \InvalidArgumentException); - - $this->manager->registerNotifier(function() use ($notifier) { - return $notifier; - }, function() { - return ['id' => 'test1', 'name' => 'Test One']; - }); - - $this->assertEquals($notification, $this->manager->prepare($notification, 'de')); - } + $manager->expects($this->never()) + ->method('getApps'); - /** - * @expectedException \InvalidArgumentException - */ - public function testPrepareNoNotifier() { - /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ - $notification = $this->getMockBuilder(INotification::class) - ->disableOriginalConstructor() - ->getMock(); - $notification->expects($this->once()) - ->method('isValidParsed') - ->willReturn(false); - - $this->manager->prepare($notification, 'en'); + $manager->notify($notification); } public function testMarkProcessed() { @@ -361,30 +151,19 @@ class ManagerTest extends TestCase { ->disableOriginalConstructor() ->getMock(); - /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app */ - $app = $this->getMockBuilder(IApp::class) - ->disableOriginalConstructor() + $manager = $this->getMockBuilder(Manager::class) + ->setConstructorArgs([ + $this->validator, + $this->logger, + ]) + ->setMethods(['getApps']) ->getMock(); - $app->expects($this->once()) - ->method('markProcessed') - ->with($notification); - /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app2 */ - $app2 = $this->getMockBuilder(IApp::class) - ->disableOriginalConstructor() - ->getMock(); - $app2->expects($this->once()) - ->method('markProcessed') - ->with($notification); - - $this->manager->registerApp(function() use ($app) { - return $app; - }); - $this->manager->registerApp(function() use ($app2) { - return $app2; - }); - - $this->manager->markProcessed($notification); + $manager->expects($this->once()) + ->method('getApps') + ->willReturn([]); + + $manager->markProcessed($notification); } public function testGetCount() { @@ -393,31 +172,18 @@ class ManagerTest extends TestCase { ->disableOriginalConstructor() ->getMock(); - /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app */ - $app = $this->getMockBuilder(IApp::class) - ->disableOriginalConstructor() + $manager = $this->getMockBuilder(Manager::class) + ->setConstructorArgs([ + $this->validator, + $this->logger, + ]) + ->setMethods(['getApps']) ->getMock(); - $app->expects($this->once()) - ->method('getCount') - ->with($notification) - ->willReturn(21); - /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app2 */ - $app2 = $this->getMockBuilder(IApp::class) - ->disableOriginalConstructor() - ->getMock(); - $app2->expects($this->once()) - ->method('getCount') - ->with($notification) - ->willReturn(42); - - $this->manager->registerApp(function() use ($app) { - return $app; - }); - $this->manager->registerApp(function() use ($app2) { - return $app2; - }); - - $this->assertSame(63, $this->manager->getCount($notification)); + $manager->expects($this->once()) + ->method('getApps') + ->willReturn([]); + + $manager->getCount($notification); } } diff --git a/tests/lib/Notification/NotificationTest.php b/tests/lib/Notification/NotificationTest.php index 7517be715ee..d72c9f62ae0 100644 --- a/tests/lib/Notification/NotificationTest.php +++ b/tests/lib/Notification/NotificationTest.php @@ -63,29 +63,6 @@ class NotificationTest extends TestCase { return $dataSets; } - protected function dataInvalidStringType() { - return [ - [true], - [false], - [16412], - [[]], - [null], - ]; - } - - protected function dataInvalidInt() { - return [ - [true], - [false], - [''], - ['a'], - [str_repeat('a', 256)], - [[]], - [['a']], - [[str_repeat('a', 256)]], - ]; - } - public function dataSetApp() { return $this->dataValidString(32); } @@ -104,10 +81,6 @@ class NotificationTest extends TestCase { return $this->dataInvalidString(32); } - public function dataSetAppInvalidType() { - return $this->dataInvalidStringType(); - } - /** * @dataProvider dataSetAppInvalid * @param mixed $app @@ -118,16 +91,6 @@ class NotificationTest extends TestCase { $this->notification->setApp($app); } - /** - * @dataProvider dataSetAppInvalidType - * @param mixed $app - * - * @expectedException \TypeError - */ - public function testSetAppInvalidType($app) { - $this->notification->setApp($app); - } - public function dataSetUser() { return $this->dataValidString(64); @@ -147,10 +110,6 @@ class NotificationTest extends TestCase { return $this->dataInvalidString(64); } - public function dataSetUserInvalidType() { - return $this->dataInvalidStringType(); - } - /** * @dataProvider dataSetUserInvalid * @param mixed $user @@ -161,16 +120,6 @@ class NotificationTest extends TestCase { $this->notification->setUser($user); } - /** - * @dataProvider dataSetUserInvalidType - * @param mixed $user - * - * @expectedException \TypeError - */ - public function testSetUserInvalidType($user) { - $this->notification->setUser($user); - } - public function dataSetDateTime() { $past = new \DateTime(); $past->sub(new \DateInterval('P1Y')); @@ -216,48 +165,32 @@ class NotificationTest extends TestCase { public function dataSetObject() { return [ - ['a', '21', '21'], - [str_repeat('a', 64), 42, '42'], + ['a', '21'], + [str_repeat('a', 64), '42'], ]; } /** * @dataProvider dataSetObject * @param string $type - * @param int|string $id - * @param string $exptectedId + * @param string $id */ - public function testSetObject($type, $id, $exptectedId) { + public function testSetObject($type, $id) { $this->assertSame('', $this->notification->getObjectType()); $this->assertSame('', $this->notification->getObjectId()); $this->assertSame($this->notification, $this->notification->setObject($type, $id)); $this->assertSame($type, $this->notification->getObjectType()); - $this->assertSame($exptectedId, $this->notification->getObjectId()); + $this->assertSame($id, $this->notification->getObjectId()); } public function dataSetObjectTypeInvalid() { return $this->dataInvalidString(64); } - /** - * @dataProvider dataSetObjectTypeInvalid - * @param mixed $type - * - * @expectedException \InvalidArgumentException - * @expectedMessage 'The given object type is invalid' - */ - public function testSetObjectTypeInvalid($type) { - $this->notification->setObject($type, 1337); - } - public function dataSetObjectIdInvalid() { return [ - [true], - [false], [''], [str_repeat('a', 64 + 1)], - [[]], - [[str_repeat('a', 64 + 1)]], ]; } |