summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-02 12:04:45 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-02 12:04:45 +0200
commitc795c0aa10f7d404a96ac893d3ba2972724d8511 (patch)
tree56b8a9bc27379ac0fb28d21abd831acf8eaef13f /tests
parentbd7d13ce963f286459684934257a6a1e61d7bfc7 (diff)
fix #11 by not relying on db exceptions anymore since there is no fking proper exception handling in the owncloud db code and stuff will break. instead update when item has been found and if not insert
Diffstat (limited to 'tests')
-rw-r--r--tests/bl/FeedBlTest.php27
-rw-r--r--tests/utility/FetcherTest.php1
2 files changed, 17 insertions, 11 deletions
diff --git a/tests/bl/FeedBlTest.php b/tests/bl/FeedBlTest.php
index 9a9bd2002..818562fb9 100644
--- a/tests/bl/FeedBlTest.php
+++ b/tests/bl/FeedBlTest.php
@@ -146,10 +146,13 @@ class FeedBlTest extends \OCA\AppFramework\Utility\TestUtility {
$item = new Item();
$item->setGuidHash(md5('hi'));
+ $item->setFeedId(3);
$items = array(
$item
);
+ $ex = new DoesNotExistException('hi');
+
$fetchReturn = array($feed, $items);
$this->mapper->expects($this->once())
@@ -161,9 +164,15 @@ class FeedBlTest extends \OCA\AppFramework\Utility\TestUtility {
->method('fetch')
->will($this->returnValue($fetchReturn));
$this->itemMapper->expects($this->once())
+ ->method('findByGuidHash')
+ ->with($this->equalTo($items[0]->getGuidHash()),
+ $this->equalTo($items[0]->getFeedId()),
+ $this->equalTo($this->user))
+ ->will($this->throwException($ex));
+ $this->itemMapper->expects($this->once())
->method('insert')
->with($this->equalTo($items[0]));
-
+
$this->bl->update($feed->getId(), $this->user);
}
@@ -192,15 +201,15 @@ class FeedBlTest extends \OCA\AppFramework\Utility\TestUtility {
->method('fetch')
->will($this->returnValue($fetchReturn));
$this->itemMapper->expects($this->once())
- ->method('insert')
- ->with($this->equalTo($items[0]))
- ->will($this->throwException($ex));
- $this->itemMapper->expects($this->once())
->method('findByGuidHash')
->with($this->equalTo($item->getGuidHash()),
$this->equalTo($feed->getId()),
$this->equalTo($this->user))
->will($this->returnValue($item));
+ $this->itemMapper->expects($this->never())
+ ->method('insert');
+ $this->itemMapper->expects($this->never())
+ ->method('delete');
$this->bl->update($feed->getId(), $this->user);
}
@@ -233,20 +242,16 @@ class FeedBlTest extends \OCA\AppFramework\Utility\TestUtility {
$this->fetcher->expects($this->once())
->method('fetch')
->will($this->returnValue($fetchReturn));
- $this->itemMapper->expects($this->at(0))
- ->method('insert')
- ->with($this->equalTo($items[0]))
- ->will($this->throwException($ex));
$this->itemMapper->expects($this->once())
->method('findByGuidHash')
->with($this->equalTo($item->getGuidHash()),
$this->equalTo($feed->getId()),
$this->equalTo($this->user))
->will($this->returnValue($item2));
- $this->itemMapper->expects($this->at(2))
+ $this->itemMapper->expects($this->at(1))
->method('delete')
->with($this->equalTo($item2));
- $this->itemMapper->expects($this->at(3))
+ $this->itemMapper->expects($this->at(2))
->method('insert')
->with($this->equalTo($item));
diff --git a/tests/utility/FetcherTest.php b/tests/utility/FetcherTest.php
index 0da3b9265..bbf2622e8 100644
--- a/tests/utility/FetcherTest.php
+++ b/tests/utility/FetcherTest.php
@@ -75,6 +75,7 @@ class FetcherTest extends \OCA\AppFramework\Utility\TestUtility {
$this->fetcher->fetch($url);
}
+
public function testMultipleFetchersOnlyOneShouldHandle(){
$url = 'hi';
$return = 'zeas';