summaryrefslogtreecommitdiffstats
path: root/tests/bl
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-03-21 20:38:09 +0100
committerBernhard Posselt <nukeawhale@gmail.com>2013-03-21 20:38:20 +0100
commitc8bdd9c3fb0ab872b868c151f052748235601653 (patch)
treeaf4ffc33ad013f817af14aed25e54606429ad612 /tests/bl
parentd692600a31bf4aa9be8b71d8fcb16e90e9393aea (diff)
finished feedcontroller
Diffstat (limited to 'tests/bl')
-rw-r--r--tests/bl/FeedBlTest.php53
-rw-r--r--tests/bl/ItemBlTest.php140
2 files changed, 193 insertions, 0 deletions
diff --git a/tests/bl/FeedBlTest.php b/tests/bl/FeedBlTest.php
index 08f98beab..444018349 100644
--- a/tests/bl/FeedBlTest.php
+++ b/tests/bl/FeedBlTest.php
@@ -36,6 +36,8 @@ class FeedBlTest extends \OCA\AppFramework\Utility\TestUtility {
protected $api;
protected $feedMapper;
protected $feedBl;
+ protected $user;
+ protected $response;
protected function setUp(){
$this->api = $this->getAPIMock();
@@ -43,11 +45,62 @@ class FeedBlTest extends \OCA\AppFramework\Utility\TestUtility {
->disableOriginalConstructor()
->getMock();
$this->feedBl = new FeedBl($this->feedMapper);
+ $this->user = 'jack';
+ $response = 'hi';
}
public function testFindAll(){
+ $this->feedMapper->expects($this->once())
+ ->method('findAll')
+ ->will($this->returnValue($this->response));
+ $result = $this->feedBl->findAll();
+ $this->assertEquals($this->response, $result);
}
+
+ public function testFindAllFromUser(){
+ $this->feedMapper->expects($this->once())
+ ->method('findAllFromUser')
+ ->with($this->equalTo($this->user))
+ ->will($this->returnValue($this->response));
+
+ $result = $this->feedBl->findAllFromUser($this->user);
+ $this->assertEquals($this->response, $result);
+ }
+
+
+ public function testCreate(){
+ // TODO
+ }
+
+
+ public function testUpdate(){
+ // TODO
+ }
+
+
+ public function testMove(){
+ $feedId = 3;
+ $folderId = 4;
+ $feed = new Feed();
+ $feed->setFolderId(16);
+ $feed->setId($feedId);
+
+ $this->feedMapper->expects($this->once())
+ ->method('find')
+ ->with($this->equalTo($feedId), $this->equalTo($this->user))
+ ->will($this->returnValue($feed));
+
+ $this->feedMapper->expects($this->once())
+ ->method('update')
+ ->with($this->equalTo($feed));
+
+ $this->feedBl->move($feedId, $folderId, $this->user);
+
+ $this->assertEquals($folderId, $feed->getFolderId());
+ }
+
+
} \ No newline at end of file
diff --git a/tests/bl/ItemBlTest.php b/tests/bl/ItemBlTest.php
new file mode 100644
index 000000000..5a4070e06
--- /dev/null
+++ b/tests/bl/ItemBlTest.php
@@ -0,0 +1,140 @@
+<?php
+
+/**
+* ownCloud - News
+*
+* @author Alessandro Cosentino
+* @author Bernhard Posselt
+* @copyright 2012 Alessandro Cosentino cosenal@gmail.com
+* @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+namespace OCA\News\Bl;
+
+require_once(__DIR__ . "/../classloader.php");
+
+
+use \OCA\News\Db\Item;
+
+
+class ItemBlTest extends \OCA\AppFramework\Utility\TestUtility {
+
+ protected $api;
+ protected $mapper;
+ protected $bl;
+ protected $user;
+ protected $response;
+
+ protected function setUp(){
+ $this->api = $this->getAPIMock();
+ $this->mapper = $this->getMockBuilder('\OCA\News\Db\ItemMapper')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->bl = new ItemBl($this->mapper);
+ $this->user = 'jack';
+ $response = 'hi';
+ }
+
+
+
+
+ /*
+ public function testFindAll(){
+ $this->mapper->expects($this->once())
+ ->method('findAll')
+ ->with($this->equalTo($this->user))
+ ->will($this->returnValue($this->response));
+
+ $result = $this->bl->findAllFromUser($this->user);
+ $this->assertEquals($this->response, $result);
+ }
+
+ */
+
+ public function testStarredCount(){
+ $star = 18;
+
+ $this->mapper->expects($this->once())
+ ->method('starredCount')
+ ->with($this->equalTo($this->user))
+ ->will($this->returnValue($star));
+
+ $result = $this->bl->starredCount($this->user);
+
+ $this->assertEquals($star, $result);
+ }
+
+
+ public function testStar(){
+ $itemId = 3;
+ $item = new Item();
+ $item->setStatus(128);
+ $item->setId($itemId);
+
+ $this->mapper->expects($this->once())
+ ->method('find')
+ ->with($this->equalTo($itemId), $this->equalTo($this->user))
+ ->will($this->returnValue($item));
+
+ $this->mapper->expects($this->once())
+ ->method('update')
+ ->with($this->equalTo($item));
+
+ $this->bl->star($itemId, false, $this->user);
+
+ $this->assertTrue($item->isUnstarred());
+ }
+
+
+ public function testRead(){
+ $itemId = 3;
+ $item = new Item();
+ $item->setStatus(128);
+ $item->setId($itemId);
+
+ $this->mapper->expects($this->once())
+ ->method('find')
+ ->with($this->equalTo($itemId), $this->equalTo($this->user))
+ ->will($this->returnValue($item));
+
+ $this->mapper->expects($this->once())
+ ->method('update')
+ ->with($this->equalTo($item));
+
+ $this->bl->read($itemId, false, $this->user);
+
+ $this->assertTrue($item->isUnread());
+ }
+
+
+ public function testReadFeed(){
+ $feedId = 3;
+
+ $this->mapper->expects($this->once())
+ ->method('readFeed')
+ ->with($this->equalTo($feedId), $this->equalTo($this->user));
+
+ $this->bl->readFeed($feedId, $this->user);
+ }
+
+}
+
+
+
+
+
+