diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-06-12 20:17:46 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-06-12 20:32:49 +0200 |
commit | 836c65b6fa7e9a90f9baf421713641dfcb7a90aa (patch) | |
tree | 7b2607449517e22a88ef4003790f4b05270b6444 /tests | |
parent | a5fea1be13b5915e60e10bccfd39e60110a56bca (diff) |
move to new restful api
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/controller/FeedControllerTest.php | 2 | ||||
-rw-r--r-- | tests/unit/external/FeedAPITest.php | 46 | ||||
-rw-r--r-- | tests/unit/external/FolderAPITest.php | 37 | ||||
-rw-r--r-- | tests/unit/external/ItemAPITest.php | 58 |
4 files changed, 67 insertions, 76 deletions
diff --git a/tests/unit/controller/FeedControllerTest.php b/tests/unit/controller/FeedControllerTest.php index 064fdeeb4..f7d0dc3f7 100644 --- a/tests/unit/controller/FeedControllerTest.php +++ b/tests/unit/controller/FeedControllerTest.php @@ -488,7 +488,7 @@ class FeedControllerTest extends ControllerTestUtility { $response = $this->controller->update(); $render = $response->render(); - $this->assertEquals('{"status":"error","data":[],"msg":"NO!"}', $render); + $this->assertEquals('{"data":[],"status":"error","msg":"NO!"}', $render); $this->assertTrue($response instanceof JSONResponse); } diff --git a/tests/unit/external/FeedAPITest.php b/tests/unit/external/FeedAPITest.php index fd65d742c..b4ab8bfe6 100644 --- a/tests/unit/external/FeedAPITest.php +++ b/tests/unit/external/FeedAPITest.php @@ -27,6 +27,7 @@ namespace OCA\News\External; use \OCA\AppFramework\Http\Request; use \OCA\AppFramework\Http\JSONResponse; +use \OCA\AppFramework\Http\Http; use \OCA\AppFramework\Utility\ControllerTestUtility; use \OCA\News\BusinessLayer\BusinessLayerException; @@ -200,9 +201,8 @@ class FeedAPITest extends ControllerTestUtility { $response = $this->feedAPI->delete(); - $this->assertNull($response->getData()); - $this->assertNull($response->getMessage()); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $this->assertEmpty($response->getData()); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } @@ -227,9 +227,9 @@ class FeedAPITest extends ControllerTestUtility { $response = $this->feedAPI->delete(); - $this->assertNull($response->getData()); - $this->assertEquals($this->msg, $response->getMessage()); - $this->assertEquals(NewsAPIResult::NOT_FOUND_ERROR, $response->getStatusCode()); + $data = $response->getData(); + $this->assertEquals($this->msg, $data['message']); + $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); } @@ -273,8 +273,7 @@ class FeedAPITest extends ControllerTestUtility { 'newestItemId' => 3 ), $response->getData()); - $this->assertNull($response->getMessage()); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } @@ -317,8 +316,7 @@ class FeedAPITest extends ControllerTestUtility { 'feeds' => array($feeds[0]->toAPI()) ), $response->getData()); - $this->assertNull($response->getMessage()); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } @@ -336,9 +334,9 @@ class FeedAPITest extends ControllerTestUtility { $response = $this->feedAPI->create(); - $this->assertNull($response->getData()); - $this->assertEquals($this->msg, $response->getMessage()); - $this->assertEquals(NewsAPIResult::EXISTS_ERROR, $response->getStatusCode()); + $data = $response->getData(); + $this->assertEquals($this->msg, $data['message']); + $this->assertEquals(NewsAPIResult::EXISTS_ERROR, $response->getStatus()); } @@ -352,9 +350,9 @@ class FeedAPITest extends ControllerTestUtility { $response = $this->feedAPI->create(); - $this->assertNull($response->getData()); - $this->assertEquals($this->msg, $response->getMessage()); - $this->assertEquals(NewsAPIResult::NOT_FOUND_ERROR, $response->getStatusCode()); + $data = $response->getData(); + $this->assertEquals($this->msg, $data['message']); + $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); } @@ -387,9 +385,8 @@ class FeedAPITest extends ControllerTestUtility { $response = $this->feedAPI->read(); - $this->assertNull($response->getData()); - $this->assertNull($response->getMessage()); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $this->assertEmpty($response->getData()); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } @@ -422,9 +419,8 @@ class FeedAPITest extends ControllerTestUtility { $response = $this->feedAPI->move(); - $this->assertNull($response->getData()); - $this->assertNull($response->getMessage()); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $this->assertEmpty($response->getData()); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } @@ -438,8 +434,8 @@ class FeedAPITest extends ControllerTestUtility { $response = $this->feedAPI->move(); - $this->assertNull($response->getData()); - $this->assertEquals($this->msg, $response->getMessage()); - $this->assertEquals(NewsAPIResult::NOT_FOUND_ERROR, $response->getStatusCode()); + $data = $response->getData(); + $this->assertEquals($this->msg, $data['message']); + $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); } } diff --git a/tests/unit/external/FolderAPITest.php b/tests/unit/external/FolderAPITest.php index f9e5490a3..f20cf0ccf 100644 --- a/tests/unit/external/FolderAPITest.php +++ b/tests/unit/external/FolderAPITest.php @@ -28,6 +28,7 @@ namespace OCA\News\External; use \OCA\AppFramework\Http\Request; use \OCA\AppFramework\Http\JSONResponse; use \OCA\AppFramework\Utility\ControllerTestUtility; +use \OCA\AppFramework\Http\Http; use \OCA\News\BusinessLayer\BusinessLayerException; use \OCA\News\BusinessLayer\BusinessLayerExistsException; @@ -179,9 +180,9 @@ class FolderAPITest extends ControllerTestUtility { $response = $this->folderAPI->create(); - $this->assertNull($response->getData()); - $this->assertEquals(NewsAPIResult::EXISTS_ERROR, $response->getStatusCode()); - $this->assertEquals($msg, $response->getMessage()); + $data = $response->getData(); + $this->assertEquals($msg, $data['message']); + $this->assertEquals(Http::STATUS_CONFLICT, $response->getStatus()); } @@ -206,7 +207,7 @@ class FolderAPITest extends ControllerTestUtility { $response = $this->folderAPI->delete(); - $this->assertNull($response->getData()); + $this->assertEmpty($response->getData()); } @@ -231,9 +232,9 @@ class FolderAPITest extends ControllerTestUtility { $response = $this->folderAPI->delete(); - $this->assertNull($response->getData()); - $this->assertEquals($this->msg, $response->getMessage()); - $this->assertEquals(NewsAPIResult::NOT_FOUND_ERROR, $response->getStatusCode()); + $data = $response->getData(); + $this->assertEquals($this->msg, $data['message']); + $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); } @@ -269,9 +270,8 @@ class FolderAPITest extends ControllerTestUtility { $response = $this->folderAPI->update(); - $this->assertNull($response->getData()); - $this->assertNull($response->getMessage()); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $this->assertEmpty($response->getData()); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } public function testUpdateDoesNotExist() { @@ -304,9 +304,9 @@ class FolderAPITest extends ControllerTestUtility { $response = $this->folderAPI->update(); - $this->assertNull($response->getData()); - $this->assertEquals($this->msg, $response->getMessage()); - $this->assertEquals(NewsAPIResult::NOT_FOUND_ERROR, $response->getStatusCode()); + $data = $response->getData(); + $this->assertEquals($this->msg, $data['message']); + $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); } @@ -340,9 +340,9 @@ class FolderAPITest extends ControllerTestUtility { $response = $this->folderAPI->update(); - $this->assertNull($response->getData()); - $this->assertEquals($this->msg, $response->getMessage()); - $this->assertEquals(NewsAPIResult::EXISTS_ERROR, $response->getStatusCode()); + $data = $response->getData(); + $this->assertEquals($this->msg, $data['message']); + $this->assertEquals(Http::STATUS_CONFLICT, $response->getStatus()); } @@ -374,9 +374,8 @@ class FolderAPITest extends ControllerTestUtility { $response = $this->folderAPI->read(); - $this->assertNull($response->getData()); - $this->assertNull($response->getMessage()); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $this->assertEmpty($response->getData()); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } diff --git a/tests/unit/external/ItemAPITest.php b/tests/unit/external/ItemAPITest.php index cc66d562d..f20e38b25 100644 --- a/tests/unit/external/ItemAPITest.php +++ b/tests/unit/external/ItemAPITest.php @@ -27,6 +27,7 @@ namespace OCA\News\External; use \OCA\AppFramework\Http\Request; use \OCA\AppFramework\Http\JSONResponse; +use \OCA\AppFramework\Http\Http; use \OCA\AppFramework\Utility\ControllerTestUtility; use \OCA\News\BusinessLayer\BusinessLayerException; @@ -228,9 +229,8 @@ class ItemAPITest extends ControllerTestUtility { $response = $this->itemAPI->read(); - $this->assertNull($response->getData()); - $this->assertNull($response->getMessage()); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $this->assertEmpty($response->getData()); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } @@ -253,9 +253,9 @@ class ItemAPITest extends ControllerTestUtility { $response = $this->itemAPI->read(); - $this->assertNull($response->getData()); - $this->assertEquals($this->msg, $response->getMessage()); - $this->assertEquals(NewsAPIResult::NOT_FOUND_ERROR, $response->getStatusCode()); + $data = $response->getData(); + $this->assertEquals($this->msg, $data['message']); + $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); } @@ -282,9 +282,8 @@ class ItemAPITest extends ControllerTestUtility { $response = $this->itemAPI->unread(); - $this->assertNull($response->getData()); - $this->assertNull($response->getMessage()); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $this->assertEmpty($response->getData()); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } @@ -307,9 +306,9 @@ class ItemAPITest extends ControllerTestUtility { $response = $this->itemAPI->unread(); - $this->assertNull($response->getData()); - $this->assertEquals($this->msg, $response->getMessage()); - $this->assertEquals(NewsAPIResult::NOT_FOUND_ERROR, $response->getStatusCode()); + $data = $response->getData(); + $this->assertEquals($this->msg, $data['message']); + $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); } @@ -338,9 +337,8 @@ class ItemAPITest extends ControllerTestUtility { $response = $this->itemAPI->star(); - $this->assertNull($response->getData()); - $this->assertNull($response->getMessage()); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $data = $response->getData(); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } @@ -364,9 +362,9 @@ class ItemAPITest extends ControllerTestUtility { $response = $this->itemAPI->star(); - $this->assertNull($response->getData()); - $this->assertEquals($this->msg, $response->getMessage()); - $this->assertEquals(NewsAPIResult::NOT_FOUND_ERROR, $response->getStatusCode()); + $data = $response->getData(); + $this->assertEquals($this->msg, $data['message']); + $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); } @@ -395,9 +393,8 @@ class ItemAPITest extends ControllerTestUtility { $response = $this->itemAPI->unstar(); - $this->assertNull($response->getData()); - $this->assertNull($response->getMessage()); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $this->assertEmpty($response->getData()); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } @@ -421,9 +418,9 @@ class ItemAPITest extends ControllerTestUtility { $response = $this->itemAPI->unstar(); - $this->assertNull($response->getData()); - $this->assertEquals($this->msg, $response->getMessage()); - $this->assertEquals(NewsAPIResult::NOT_FOUND_ERROR, $response->getStatusCode()); + $data = $response->getData(); + $this->assertEquals($this->msg, $data['message']); + $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); } @@ -450,9 +447,8 @@ class ItemAPITest extends ControllerTestUtility { $response = $this->itemAPI->readAll(); - $this->assertNull($response->getData()); - $this->assertNull($response->getMessage()); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $this->assertEmpty($response->getData()); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } @@ -481,7 +477,7 @@ class ItemAPITest extends ControllerTestUtility { $this->equalTo(true), $this->equalTo($this->user)); $response = $this->itemAPI->readMultiple(); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } @@ -534,7 +530,7 @@ class ItemAPITest extends ControllerTestUtility { $this->equalTo(false), $this->equalTo($this->user)); $response = $this->itemAPI->unreadMultiple(); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } @@ -573,7 +569,7 @@ class ItemAPITest extends ControllerTestUtility { $this->equalTo(true), $this->equalTo($this->user)); $response = $this->itemAPI->starMultiple(); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } @@ -647,7 +643,7 @@ class ItemAPITest extends ControllerTestUtility { $this->equalTo(false), $this->equalTo($this->user)); $response = $this->itemAPI->unstarMultiple(); - $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); } |