diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-22 13:47:45 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-22 13:47:45 +0100 |
commit | 585667bdf4a06a7bcde1b7d2b9b42059135343dc (patch) | |
tree | f7b9b053e70a088280c83073d2fe72c9387bcefc /tests/bl/FeedBlTest.php | |
parent | 196177a0ca3fc0103d359eec44f46173be685413 (diff) |
dont add feed twice
Diffstat (limited to 'tests/bl/FeedBlTest.php')
-rw-r--r-- | tests/bl/FeedBlTest.php | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/bl/FeedBlTest.php b/tests/bl/FeedBlTest.php index bef45bd2e..3cf528722 100644 --- a/tests/bl/FeedBlTest.php +++ b/tests/bl/FeedBlTest.php @@ -27,6 +27,7 @@ namespace OCA\News\Bl; require_once(__DIR__ . "/../classloader.php"); +use \OCA\AppFramework\Db\DoesNotExistException; use \OCA\News\Db\Feed; use \OCA\News\Db\Item; @@ -84,23 +85,33 @@ class FeedBlTest extends \OCA\AppFramework\Utility\TestUtility { public function testCreateDoesNotFindFeed(){ $ex = new FetcherException('hi'); $url = 'test'; + $this->mapper->expects($this->once()) + ->method('findByUrlHash') + ->with($this->equalTo(md5($url)), $this->equalTo($this->user)) + ->will($this->throwException(new DoesNotExistException('yo'))); $this->fetcher->expects($this->once()) ->method('fetch') ->with($this->equalTo($url)) ->will($this->throwException($ex)); $this->setExpectedException('\OCA\News\Bl\BLException'); - $this->bl->create($url, 1, 2); + $this->bl->create($url, 1, $this->user); } public function testCreate(){ $url = 'test'; $folderId = 10; $createdFeed = new Feed(); + $ex = new DoesNotExistException('yo'); $createdFeed->setUrl($url); $return = array( $createdFeed, array(new Item(), new Item()) ); + + $this->mapper->expects($this->once()) + ->method('findByUrlHash') + ->with($this->equalTo(md5($url)), $this->equalTo($this->user)) + ->will($this->throwException($ex)); $this->fetcher->expects($this->once()) ->method('fetch') ->with($this->equalTo($url)) @@ -122,6 +133,16 @@ class FeedBlTest extends \OCA\AppFramework\Utility\TestUtility { $this->assertEquals($feed->getUrl(), $url); } + public function testCreateFeedExistsAlready(){ + $url = 'test'; + $this->mapper->expects($this->once()) + ->method('findByUrlHash') + ->with($this->equalTo(md5($url)), $this->equalTo($this->user)); + $this->setExpectedException('\OCA\News\Bl\BLException'); + $this->bl->create($url, 1, $this->user); + + } + public function testUpdate(){ // TODO |