diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-09-16 15:04:05 +0300 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-09-16 15:04:05 +0300 |
commit | a1304fbb9c18acac82d051d225894394297f2062 (patch) | |
tree | f106a1ae009cca9c297081ec43a46643fe864c75 /tests | |
parent | 9050235be73499f9d9ab889e1c018f3b27c642af (diff) |
Correctly deal with notifications of disabled apps
Diffstat (limited to 'tests')
-rw-r--r-- | tests/controller/EndpointControllerTest.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/controller/EndpointControllerTest.php b/tests/controller/EndpointControllerTest.php index 422cd0d..4511ebc 100644 --- a/tests/controller/EndpointControllerTest.php +++ b/tests/controller/EndpointControllerTest.php @@ -159,6 +159,66 @@ class EndpointControllerTest extends TestCase { $this->assertSame($expectedData, $response->getData()); } + public function dataGetThrows() { + return [ + [ + [ + 1 => $this->getMockBuilder('OC\Notification\INotification') + ->disableOriginalConstructor() + ->getMock(), + 3 => $this->getMockBuilder('OC\Notification\INotification') + ->disableOriginalConstructor() + ->getMock(), + ], + md5(json_encode([3])), + ['$notification'], + ], + ]; + } + + /** + * @dataProvider dataGetThrows + * @param array $notifications + * @param string $expectedETag + * @param array $expectedData + */ + public function testGetThrows(array $notifications, $expectedETag, array $expectedData) { + $controller = $this->getController([ + 'notificationToArray', + ]); + $controller->expects($this->exactly(1)) + ->method('notificationToArray') + ->willReturn('$notification'); + + $filter = $this->getMockBuilder('OC\Notification\INotification') + ->disableOriginalConstructor() + ->getMock(); + $filter->expects($this->once()) + ->method('setUser') + ->willReturn('username'); + + $this->manager->expects($this->once()) + ->method('createNotification') + ->willReturn($filter); + $this->manager->expects($this->at(1)) + ->method('prepare') + ->willThrowException(new \InvalidArgumentException()); + $this->manager->expects($this->at(2)) + ->method('prepare') + ->willReturnArgument(0); + + $this->handler->expects($this->once()) + ->method('get') + ->with($filter) + ->willReturn($notifications); + + $response = $controller->get(); + $this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $response); + + $this->assertSame($expectedETag, $response->getETag()); + $this->assertSame($expectedData, $response->getData()); + } + public function dataDelete() { return [ [42, 'username1'], |