summaryrefslogtreecommitdiffstats
path: root/tests/unit/controller/ItemControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/controller/ItemControllerTest.php')
-rw-r--r--tests/unit/controller/ItemControllerTest.php102
1 files changed, 100 insertions, 2 deletions
diff --git a/tests/unit/controller/ItemControllerTest.php b/tests/unit/controller/ItemControllerTest.php
index b0d2a52bc..16df210e0 100644
--- a/tests/unit/controller/ItemControllerTest.php
+++ b/tests/unit/controller/ItemControllerTest.php
@@ -128,7 +128,32 @@ class ItemControllerTest extends ControllerTestUtility {
->with($url['itemId'], true, $this->user);
- $this->controller->read();
+ $result = $this->controller->read();
+ $this->assertTrue($result instanceof JSONResponse);
+ }
+
+
+ public function testReadDoesNotExist(){
+ $url = array(
+ 'itemId' => 4
+ );
+ $msg = 'hi';
+ $this->controller = $this->getPostController(array(), $url);
+
+ $this->api->expects($this->once())
+ ->method('getUserId')
+ ->will($this->returnValue($this->user));
+ $this->itemBusinessLayer->expects($this->once())
+ ->method('read')
+ ->will($this->throwException(new BusinessLayerException($msg)));
+
+
+ $response = $this->controller->read();
+ $params = json_decode($response->render(), true);
+
+ $this->assertEquals('error', $params['status']);
+ $this->assertEquals($msg, $params['msg']);
+ $this->assertTrue($response instanceof JSONResponse);
}
@@ -149,7 +174,32 @@ class ItemControllerTest extends ControllerTestUtility {
}
- public function testStar(){
+
+ public function testUnreadDoesNotExist(){
+ $url = array(
+ 'itemId' => 4
+ );
+ $msg = 'hi';
+ $this->controller = $this->getPostController(array(), $url);
+
+ $this->api->expects($this->once())
+ ->method('getUserId')
+ ->will($this->returnValue($this->user));
+ $this->itemBusinessLayer->expects($this->once())
+ ->method('read')
+ ->will($this->throwException(new BusinessLayerException($msg)));
+
+
+ $response = $this->controller->unread();
+ $params = json_decode($response->render(), true);
+
+ $this->assertEquals('error', $params['status']);
+ $this->assertEquals($msg, $params['msg']);
+ $this->assertTrue($response instanceof JSONResponse);
+ }
+
+
+ public function testStar(){
$url = array(
'feedId' => 4,
'guidHash' => md5('test')
@@ -172,6 +222,30 @@ class ItemControllerTest extends ControllerTestUtility {
}
+ public function testStarDoesNotExist(){
+ $url = array(
+ 'feedId' => 4,
+ 'guidHash' => md5('test')
+ );
+ $msg = 'ho';
+ $this->controller = $this->getPostController(array(), $url);
+
+ $this->api->expects($this->once())
+ ->method('getUserId')
+ ->will($this->returnValue($this->user));
+ $this->itemBusinessLayer->expects($this->once())
+ ->method('star')
+ ->will($this->throwException(new BusinessLayerException($msg)));;
+
+ $response = $this->controller->star();
+ $params = json_decode($response->render(), true);
+
+ $this->assertEquals('error', $params['status']);
+ $this->assertEquals($msg, $params['msg']);
+ $this->assertTrue($response instanceof JSONResponse);
+ }
+
+
public function testUnstar(){
$url = array(
'feedId' => 4,
@@ -195,6 +269,30 @@ class ItemControllerTest extends ControllerTestUtility {
}
+ public function testUnstarDoesNotExist(){
+ $url = array(
+ 'feedId' => 4,
+ 'guidHash' => md5('test')
+ );
+ $msg = 'ho';
+ $this->controller = $this->getPostController(array(), $url);
+
+ $this->api->expects($this->once())
+ ->method('getUserId')
+ ->will($this->returnValue($this->user));
+ $this->itemBusinessLayer->expects($this->once())
+ ->method('star')
+ ->will($this->throwException(new BusinessLayerException($msg)));;
+
+ $response = $this->controller->unstar();
+ $params = json_decode($response->render(), true);
+
+ $this->assertEquals('error', $params['status']);
+ $this->assertEquals($msg, $params['msg']);
+ $this->assertTrue($response instanceof JSONResponse);
+ }
+
+
public function testReadFeed(){
$url = array(
'feedId' => 4