diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/classloader.php | 1 | ||||
-rw-r--r-- | tests/unit/controller/ExportControllerTest.php | 20 | ||||
-rw-r--r-- | tests/unit/controller/FeedApiControllerTest.php | 256 | ||||
-rw-r--r-- | tests/unit/controller/FeedControllerTest.php | 268 | ||||
-rw-r--r-- | tests/unit/controller/FolderApiControllerTest.php | 191 | ||||
-rw-r--r-- | tests/unit/controller/FolderControllerTest.php | 179 | ||||
-rw-r--r-- | tests/unit/controller/ItemApiControllerTest.php | 379 | ||||
-rw-r--r-- | tests/unit/controller/ItemControllerTest.php | 234 | ||||
-rw-r--r-- | tests/unit/controller/PageControllerTest.php | 50 | ||||
-rw-r--r-- | tests/unit/controller/UtilityApiControllerTest.php | 64 | ||||
-rw-r--r-- | tests/unit/db/FeedMapperTest.php | 12 | ||||
-rw-r--r-- | tests/unit/db/FolderMapperTest.php | 8 | ||||
-rw-r--r-- | tests/unit/db/ItemMapperTest.php | 9 | ||||
-rw-r--r-- | tests/unit/db/ItemTest.php | 20 | ||||
-rw-r--r-- | tests/unit/db/MapperFactoryTest.php | 2 | ||||
-rw-r--r-- | tests/unit/db/postgres/ItemMapperTest.php | 7 |
16 files changed, 313 insertions, 1387 deletions
diff --git a/tests/classloader.php b/tests/classloader.php index bca9c21ea..8fdd9704d 100644 --- a/tests/classloader.php +++ b/tests/classloader.php @@ -12,6 +12,7 @@ */ require_once __DIR__ . '/../3rdparty/simplepie/autoloader.php'; +require_once __DIR__ . '/../../../tests/lib/appframework/db/MapperTestUtility.php'; // to execute without owncloud, we need to create our own classloader spl_autoload_register(function ($className){ diff --git a/tests/unit/controller/ExportControllerTest.php b/tests/unit/controller/ExportControllerTest.php index 820784d18..f41977241 100644 --- a/tests/unit/controller/ExportControllerTest.php +++ b/tests/unit/controller/ExportControllerTest.php @@ -13,11 +13,9 @@ namespace OCA\News\Controller; -use \OCP\IRequest; use \OCP\AppFramework\Http; use \OCA\News\Http\TextDownloadResponse; -use \OCA\News\Utility\ControllerTestUtility; use \OCA\News\Utility\OPMLExporter; use \OCA\News\Db\Item; use \OCA\News\Db\Feed; @@ -25,7 +23,7 @@ use \OCA\News\Db\Feed; require_once(__DIR__ . "/../../classloader.php"); -class ExportControllerTest extends ControllerTestUtility { +class ExportControllerTest extends \PHPUnit_Framework_TestCase { private $appName; private $request; @@ -51,7 +49,9 @@ class ExportControllerTest extends ControllerTestUtility { $this->folderBusinessLayer = $this->getMockBuilder('\OCA\News\BusinessLayer\FolderBusinessLayer') ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getRequest(); + $this->request = $this->getMockBuilder('\OCP\IRequest') + ->disableOriginalConstructor() + ->getMock(); $this->opmlExporter = new OPMLExporter(); $this->controller = new ExportController($this->appName, $this->request, $this->feedBusinessLayer, $this->folderBusinessLayer, @@ -59,18 +59,6 @@ class ExportControllerTest extends ControllerTestUtility { } - public function testOpmlAnnotations(){ - $annotations = array('NoAdminRequired', 'NoCSRFRequired'); - $this->assertAnnotations($this->controller, 'opml', $annotations); - } - - - public function testArticlesAnnotations(){ - $annotations = array('NoAdminRequired', 'NoCSRFRequired'); - $this->assertAnnotations($this->controller, 'articles', $annotations); - } - - public function testOpmlExportNoFeeds(){ $opml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . diff --git a/tests/unit/controller/FeedApiControllerTest.php b/tests/unit/controller/FeedApiControllerTest.php index 220e89ea9..1444fa563 100644 --- a/tests/unit/controller/FeedApiControllerTest.php +++ b/tests/unit/controller/FeedApiControllerTest.php @@ -13,10 +13,8 @@ namespace OCA\News\Controller; -use \OCP\IRequest; use \OCP\AppFramework\Http; -use \OCA\News\Utility\ControllerTestUtility; use \OCA\News\BusinessLayer\BusinessLayerException; use \OCA\News\BusinessLayer\BusinessLayerConflictException; use \OCA\News\Db\Folder; @@ -26,7 +24,7 @@ use \OCA\News\Db\Item; require_once(__DIR__ . "/../../classloader.php"); -class FeedApiControllerTest extends ControllerTestUtility { +class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { private $folderBusinessLayer; private $feedBusinessLayer; @@ -37,11 +35,13 @@ class FeedApiControllerTest extends ControllerTestUtility { private $request; private $msg; private $logger; + private $loggerParams; protected function setUp() { $this->user = 'tom'; + $this->loggerParams = array('hi'); $this->logger = $this->getMockBuilder( - '\OCA\News\Core\Logger') + '\OCP\ILogger') ->disableOriginalConstructor() ->getMock(); $this->appName = 'news'; @@ -68,55 +68,13 @@ class FeedApiControllerTest extends ControllerTestUtility { $this->feedBusinessLayer, $this->itemBusinessLayer, $this->logger, - $this->user + $this->user, + $this->loggerParams ); $this->msg = 'hohoho'; } - private function assertDefaultAnnotations($methodName){ - $annotations = array('NoAdminRequired', 'NoCSRFRequired', 'API'); - $this->assertAnnotations($this->feedAPI, $methodName, $annotations); - } - - - public function testGetAllAnnotations(){ - $this->assertDefaultAnnotations('index'); - } - - - public function testCreateAnnotations(){ - $this->assertDefaultAnnotations('create'); - } - - - public function testDeleteAnnotations(){ - $this->assertDefaultAnnotations('delete'); - } - - - public function testMoveAnnotations(){ - $this->assertDefaultAnnotations('move'); - } - - - public function testReadAnnotations(){ - $this->assertDefaultAnnotations('read'); - } - - - public function testFromUsersAnnotations(){ - $annotations = array('NoCSRFRequired', 'API'); - $this->assertAnnotations($this->feedAPI, 'fromAllUsers', $annotations); - } - - - public function testUpdateAnnotations(){ - $annotations = array('NoCSRFRequired'); - $this->assertAnnotations($this->feedAPI, 'update', $annotations); - } - - public function testIndex() { $feeds = array( new Feed() @@ -143,7 +101,7 @@ class FeedApiControllerTest extends ControllerTestUtility { 'feeds' => array($feeds[0]->toAPI()), 'starredCount' => $starredCount, 'newestItemId' => $newestItemId - ), $response->getData()); + ), $response); } @@ -171,56 +129,27 @@ class FeedApiControllerTest extends ControllerTestUtility { $this->assertEquals(array( 'feeds' => array($feeds[0]->toAPI()), 'starredCount' => $starredCount, - ), $response->getData()); + ), $response); } public function testDelete() { - $request = $this->getRequest(array('urlParams' => array( - 'feedId' => 2 - ))); - $this->feedAPI = new FeedApiController( - $this->appName, - $request, - $this->folderBusinessLayer, - $this->feedBusinessLayer, - $this->itemBusinessLayer, - $this->logger, - $this->user - ); - $this->feedBusinessLayer->expects($this->once()) ->method('delete') ->with( $this->equalTo(2), $this->equalTo($this->user)); - $response = $this->feedAPI->delete(); - - $this->assertEmpty($response->getData()); - $this->assertEquals(Http::STATUS_OK, $response->getStatus()); + $this->feedAPI->delete(2); } public function testDeleteDoesNotExist() { - $request = $this->getRequest(array('urlParams' => array( - 'feedId' => 2 - ))); - $this->feedAPI = new FeedApiController( - $this->appName, - $request, - $this->folderBusinessLayer, - $this->feedBusinessLayer, - $this->itemBusinessLayer, - $this->logger, - $this->user - ); - $this->feedBusinessLayer->expects($this->once()) ->method('delete') ->will($this->throwException(new BusinessLayerException($this->msg))); - $response = $this->feedAPI->delete(); + $response = $this->feedAPI->delete(2); $data = $response->getData(); $this->assertEquals($this->msg, $data['message']); @@ -232,19 +161,6 @@ class FeedApiControllerTest extends ControllerTestUtility { $feeds = array( new Feed() ); - $request = $this->getRequest(array('params' => array( - 'url' => 'ho', - 'folderId' => 3 - ))); - $this->feedAPI = new FeedApiController( - $this->appName, - $request, - $this->folderBusinessLayer, - $this->feedBusinessLayer, - $this->itemBusinessLayer, - $this->logger, - $this->user - ); $this->feedBusinessLayer->expects($this->once()) ->method('purgeDeleted') @@ -252,7 +168,7 @@ class FeedApiControllerTest extends ControllerTestUtility { $this->feedBusinessLayer->expects($this->once()) ->method('create') ->with( - $this->equalTo('ho'), + $this->equalTo('url'), $this->equalTo(3), $this->equalTo($this->user)) ->will($this->returnValue($feeds[0])); @@ -260,14 +176,12 @@ class FeedApiControllerTest extends ControllerTestUtility { ->method('getNewestItemId') ->will($this->returnValue(3)); - $response = $this->feedAPI->create(); + $response = $this->feedAPI->create('url', 3); $this->assertEquals(array( 'feeds' => array($feeds[0]->toAPI()), 'newestItemId' => 3 - ), $response->getData()); - - $this->assertEquals(Http::STATUS_OK, $response->getStatus()); + ), $response); } @@ -275,19 +189,6 @@ class FeedApiControllerTest extends ControllerTestUtility { $feeds = array( new Feed() ); - $request = $this->getRequest(array('params' => array( - 'url' => 'ho', - 'folderId' => 3 - ))); - $this->feedAPI = new FeedApiController( - $this->appName, - $request, - $this->folderBusinessLayer, - $this->feedBusinessLayer, - $this->itemBusinessLayer, - $this->logger, - $this->user - ); $this->feedBusinessLayer->expects($this->once()) ->method('purgeDeleted') @@ -303,13 +204,11 @@ class FeedApiControllerTest extends ControllerTestUtility { ->method('getNewestItemId') ->will($this->throwException(new BusinessLayerException(''))); - $response = $this->feedAPI->create(); + $response = $this->feedAPI->create('ho', 3); $this->assertEquals(array( 'feeds' => array($feeds[0]->toAPI()) - ), $response->getData()); - - $this->assertEquals(Http::STATUS_OK, $response->getStatus()); + ), $response); } @@ -322,7 +221,7 @@ class FeedApiControllerTest extends ControllerTestUtility { ->method('create') ->will($this->throwException(new BusinessLayerConflictException($this->msg))); - $response = $this->feedAPI->create(); + $response = $this->feedAPI->create('ho', 3); $data = $response->getData(); $this->assertEquals($this->msg, $data['message']); @@ -335,7 +234,7 @@ class FeedApiControllerTest extends ControllerTestUtility { ->method('create') ->will($this->throwException(new BusinessLayerException($this->msg))); - $response = $this->feedAPI->create(); + $response = $this->feedAPI->create('ho', 3); $data = $response->getData(); $this->assertEquals($this->msg, $data['message']); @@ -344,24 +243,6 @@ class FeedApiControllerTest extends ControllerTestUtility { public function testRead() { - $request = $this->getRequest(array( - 'urlParams' => array( - 'feedId' => 3 - ), - 'params' => array( - 'newestItemId' => 30, - ) - )); - $this->feedAPI = new FeedApiController( - $this->appName, - $request, - $this->folderBusinessLayer, - $this->feedBusinessLayer, - $this->itemBusinessLayer, - $this->logger, - $this->user - ); - $this->itemBusinessLayer->expects($this->once()) ->method('readFeed') ->with( @@ -369,32 +250,11 @@ class FeedApiControllerTest extends ControllerTestUtility { $this->equalTo(30), $this->equalTo($this->user)); - $response = $this->feedAPI->read(); - - $this->assertEmpty($response->getData()); - $this->assertEquals(Http::STATUS_OK, $response->getStatus()); + $this->feedAPI->read(3, 30); } public function testMove() { - $request = $this->getRequest(array( - 'urlParams' => array( - 'feedId' => 3 - ), - 'params' => array( - 'folderId' => 30, - ) - )); - $this->feedAPI = new FeedApiController( - $this->appName, - $request, - $this->folderBusinessLayer, - $this->feedBusinessLayer, - $this->itemBusinessLayer, - $this->logger, - $this->user - ); - $this->feedBusinessLayer->expects($this->once()) ->method('move') ->with( @@ -402,10 +262,20 @@ class FeedApiControllerTest extends ControllerTestUtility { $this->equalTo(30), $this->equalTo($this->user)); - $response = $this->feedAPI->move(); + $this->feedAPI->move(3, 30); + } + + + public function testMoveDoesNotExist() { + $this->feedBusinessLayer->expects($this->once()) + ->method('move') + ->will($this->throwException(new BusinessLayerException($this->msg))); + + $response = $this->feedAPI->move(3, 4); - $this->assertEmpty($response->getData()); - $this->assertEquals(Http::STATUS_OK, $response->getStatus()); + $data = $response->getData(); + $this->assertEquals($this->msg, $data['message']); + $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); } @@ -413,24 +283,6 @@ class FeedApiControllerTest extends ControllerTestUtility { $feedId = 3; $feedTitle = 'test'; - $request = $this->getRequest(array( - 'urlParams' => array( - 'feedId' => $feedId - ), - 'params' => array( - 'feedTitle' => $feedTitle - ) - )); - $this->feedAPI = new FeedApiController( - $this->appName, - $request, - $this->folderBusinessLayer, - $this->feedBusinessLayer, - $this->itemBusinessLayer, - $this->logger, - $this->user - ); - $this->feedBusinessLayer->expects($this->once()) ->method('rename') ->with( @@ -438,23 +290,7 @@ class FeedApiControllerTest extends ControllerTestUtility { $this->equalTo($feedTitle), $this->equalTo($this->user)); - $response = $this->feedAPI->rename(); - - $this->assertEmpty($response->getData()); - $this->assertEquals(Http::STATUS_OK, $response->getStatus()); - } - - - public function testMoveDoesNotExist() { - $this->feedBusinessLayer->expects($this->once()) - ->method('move') - ->will($this->throwException(new BusinessLayerException($this->msg))); - - $response = $this->feedAPI->move(); - - $data = $response->getData(); - $this->assertEquals($this->msg, $data['message']); - $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); + $this->feedAPI->rename($feedId, $feedTitle); } @@ -467,45 +303,35 @@ class FeedApiControllerTest extends ControllerTestUtility { $this->feedBusinessLayer->expects($this->once()) ->method('findAllFromAllUsers') ->will($this->returnValue($feeds)); - $response = $this->feedAPI->fromAllUsers(); - $this->assertEquals('{"feeds":[{"id":1,"userId":"john"}]}', $response->render()); + $response = json_encode($this->feedAPI->fromAllUsers()); + $this->assertEquals('{"feeds":[{"id":1,"userId":"john"}]}', $response); } public function testUpdate() { $feedId = 3; $userId = 'hi'; - $request = $this->getRequest(array('params' => array( - 'feedId' => $feedId, - 'userId' => $userId - ))); - $this->feedAPI = new FeedApiController( - $this->appName, - $request, - $this->folderBusinessLayer, - $this->feedBusinessLayer, - $this->itemBusinessLayer, - $this->logger, - $this->user - ); + $this->feedBusinessLayer->expects($this->once()) ->method('update') ->with($this->equalTo($feedId), $this->equalTo($userId)); - $this->feedAPI->update(); + $this->feedAPI->update($userId, $feedId); } public function testUpdateError() { + $feedId = 3; + $userId = 'hi'; $this->feedBusinessLayer->expects($this->once()) ->method('update') ->will($this->throwException(new \Exception($this->msg))); $this->logger->expects($this->once()) - ->method('log') + ->method('debug') ->with($this->equalTo('Could not update feed ' . $this->msg), - $this->equalTo('debug')); + $this->equalTo($this->loggerParams)); - $this->feedAPI->update(); + $this->feedAPI->update($userId, $feedId); } diff --git a/tests/unit/controller/FeedControllerTest.php b/tests/unit/controller/FeedControllerTest.php index 4238b1faa..ba9d86a8a 100644 --- a/tests/unit/controller/FeedControllerTest.php +++ b/tests/unit/controller/FeedControllerTest.php @@ -13,10 +13,8 @@ namespace OCA\News\Controller; -use \OCP\IRequest; use \OCP\AppFramework\Http; -use \OCA\News\Utility\ControllerTestUtility; use \OCA\News\Db\Feed; use \OCA\News\Db\FeedType; use \OCA\News\BusinessLayer\BusinessLayerException; @@ -25,7 +23,7 @@ use \OCA\News\BusinessLayer\BusinessLayerConflictException; require_once(__DIR__ . "/../../classloader.php"); -class FeedControllerTest extends ControllerTestUtility { +class FeedControllerTest extends \PHPUnit_Framework_TestCase { private $appName; private $feedBusinessLayer; @@ -55,7 +53,10 @@ class FeedControllerTest extends ControllerTestUtility { $this->folderBusinessLayer = $this->getMockBuilder('\OCA\News\BusinessLayer\FolderBusinessLayer') ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getRequest(); + $this->request = $this->getMockBuilder( + '\OCP\IRequest') + ->disableOriginalConstructor() + ->getMock(); $this->controller = new FeedController($this->appName, $this->request, $this->folderBusinessLayer, $this->feedBusinessLayer, @@ -64,70 +65,6 @@ class FeedControllerTest extends ControllerTestUtility { $this->user); } - private function assertFeedControllerAnnotations($methodName){ - $annotations = array('NoAdminRequired'); - $this->assertAnnotations($this->controller, $methodName, $annotations); - } - - - private function getPostController($postValue, $url=array()){ - $post = array( - 'post' => $postValue, - 'urlParams' => $url - ); - - $request = $this->getRequest($post); - return new FeedController($this->appName, $request, - $this->folderBusinessLayer, - $this->feedBusinessLayer, - $this->itemBusinessLayer, - $this->settings, - $this->user); - } - - - public function testFeedsAnnotations(){ - $this->assertFeedControllerAnnotations('index'); - } - - - public function testActiveAnnotations(){ - $this->assertFeedControllerAnnotations('active'); - } - - - public function testCreateAnnotations(){ - $this->assertFeedControllerAnnotations('create'); - } - - - public function testDeleteAnnotations(){ - $this->assertFeedControllerAnnotations('delete'); - } - - - public function testRestoreAnnotations(){ - $this->assertFeedControllerAnnotations('restore'); - } - - - public function testUpdateAnnotations(){ - $this->assertFeedControllerAnnotations('update'); - } - - - public function testMoveAnnotations(){ - $this->assertFeedControllerAnnotations('move'); - } - - - public function testImportArticlesAnnotations(){ - $this->assertFeedControllerAnnotations('import'); - } - - public function testReadAnnotations(){ - $this->assertFeedControllerAnnotations('read'); - } public function testIndex(){ $result = array( @@ -151,7 +88,7 @@ class FeedControllerTest extends ControllerTestUtility { $response = $this->controller->index(); - $this->assertEquals($result, $response->getData()); + $this->assertEquals($result, $response); } @@ -178,7 +115,7 @@ class FeedControllerTest extends ControllerTestUtility { $response = $this->controller->index(); - $this->assertEquals($result, $response->getData()); + $this->assertEquals($result, $response); } @@ -213,7 +150,7 @@ class FeedControllerTest extends ControllerTestUtility { $response = $this->controller->active(); - $this->assertEquals($result, $response->getData()); + $this->assertEquals($result, $response); } @@ -236,7 +173,7 @@ class FeedControllerTest extends ControllerTestUtility { $response = $this->controller->active(); - $this->assertEquals($result, $response->getData()); + $this->assertEquals($result, $response); } @@ -259,7 +196,7 @@ class FeedControllerTest extends ControllerTestUtility { $response = $this->controller->active(); - $this->assertEquals($result, $response->getData()); + $this->assertEquals($result, $response); } @@ -277,7 +214,7 @@ class FeedControllerTest extends ControllerTestUtility { $response = $this->controller->active(); - $this->assertEquals($result, $response->getData()); + $this->assertEquals($result, $response); } @@ -287,13 +224,6 @@ class FeedControllerTest extends ControllerTestUtility { 'newestItemId' => 3 ); - $post = array( - 'url' => 'hi', - 'parentFolderId' => 4 - ); - $this->controller = $this->getPostController($post); - - $this->itemBusinessLayer->expects($this->once()) ->method('getNewestItemId') ->will($this->returnValue($result['newestItemId'])); @@ -302,14 +232,14 @@ class FeedControllerTest extends ControllerTestUtility { ->with($this->equalTo($this->user), $this->equalTo(false)); $this->feedBusinessLayer->expects($this->once()) ->method('create') - ->with($this->equalTo($post['url']), - $this->equalTo($post['parentFolderId']), + ->with($this->equalTo('hi'), + $this->equalTo(4), $this->equalTo($this->user)) ->will($this->returnValue($result['feeds'][0])); - $response = $this->controller->create(); + $response = $this->controller->create('hi', 4); - $this->assertEquals($result, $response->getData()); + $this->assertEquals($result, $response); } @@ -318,12 +248,6 @@ class FeedControllerTest extends ControllerTestUtility { 'feeds' => array(new Feed()) ); - $post = array( - 'url' => 'hi', - 'parentFolderId' => 4 - ); - $this->controller = $this->getPostController($post); - $this->feedBusinessLayer->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); @@ -334,14 +258,14 @@ class FeedControllerTest extends ControllerTestUtility { $this->feedBusinessLayer->expects($this->once()) ->method('create') - ->with($this->equalTo($post['url']), - $this->equalTo($post['parentFolderId']), + ->with($this->equalTo('hi'), + $this->equalTo(4), $this->equalTo($this->user)) ->will($this->returnValue($result['feeds'][0])); - $response = $this->controller->create(); + $response = $this->controller->create('hi', 4); - $this->assertEquals($result, $response->getData()); + $this->assertEquals($result, $response); } @@ -355,10 +279,10 @@ class FeedControllerTest extends ControllerTestUtility { ->method('create') ->will($this->throwException($ex)); - $response = $this->controller->create(); + $response = $this->controller->create('hi', 4); $params = json_decode($response->render(), true); - $this->assertEquals($msg, $params['msg']); + $this->assertEquals($msg, $params['message']); $this->assertEquals($response->getStatus(), Http::STATUS_UNPROCESSABLE_ENTITY); } @@ -373,43 +297,34 @@ class FeedControllerTest extends ControllerTestUtility { ->method('create') ->will($this->throwException($ex)); - $response = $this->controller->create(); + $response = $this->controller->create('hi', 4); $params = json_decode($response->render(), true); - $this->assertEquals($msg, $params['msg']); + $this->assertEquals($msg, $params['message']); $this->assertEquals($response->getStatus(), Http::STATUS_CONFLICT); } public function testDelete(){ - $url = array( - 'feedId' => 4 - ); - $this->controller = $this->getPostController(array(), $url); - $this->feedBusinessLayer->expects($this->once()) ->method('markDeleted') - ->with($this->equalTo($url['feedId'])); + ->with($this->equalTo(4)); - $this->controller->delete(); + $this->controller->delete(4); } public function testDeleteDoesNotExist(){ - $url = array( - 'feedId' => 4 - ); $msg = 'hehe'; - $this->controller = $this->getPostController(array(), $url); $this->feedBusinessLayer->expects($this->once()) ->method('markDeleted') ->will($this->throwException(new BusinessLayerException($msg))); - $response = $this->controller->delete(); + $response = $this->controller->delete(4); $params = json_decode($response->render(), true); - $this->assertEquals($msg, $params['msg']); + $this->assertEquals($msg, $params['message']); $this->assertEquals($response->getStatus(), Http::STATUS_NOT_FOUND); } @@ -427,125 +342,84 @@ class FeedControllerTest extends ControllerTestUtility { ) ); - $url = array( - 'feedId' => 4 - ); - $this->controller = $this->getPostController(array(), $url); - $this->feedBusinessLayer->expects($this->once()) ->method('update') - ->with($this->equalTo($url['feedId']), $this->equalTo($this->user)) + ->with($this->equalTo(4), $this->equalTo($this->user)) ->will($this->returnValue($feed)); - $response = $this->controller->update(); + $response = $this->controller->update(4); - $this->assertEquals($result, $response->getData()); + $this->assertEquals($result, $response); } public function testUpdateReturnsJSONError(){ - $url = array( - 'feedId' => 4 - ); - $this->controller = $this->getPostController(array(), $url); - $this->feedBusinessLayer->expects($this->once()) ->method('update') - ->with($this->equalTo($url['feedId']), $this->equalTo($this->user)) |