diff options
Diffstat (limited to 'tests/unit/controller')
-rw-r--r-- | tests/unit/controller/ApiControllerTest.php | 19 | ||||
-rw-r--r-- | tests/unit/controller/ExportControllerTest.php | 16 | ||||
-rw-r--r-- | tests/unit/controller/FeedApiControllerTest.php | 102 | ||||
-rw-r--r-- | tests/unit/controller/FeedControllerTest.php | 87 | ||||
-rw-r--r-- | tests/unit/controller/FolderApiControllerTest.php | 87 | ||||
-rw-r--r-- | tests/unit/controller/FolderControllerTest.php | 55 | ||||
-rw-r--r-- | tests/unit/controller/ItemApiControllerTest.php | 156 | ||||
-rw-r--r-- | tests/unit/controller/ItemControllerTest.php | 67 | ||||
-rw-r--r-- | tests/unit/controller/PageControllerTest.php | 36 |
9 files changed, 216 insertions, 409 deletions
diff --git a/tests/unit/controller/ApiControllerTest.php b/tests/unit/controller/ApiControllerTest.php index 722830a23..6aa6ee4ea 100644 --- a/tests/unit/controller/ApiControllerTest.php +++ b/tests/unit/controller/ApiControllerTest.php @@ -36,14 +36,16 @@ require_once(__DIR__ . "/../../classloader.php"); class ApiControllerTest extends ControllerTestUtility { - private $api; + private $settings; private $request; private $newsAPI; private $updater; + private $appName; protected function setUp() { - $this->api = $this->getMockBuilder( - '\OCA\News\Core\API') + $this->appName = 'news'; + $this->settings = $this->getMockBuilder( + '\OCA\News\Core\Settings') ->disableOriginalConstructor() ->getMock(); $this->request = $this->getMockBuilder( @@ -54,7 +56,8 @@ class ApiControllerTest extends ControllerTestUtility { '\OCA\News\Utility\Updater') ->disableOriginalConstructor() ->getMock(); - $this->newsAPI = new ApiController($this->api, $this->request, $this->updater); + $this->newsAPI = new ApiController($this->appName, $this->request, + $this->updater, $this->settings); } @@ -78,7 +81,7 @@ class ApiControllerTest extends ControllerTestUtility { } public function testGetVersion(){ - $this->api->expects($this->once()) + $this->settings->expects($this->once()) ->method('getAppValue') ->with($this->equalTo('installed_version')) ->will($this->returnValue('1.0')); @@ -115,7 +118,8 @@ class ApiControllerTest extends ControllerTestUtility { public function testCors() { $this->request = $this->getRequest(array('server' => array())); - $this->newsAPI = new ApiController($this->api, $this->request, $this->updater); + $this->newsAPI = new ApiController($this->appName, $this->request, + $this->updater, $this->settings); $response = $this->newsAPI->cors(); $headers = $response->getHeaders(); @@ -130,7 +134,8 @@ class ApiControllerTest extends ControllerTestUtility { public function testCorsUsesOriginIfGiven() { $this->request = $this->getRequest(array('server' => array('HTTP_ORIGIN' => 'test'))); - $this->newsAPI = new ApiController($this->api, $this->request, $this->updater); + $this->newsAPI = new ApiController($this->appName, $this->request, + $this->updater, $this->settings); $response = $this->newsAPI->cors(); $headers = $response->getHeaders(); diff --git a/tests/unit/controller/ExportControllerTest.php b/tests/unit/controller/ExportControllerTest.php index b79574ff2..bc3baf4cf 100644 --- a/tests/unit/controller/ExportControllerTest.php +++ b/tests/unit/controller/ExportControllerTest.php @@ -40,7 +40,7 @@ require_once(__DIR__ . "/../../classloader.php"); class ExportControllerTest extends ControllerTestUtility { - private $api; + private $appName; private $request; private $controller; private $user; @@ -53,7 +53,8 @@ class ExportControllerTest extends ControllerTestUtility { * Gets run before each test */ public function setUp(){ - $this->api = $this->getAPIMock(); + $this->appName = 'news'; + $this->user = 'john'; $this->itemBusinessLayer = $this->getMockBuilder('\OCA\News\BusinessLayer\ItemBusinessLayer') ->disableOriginalConstructor() ->getMock(); @@ -65,10 +66,9 @@ class ExportControllerTest extends ControllerTestUtility { ->getMock(); $this->request = $this->getRequest(); $this->opmlExporter = new OPMLExporter(); - $this->controller = new ExportController($this->api, $this->request, + $this->controller = new ExportController($this->appName, $this->request, $this->feedBusinessLayer, $this->folderBusinessLayer, - $this->itemBusinessLayer, $this->opmlExporter); - $this->user = 'john'; + $this->itemBusinessLayer, $this->opmlExporter, $this->user); } @@ -94,9 +94,6 @@ class ExportControllerTest extends ControllerTestUtility { " <body/>\n" . "</opml>\n"; - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('findAll') ->with($this->equalTo($this->user)) @@ -130,9 +127,6 @@ class ExportControllerTest extends ControllerTestUtility { $item1, $item2 ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('findAll') ->with($this->equalTo($this->user)) diff --git a/tests/unit/controller/FeedApiControllerTest.php b/tests/unit/controller/FeedApiControllerTest.php index 8bb8447bd..752eb575b 100644 --- a/tests/unit/controller/FeedApiControllerTest.php +++ b/tests/unit/controller/FeedApiControllerTest.php @@ -45,16 +45,19 @@ class FeedApiControllerTest extends ControllerTestUtility { private $feedBusinessLayer; private $itemBusinessLayer; private $feedAPI; - private $api; + private $appName; private $user; private $request; private $msg; + private $logger; protected function setUp() { - $this->api = $this->getMockBuilder( - '\OCA\News\Core\API') + $this->user = 'tom'; + $this->logger = $this->getMockBuilder( + '\OCA\News\Core\Logger') ->disableOriginalConstructor() ->getMock(); + $this->appName = 'news'; $this->request = $this->getMockBuilder( '\OCP\IRequest') ->disableOriginalConstructor() @@ -72,13 +75,14 @@ class FeedApiControllerTest extends ControllerTestUtility { ->disableOriginalConstructor() ->getMock(); $this->feedAPI = new FeedApiController( - $this->api, + $this->appName, $this->request, $this->folderBusinessLayer, $this->feedBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->logger, + $this->user ); - $this->user = 'tom'; $this->msg = 'hohoho'; } @@ -133,9 +137,6 @@ class FeedApiControllerTest extends ControllerTestUtility { $starredCount = 3; $newestItemId = 2; - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('starredCount') ->with($this->equalTo($this->user)) @@ -165,9 +166,6 @@ class FeedApiControllerTest extends ControllerTestUtility { ); $starredCount = 3; - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('starredCount') ->with($this->equalTo($this->user)) @@ -195,16 +193,15 @@ class FeedApiControllerTest extends ControllerTestUtility { 'feedId' => 2 ))); $this->feedAPI = new FeedApiController( - $this->api, + $this->appName, $request, $this->folderBusinessLayer, $this->feedBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->logger, + $this->user ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('delete') ->with( @@ -223,16 +220,15 @@ class FeedApiControllerTest extends ControllerTestUtility { 'feedId' => 2 ))); $this->feedAPI = new FeedApiController( - $this->api, + $this->appName, $request, $this->folderBusinessLayer, $this->feedBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->logger, + $this->user ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('delete') ->will($this->throwException(new BusinessLayerException($this->msg))); @@ -254,16 +250,15 @@ class FeedApiControllerTest extends ControllerTestUtility { 'folderId' => 3 ))); $this->feedAPI = new FeedApiController( - $this->api, + $this->appName, $request, $this->folderBusinessLayer, $this->feedBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->logger, + $this->user ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); @@ -298,16 +293,15 @@ class FeedApiControllerTest extends ControllerTestUtility { 'folderId' => 3 ))); $this->feedAPI = new FeedApiController( - $this->api, + $this->appName, $request, $this->folderBusinessLayer, $this->feedBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->logger, + $this->user ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); @@ -334,9 +328,6 @@ class FeedApiControllerTest extends ControllerTestUtility { public function testCreateExists() { - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); @@ -353,9 +344,6 @@ class FeedApiControllerTest extends ControllerTestUtility { public function testCreateError() { - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('create') ->will($this->throwException(new BusinessLayerException($this->msg))); @@ -378,16 +366,15 @@ class FeedApiControllerTest extends ControllerTestUtility { ) )); $this->feedAPI = new FeedApiController( - $this->api, + $this->appName, $request, $this->folderBusinessLayer, $this->feedBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->logger, + $this->user ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('readFeed') ->with( @@ -412,16 +399,15 @@ class FeedApiControllerTest extends ControllerTestUtility { ) )); $this->feedAPI = new FeedApiController( - $this->api, + $this->appName, $request, $this->folderBusinessLayer, $this->feedBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->logger, + $this->user ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('move') ->with( @@ -449,16 +435,15 @@ class FeedApiControllerTest extends ControllerTestUtility { ) )); $this->feedAPI = new FeedApiController( - $this->api, + $this->appName, $request, $this->folderBusinessLayer, $this->feedBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->logger, + $this->user ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('rename') ->with( @@ -474,9 +459,6 @@ class FeedApiControllerTest extends ControllerTestUtility { public function testMoveDoesNotExist() { - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('move') ->will($this->throwException(new BusinessLayerException($this->msg))); @@ -512,11 +494,13 @@ class FeedApiControllerTest extends ControllerTestUtility { 'userId' => $userId ))); $this->feedAPI = new FeedApiController( - $this->api, + $this->appName, $request, $this->folderBusinessLayer, $this->feedBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->logger, + $this->user ); $this->feedBusinessLayer->expects($this->once()) ->method('update') @@ -531,7 +515,7 @@ class FeedApiControllerTest extends ControllerTestUtility { $this->feedBusinessLayer->expects($this->once()) ->method('update') ->will($this->throwException(new \Exception($this->msg))); - $this->api->expects($this->once()) + $this->logger->expects($this->once()) ->method('log') ->with($this->equalTo('Could not update feed ' . $this->msg), $this->equalTo('debug')); diff --git a/tests/unit/controller/FeedControllerTest.php b/tests/unit/controller/FeedControllerTest.php index 90c1b8e14..2135c5366 100644 --- a/tests/unit/controller/FeedControllerTest.php +++ b/tests/unit/controller/FeedControllerTest.php @@ -40,19 +40,25 @@ require_once(__DIR__ . "/../../classloader.php"); class FeedControllerTest extends ControllerTestUtility { - private $api; + private $appName; private $feedBusinessLayer; private $request; private $controller; private $folderBusinessLayer; private $itemBusinessLayer; + private $settings; /** * Gets run before each test */ public function setUp(){ - $this->api = $this->getAPIMock(); + $this->appName = 'news'; + $this->user = 'jack'; + $this->settings = $this->getMockBuilder( + '\OCA\News\Core\Settings') + ->disableOriginalConstructor() + ->getMock(); $this->itemBusinessLayer = $this->getMockBuilder('\OCA\News\BusinessLayer\ItemBusinessLayer') ->disableOriginalConstructor() ->getMock(); @@ -63,11 +69,12 @@ class FeedControllerTest extends ControllerTestUtility { ->disableOriginalConstructor() ->getMock(); $this->request = $this->getRequest(); - $this->controller = new FeedController($this->api, $this->request, + $this->controller = new FeedController($this->appName, $this->request, $this->folderBusinessLayer, $this->feedBusinessLayer, - $this->itemBusinessLayer); - $this->user = 'jack'; + $this->itemBusinessLayer, + $this->user, + $this->settings); } private function assertFeedControllerAnnotations($methodName){ @@ -83,10 +90,12 @@ class FeedControllerTest extends ControllerTestUtility { ); $request = $this->getRequest($post); - return new FeedController($this->api, $request, + return new FeedController($this->appName, $request, $this->folderBusinessLayer, $this->feedBusinessLayer, - $this->itemBusinessLayer); + $this->itemBusinessLayer, + $this->user, + $this->settings); } @@ -140,9 +149,6 @@ class FeedControllerTest extends ControllerTestUtility { ), 'starred' => 13 ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('findAll') ->with($this->equalTo($this->user)) @@ -171,9 +177,6 @@ class FeedControllerTest extends ControllerTestUtility { 'starred' => 13, 'newestItemId' => 5 ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('findAll') ->with($this->equalTo($this->user)) @@ -196,14 +199,11 @@ class FeedControllerTest extends ControllerTestUtility { private function activeInitMocks($id, $type){ - $this->api->expects($this->at(0)) - ->method('getUserId') - ->will($this->returnValue($this->user)); - $this->api->expects($this->at(1)) + $this->settings->expects($this->at(0)) ->method('getUserValue') ->with($this->equalTo('lastViewedFeedId')) ->will($this->returnValue($id)); - $this->api->expects($this->at(2)) + $this->settings->expects($this->at(1)) ->method('getUserValue') ->with($this->equalTo('lastViewedFeedType')) ->will($this->returnValue($type)); @@ -308,9 +308,6 @@ class FeedControllerTest extends ControllerTestUtility { ); $this->controller = $this->getPostController($post); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('getNewestItemId') @@ -343,9 +340,6 @@ class FeedControllerTest extends ControllerTestUtility { ); $this->controller = $this->getPostController($post); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); @@ -371,9 +365,6 @@ class FeedControllerTest extends ControllerTestUtility { public function testCreateReturnsErrorForInvalidCreate(){ $msg = 'except'; $ex = new BusinessLayerException($msg); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); @@ -393,9 +384,6 @@ class FeedControllerTest extends ControllerTestUtility { public function testCreateReturnsErrorForDuplicateCreate(){ $msg = 'except'; $ex = new BusinessLayerConflictException($msg); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); @@ -418,9 +406,6 @@ class FeedControllerTest extends ControllerTestUtility { ); $this->controller = $this->getPostController(array(), $url); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('markDeleted') ->with($this->equalTo($url['feedId'])); @@ -437,9 +422,6 @@ class FeedControllerTest extends ControllerTestUtility { $msg = 'hehe'; $this->controller = $this->getPostController(array(), $url); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('markDeleted') ->will($this->throwException(new BusinessLayerException($msg))); @@ -471,9 +453,6 @@ class FeedControllerTest extends ControllerTestUtility { ); $this->controller = $this->getPostController(array(), $url); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('update') ->with($this->equalTo($url['feedId']), $this->equalTo($this->user)) @@ -498,9 +477,6 @@ class FeedControllerTest extends ControllerTestUtility { ); $this->controller = $this->getPostController(array(), $url); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('update') ->with($this->equalTo($url['feedId']), $this->equalTo($this->user)) @@ -524,9 +500,6 @@ class FeedControllerTest extends ControllerTestUtility { ); $this->controller = $this->getPostController($post, $url); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('move') ->with($this->equalTo($url['feedId']), @@ -549,9 +522,6 @@ class FeedControllerTest extends ControllerTestUtility { $msg = 'john'; $this->controller = $this->getPostController($post, $url); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('move') ->will($this->throwException(new BusinessLayerException($msg))); @@ -574,9 +544,6 @@ class FeedControllerTest extends ControllerTestUtility { ); $this->controller = $this->getPostController($post, $url); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('rename') ->with($this->equalTo($url['feedId']), @@ -600,9 +567,6 @@ class FeedControllerTest extends ControllerTestUtility { $msg = 'hi'; - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('rename') ->with($this->equalTo($url['feedId']), @@ -631,9 +595,6 @@ class FeedControllerTest extends ControllerTestUtility { ); $this->controller = $this->getPostController($post); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('importArticles') ->with($this->equalTo($post['json']), @@ -656,9 +617,6 @@ class FeedControllerTest extends ControllerTestUtility { $expected = array(); $this->controller = $this->getPostController($post); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('importArticles') ->with($this->equalTo($post['json']), @@ -689,9 +647,6 @@ class FeedControllerTest extends ControllerTestUtility { ) ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('readFeed') ->with($url['feedId'], $post['highestItemId'], $this->user); @@ -708,9 +663,6 @@ class FeedControllerTest extends ControllerTestUtility { ); $this->controller = $this->getPostController(array(), $url); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('unmarkDeleted') ->with($this->equalTo($url['feedId'])); @@ -727,9 +679,6 @@ class FeedControllerTest extends ControllerTestUtility { $msg = 'hehe'; $this->controller = $this->getPostController(array(), $url); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('unmarkDeleted') ->will($this->throwException(new BusinessLayerException($msg))); diff --git a/tests/unit/controller/FolderApiControllerTest.php b/tests/unit/controller/FolderApiControllerTest.php index cc799dc18..702699b98 100644 --- a/tests/unit/controller/FolderApiControllerTest.php +++ b/tests/unit/controller/FolderApiControllerTest.php @@ -46,16 +46,14 @@ class FolderApiControllerTest extends ControllerTestUtility { private $folderBusinessLayer; private $itemBusinessLayer; private $folderAPI; - private $api; + private $appName; private $user; private $request; private $msg; protected function setUp() { - $this->api = $this->getMockBuilder( - '\OCA\News\Core\API') - ->disableOriginalConstructor() - ->getMock(); + $this->appName = 'news'; + $this->user = 'tom'; $this->request = $this->getMockBuilder( '\OCP\IRequest') ->disableOriginalConstructor() @@ -69,12 +67,12 @@ class FolderApiControllerTest extends ControllerTestUtility { ->disableOriginalConstructor() ->getMock(); $this->folderAPI = new FolderApiController( - $this->api, + $this->appName, $this->request, $this->folderBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->user ); - $this->user = 'tom'; $this->msg = 'test'; } @@ -115,9 +113,6 @@ class FolderApiControllerTest extends ControllerTestUtility { new Folder() ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('findAll') ->with($this->equalTo($this->user)) @@ -139,17 +134,15 @@ class FolderApiControllerTest extends ControllerTestUtility { $folder ); $this->folderAPI = new FolderApiController( - $this->api, + $this->appName, $this->getRequest(array('params' => array( 'name' => $folderName ))), $this->folderBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->user ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); @@ -169,9 +162,6 @@ class FolderApiControllerTest extends ControllerTestUtility { public function testCreateAlreadyExists() { $msg = 'exists'; - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); @@ -190,9 +180,6 @@ class FolderApiControllerTest extends ControllerTestUtility { public function testCreateInvalidFolderName() { $msg = 'exists'; - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); @@ -212,17 +199,15 @@ class FolderApiControllerTest extends ControllerTestUtility { $folderId = 23; $this->folderAPI = new FolderApiController( - $this->api, + $this->appName, $this->getRequest(array('urlParams' => array( 'folderId' => $folderId ))), $this->folderBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->user ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('delete') ->with($this->equalTo($folderId), $this->equalTo($this->user)); @@ -237,17 +222,15 @@ class FolderApiControllerTest extends ControllerTestUtility { $folderId = 23; $this->folderAPI = new FolderApiController( - $this->api, + $this->appName, $this->getRequest(array('urlParams' => array( 'folderId' => $folderId ))), $this->folderBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->user ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('delete') ->will($this->throwException(new BusinessLayerException($this->msg))); @@ -265,7 +248,7 @@ class FolderApiControllerTest extends ControllerTestUtility { $folderName = 'test'; $this->folderAPI = new FolderApiController( - $this->api, + $this->appName, $this->getRequest( array( 'urlParams' => array( @@ -278,12 +261,10 @@ class FolderApiControllerTest extends ControllerTestUtility { ) ), $this->folderBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->user ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('rename') ->with($this->equalTo($folderId), @@ -301,7 +282,7 @@ class FolderApiControllerTest extends ControllerTestUtility { $folderName = 'test'; $this->folderAPI = new FolderApiController( - $this->api, + $this->appName, $this->getRequest( array( 'urlParams' => array( @@ -314,12 +295,10 @@ class FolderApiControllerTest extends ControllerTestUtility { ) ), $this->folderBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->user ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('rename') ->will($this->throwException(new BusinessLayerException($this->msg))); @@ -337,7 +316,7 @@ class FolderApiControllerTest extends ControllerTestUtility { $folderName = 'test'; $this->folderAPI = new FolderApiController( - $this->api, + $this->appName, $this->getRequest( array( 'urlParams' => array( @@ -350,12 +329,10 @@ class FolderApiControllerTest extends ControllerTestUtility { ) ), $this->folderBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->user ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('rename') ->will($this->throwException(new BusinessLayerConflictException($this->msg))); @@ -373,7 +350,7 @@ class FolderApiControllerTest extends ControllerTestUtility { $folderName = ''; $this->folderAPI = new FolderApiController( - $this->api, + $this->appName, $this->getRequest( array( 'urlParams' => array( @@ -386,12 +363,10 @@ class FolderApiControllerTest extends ControllerTestUtility { ) ), $this->folderBusinessLayer, - $this->itemBusinessLayer + $this->itemBusinessLayer, + $this->user ); - $this->api->expects($this->once()) - ->met |