summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2015-01-23 14:32:53 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2015-01-23 14:32:53 +0100
commitdf509a4b856472fa22fd6d43a212c9d21bd5b40f (patch)
treebe8be7824bd4ba3ee687c6e57d1383929360e505 /tests
parent5adeba1a560985173974c9ac98c624093055d669 (diff)
fix #711
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/controller/FeedControllerTest.php27
-rw-r--r--tests/unit/db/FeedTest.php4
-rw-r--r--tests/unit/service/FeedServiceTest.php31
3 files changed, 61 insertions, 1 deletions
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);
+ }
+
+
+
}