diff options
author | Joas Schilling <coding@schilljs.com> | 2019-07-16 13:32:44 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-07-16 13:32:44 +0200 |
commit | 565838da9c279fe071a9cdfbfd9cf574893a61f5 (patch) | |
tree | edca999a6b0a1a6ce373850cd57b8b0a2759d61f /apps | |
parent | c3ef1cd90d215f36edf7236456578a233bc5f3bd (diff) | |
download | nextcloud-server-565838da9c279fe071a9cdfbfd9cf574893a61f5.tar.gz nextcloud-server-565838da9c279fe071a9cdfbfd9cf574893a61f5.zip |
Update unit tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps')
4 files changed, 18 insertions, 11 deletions
diff --git a/apps/comments/tests/Unit/Controller/NotificationsTest.php b/apps/comments/tests/Unit/Controller/NotificationsTest.php index c5209b9f9d5..9df81f01b02 100644 --- a/apps/comments/tests/Unit/Controller/NotificationsTest.php +++ b/apps/comments/tests/Unit/Controller/NotificationsTest.php @@ -117,6 +117,9 @@ class NotificationsTest extends TestCase { $comment->expects($this->any()) ->method('getObjectType') ->willReturn('files'); + $comment->expects($this->any()) + ->method('getId') + ->willReturn('1234'); $this->commentsManager->expects($this->any()) ->method('get') @@ -192,6 +195,9 @@ class NotificationsTest extends TestCase { $comment->expects($this->any()) ->method('getObjectType') ->willReturn('files'); + $comment->expects($this->any()) + ->method('getId') + ->willReturn('1234'); $this->commentsManager->expects($this->any()) ->method('get') diff --git a/apps/comments/tests/Unit/Notification/ListenerTest.php b/apps/comments/tests/Unit/Notification/ListenerTest.php index d6f83262f30..e31b227bce8 100644 --- a/apps/comments/tests/Unit/Notification/ListenerTest.php +++ b/apps/comments/tests/Unit/Notification/ListenerTest.php @@ -91,6 +91,9 @@ class ListenerTest extends TestCase { [ 'type' => 'user', 'id' => '23452-4333-54353-2342'], [ 'type' => 'user', 'id' => 'yolo'], ]); + $comment->expects($this->atLeastOnce()) + ->method('getId') + ->willReturn('1234'); /** @var CommentsEvent|\PHPUnit_Framework_MockObject_MockObject $event */ $event = $this->getMockBuilder(CommentsEvent::class) @@ -186,6 +189,9 @@ class ListenerTest extends TestCase { $comment->expects($this->once()) ->method('getMentions') ->willReturn([[ 'type' => 'user', 'id' => 'foobar']]); + $comment->expects($this->atLeastOnce()) + ->method('getId') + ->willReturn('1234'); /** @var CommentsEvent|\PHPUnit_Framework_MockObject_MockObject $event */ $event = $this->getMockBuilder(CommentsEvent::class) diff --git a/apps/comments/tests/Unit/Notification/NotifierTest.php b/apps/comments/tests/Unit/Notification/NotifierTest.php index 6eceed44919..d008c4c3121 100644 --- a/apps/comments/tests/Unit/Notification/NotifierTest.php +++ b/apps/comments/tests/Unit/Notification/NotifierTest.php @@ -195,6 +195,9 @@ class NotifierTest extends TestCase { ->expects($this->any()) ->method('getMentions') ->willReturn([['type' => 'user', 'id' => 'you']]); + $this->comment->expects($this->atLeastOnce()) + ->method('getId') + ->willReturn('1234'); $this->commentsManager ->expects($this->once()) @@ -539,7 +542,7 @@ class NotifierTest extends TestCase { } /** - * @expectedException \InvalidArgumentException + * @expectedException \OCP\Notification\AlreadyProcessedException */ public function testPrepareUnresolvableFileID() { $displayName = 'Huraga'; diff --git a/apps/updatenotification/tests/Notification/NotifierTest.php b/apps/updatenotification/tests/Notification/NotifierTest.php index b1ddf7b478d..f97ff776c93 100644 --- a/apps/updatenotification/tests/Notification/NotifierTest.php +++ b/apps/updatenotification/tests/Notification/NotifierTest.php @@ -30,6 +30,7 @@ use OCP\IGroupManager; use OCP\IURLGenerator; use OCP\IUserSession; use OCP\L10N\IFactory; +use OCP\Notification\AlreadyProcessedException; use OCP\Notification\IManager; use OCP\Notification\INotification; use Test\TestCase; @@ -112,21 +113,12 @@ class NotifierTest extends TestCase { ->method('getObjectId') ->willReturn($versionNotification); - if ($exception) { - $this->notificationManager->expects($this->once()) - ->method('markProcessed') - ->with($notification); - } else { - $this->notificationManager->expects($this->never()) - ->method('markProcessed'); - } - try { self::invokePrivate($notifier, 'updateAlreadyInstalledCheck', [$notification, $versionInstalled]); $this->assertFalse($exception); } catch (\Exception $e) { $this->assertTrue($exception); - $this->assertInstanceOf('InvalidArgumentException', $e); + $this->assertInstanceOf(AlreadyProcessedException::class, $e); } } } |