summaryrefslogtreecommitdiffstats
path: root/tests/unit/businesslayer/ItemBusinessLayerTest.php
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-26 10:46:32 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-26 11:52:50 +0200
commit5cc47b4f414026ecf16d8c7025571422367f7c58 (patch)
treef555d0769e0a594f3a8f873ff8b455e0bf2a00ee /tests/unit/businesslayer/ItemBusinessLayerTest.php
parent5d41833874a69d2c9322a20ebb7815b6bb1b5adf (diff)
use last_modified column for finding new items (so we also see if they were updated or starred), use offset to paginate rather than item id
Diffstat (limited to 'tests/unit/businesslayer/ItemBusinessLayerTest.php')
-rw-r--r--tests/unit/businesslayer/ItemBusinessLayerTest.php33
1 files changed, 30 insertions, 3 deletions
diff --git a/tests/unit/businesslayer/ItemBusinessLayerTest.php b/tests/unit/businesslayer/ItemBusinessLayerTest.php
index 17c477398..5b5598abd 100644
--- a/tests/unit/businesslayer/ItemBusinessLayerTest.php
+++ b/tests/unit/businesslayer/ItemBusinessLayerTest.php
@@ -27,6 +27,7 @@ namespace OCA\News\BusinessLayer;
require_once(__DIR__ . "/../../classloader.php");
+use \OCA\AppFramework\Db\DoesNotExistException;
use \OCA\News\Db\Item;
use \OCA\News\Db\StatusFlag;
@@ -42,6 +43,7 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
private $response;
private $status;
private $time;
+ private $newestItemId;
protected function setUp(){
@@ -74,6 +76,7 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
$this->showAll = true;
$this->offset = 5;
$this->limit = 20;
+ $this->newestItemId = 4;
}
@@ -134,13 +137,14 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
->with($this->equalTo($this->id),
$this->equalTo($this->limit),
$this->equalTo($this->offset),
+ $this->equalTo($this->newestItemId),
$this->equalTo($this->status),
$this->equalTo($this->user))
->will($this->returnValue($this->response));
$result = $this->itemBusinessLayer->findAll(
$this->id, $type, $this->limit,
- $this->offset, $this->showAll,
+ $this->offset, $this->newestItemId, $this->showAll,
$this->user);
$this->assertEquals($this->response, $result);
}
@@ -153,13 +157,14 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
->with($this->equalTo($this->id),
$this->equalTo($this->limit),
$this->equalTo($this->offset),
+ $this->equalTo($this->newestItemId),
$this->equalTo($this->status),
$this->equalTo($this->user))
->will($this->returnValue($this->response));
$result = $this->itemBusinessLayer->findAll(
$this->id, $type, $this->limit,
- $this->offset, $this->showAll,
+ $this->offset, $this->newestItemId, $this->showAll,
$this->user);
$this->assertEquals($this->response, $result);
}
@@ -171,13 +176,14 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
->method('findAll')
->with( $this->equalTo($this->limit),
$this->equalTo($this->offset),
+ $this->equalTo($this->newestItemId),
$this->equalTo($this->status),
$this->equalTo($this->user))
->will($this->returnValue($this->response));
$result = $this->itemBusinessLayer->findAll(
$this->id, $type, $this->limit,
- $this->offset, $this->showAll,
+ $this->offset, $this->newestItemId, $this->showAll,
$this->user);
$this->assertEquals($this->response, $result);
}
@@ -283,6 +289,27 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
}
+ public function testGetNewestItemId() {
+ $this->mapper->expects($this->once())
+ ->method('getNewestItemId')
+ ->with($this->equalTo($this->user))
+ ->will($this->returnValue(12));
+
+ $result = $this->itemBusinessLayer->getNewestItemId($this->user);
+ $this->assertEquals(12, $result);
+ }
+
+
+ public function testGetNewestItemIdDoesNotExist() {
+ $this->mapper->expects($this->once())
+ ->method('getNewestItemId')
+ ->with($this->equalTo($this->user))
+ ->will($this->throwException(new DoesNotExistException('There are no items')));
+
+ $this->setExpectedException('\OCA\News\BusinessLayer\BusinessLayerException');
+ $this->itemBusinessLayer->getNewestItemId($this->user);
+ }
+
}