From df509a4b856472fa22fd6d43a212c9d21bd5b40f Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Fri, 23 Jan 2015 14:32:53 +0100 Subject: fix #711 --- tests/unit/controller/FeedControllerTest.php | 27 ++++++++++++++++++++++++ tests/unit/db/FeedTest.php | 4 +++- tests/unit/service/FeedServiceTest.php | 31 ++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/unit/controller/FeedControllerTest.php b/tests/unit/controller/FeedControllerTest.php index e7f19a2b8..813508cef 100644 --- a/tests/unit/controller/FeedControllerTest.php +++ b/tests/unit/controller/FeedControllerTest.php @@ -507,4 +507,31 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($response->getStatus(), Http::STATUS_NOT_FOUND); } + + public function testOrdering() { + $this->feedService->expects($this->once()) + ->method('setOrdering') + ->with($this->equalTo(4), + $this->equalTo(2), + $this->equalTo($this->user)); + + $this->controller->ordering(4, 2); + } + + + public function testOrderingDoesNotExist(){ + $msg = 'hehe'; + + $this->feedService->expects($this->once()) + ->method('setOrdering') + ->will($this->throwException(new ServiceNotFoundException($msg))); + + $response = $this->controller->ordering(4, 2); + $params = json_decode($response->render(), true); + + $this->assertEquals($msg, $params['message']); + $this->assertEquals($response->getStatus(), Http::STATUS_NOT_FOUND); + } + + } diff --git a/tests/unit/db/FeedTest.php b/tests/unit/db/FeedTest.php index f8461a239..fd90f2925 100644 --- a/tests/unit/db/FeedTest.php +++ b/tests/unit/db/FeedTest.php @@ -30,6 +30,7 @@ class FeedTest extends \PHPUnit_Framework_TestCase { $feed->setUnreadCount(321); $feed->setLink('https://www.google.com/some/weird/path'); $feed->setLocation('http://google.at'); + $feed->setOrdering(2); return $feed; } @@ -67,7 +68,8 @@ class FeedTest extends \PHPUnit_Framework_TestCase { 'deletedAt' => null, 'articlesPerUpdate' => null, 'cssClass' => 'custom-google-com', - 'location' => 'http://google.at' + 'location' => 'http://google.at', + 'ordering' => 2 ], $feed->jsonSerialize()); } diff --git a/tests/unit/service/FeedServiceTest.php b/tests/unit/service/FeedServiceTest.php index 2ab135d2b..8b0d78c52 100644 --- a/tests/unit/service/FeedServiceTest.php +++ b/tests/unit/service/FeedServiceTest.php @@ -777,5 +777,36 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase { } + public function testOrdering () { + $feed = Feed::fromRow(['id' => 3]); + $this->feedMapper->expects($this->once()) + ->method('find') + ->with($this->equalTo($feed->getId()), + $this->equalTo($this->user)) + ->will($this->returnValue($feed)); + + $feed->setOrdering(2); + $this->feedMapper->expects($this->once()) + ->method('update') + ->with($this->equalTo($feed)); + + $this->feedService->setOrdering(3, 2, $this->user); + } + + + /** + * @expectedException OCA\News\Service\ServiceNotFoundException + */ + public function testOrderingDoesNotExist () { + $feed = Feed::fromRow(['id' => 3]); + $this->feedMapper->expects($this->once()) + ->method('find') + ->will($this->throwException(new DoesNotExistException(''))); + + $this->feedService->setOrdering(3, 2, $this->user); + } + + + } -- cgit v1.2.3