From de2121d066e85aad0c67c498bcf2fd242824f83b Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 9 Oct 2014 10:02:44 +0200 Subject: More coverage --- tests/unit/controller/FeedApiControllerTest.php | 21 +++++++++++++++++++++ tests/unit/controller/ItemControllerTest.php | 16 ++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/tests/unit/controller/FeedApiControllerTest.php b/tests/unit/controller/FeedApiControllerTest.php index c614dac82..8dff56f2e 100644 --- a/tests/unit/controller/FeedApiControllerTest.php +++ b/tests/unit/controller/FeedApiControllerTest.php @@ -278,6 +278,27 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { } + public function testRenameError() { + $feedId = 3; + $feedTitle = 'test'; + + $this->feedService->expects($this->once()) + ->method('rename') + ->with( + $this->equalTo($feedId), + $this->equalTo($feedTitle), + $this->equalTo($this->user)) + ->will($this->throwException(new ServiceNotFoundException('hi'))); + + $result = $this->feedAPI->rename($feedId, $feedTitle); + $data = $result->getData(); + $code = $result->getStatus(); + + $this->assertSame(Http::STATUS_NOT_FOUND, $code); + $this->assertSame('hi', $data['message']); + } + + public function testfromAllUsers(){ $feed = new Feed(); $feed->setUrl(3); diff --git a/tests/unit/controller/ItemControllerTest.php b/tests/unit/controller/ItemControllerTest.php index b5a579783..b366fdfa0 100644 --- a/tests/unit/controller/ItemControllerTest.php +++ b/tests/unit/controller/ItemControllerTest.php @@ -100,6 +100,22 @@ class ItemControllerTest extends \PHPUnit_Framework_TestCase { } + public function testReadMultipleDontStopOnException() { + $this->itemService->expects($this->at(0)) + ->method('read') + ->with($this->equalTo(2), + $this->equalTo(true), + $this->equalTo($this->user)) + ->will($this->throwException(new ServiceNotFoundException('yo'))); + $this->itemService->expects($this->at(1)) + ->method('read') + ->with($this->equalTo(4), + $this->equalTo(true), + $this->equalTo($this->user)); + $this->controller->readMultiple([2, 4]); + } + + public function testStar(){ $this->itemService->expects($this->once()) ->method('star') -- cgit v1.2.3