diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-15 03:41:49 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-15 03:41:49 +0200 |
commit | 407fbebc2da14520942e0a6a9220a5a3cfc4a7ad (patch) | |
tree | e313ddad41398382f82cd27b40f46e0b7394c393 /tests/unit/controller | |
parent | 7d33bab5abd81871e4efcf995f8a715d45b9d590 (diff) |
rename businesslayer to service
Diffstat (limited to 'tests/unit/controller')
-rw-r--r-- | tests/unit/controller/ExportControllerTest.php | 27 | ||||
-rw-r--r-- | tests/unit/controller/FeedApiControllerTest.php | 86 | ||||
-rw-r--r-- | tests/unit/controller/FeedControllerTest.php | 106 | ||||
-rw-r--r-- | tests/unit/controller/FolderApiControllerTest.php | 62 | ||||
-rw-r--r-- | tests/unit/controller/FolderControllerTest.php | 87 | ||||
-rw-r--r-- | tests/unit/controller/ItemApiControllerTest.php | 70 | ||||
-rw-r--r-- | tests/unit/controller/ItemControllerTest.php | 72 |
7 files changed, 255 insertions, 255 deletions
diff --git a/tests/unit/controller/ExportControllerTest.php b/tests/unit/controller/ExportControllerTest.php index fd3aece97..ded145f2b 100644 --- a/tests/unit/controller/ExportControllerTest.php +++ b/tests/unit/controller/ExportControllerTest.php @@ -29,9 +29,9 @@ class ExportControllerTest extends \PHPUnit_Framework_TestCase { private $request; private $controller; private $user; - private $feedBusinessLayer; - private $folderBusinessLayer; - private $itemBusinessLayer; + private $feedService; + private $folderService; + private $itemService; private $opmlExporter; /** @@ -40,13 +40,16 @@ class ExportControllerTest extends \PHPUnit_Framework_TestCase { public function setUp(){ $this->appName = 'news'; $this->user = 'john'; - $this->itemBusinessLayer = $this->getMockBuilder('\OCA\News\BusinessLayer\ItemBusinessLayer') + $this->itemService = $this->getMockBuilder( + '\OCA\News\Service\ItemService') ->disableOriginalConstructor() ->getMock(); - $this->feedBusinessLayer = $this->getMockBuilder('\OCA\News\BusinessLayer\FeedBusinessLayer') + $this->feedService = $this->getMockBuilder( + '\OCA\News\Service\FeedService') ->disableOriginalConstructor() ->getMock(); - $this->folderBusinessLayer = $this->getMockBuilder('\OCA\News\BusinessLayer\FolderBusinessLayer') + $this->folderService = $this->getMockBuilder( + '\OCA\News\Service\FolderService') ->disableOriginalConstructor() ->getMock(); $this->request = $this->getMockBuilder('\OCP\IRequest') @@ -54,8 +57,8 @@ class ExportControllerTest extends \PHPUnit_Framework_TestCase { ->getMock(); $this->opmlExporter = new OPMLExporter(); $this->controller = new ExportController($this->appName, $this->request, - $this->feedBusinessLayer, $this->folderBusinessLayer, - $this->itemBusinessLayer, $this->opmlExporter, $this->user); + $this->folderService, $this->feedService, + $this->itemService, $this->opmlExporter, $this->user); } @@ -69,11 +72,11 @@ class ExportControllerTest extends \PHPUnit_Framework_TestCase { " <body/>\n" . "</opml>\n"; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('findAll') ->with($this->equalTo($this->user)) ->will($this->returnValue([])); - $this->folderBusinessLayer->expects($this->once()) + $this->folderService->expects($this->once()) ->method('findAll') ->with($this->equalTo($this->user)) ->will($this->returnValue([])); @@ -100,11 +103,11 @@ class ExportControllerTest extends \PHPUnit_Framework_TestCase { $articles = [$item1, $item2]; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('findAll') ->with($this->equalTo($this->user)) ->will($this->returnValue($feeds)); - $this->itemBusinessLayer->expects($this->once()) + $this->itemService->expects($this->once()) ->method('getUnreadOrStarred') ->with($this->equalTo($this->user)) ->will($this->returnValue($articles)); diff --git a/tests/unit/controller/FeedApiControllerTest.php b/tests/unit/controller/FeedApiControllerTest.php index 6e18d89da..b5a167588 100644 --- a/tests/unit/controller/FeedApiControllerTest.php +++ b/tests/unit/controller/FeedApiControllerTest.php @@ -15,8 +15,8 @@ namespace OCA\News\Controller; use \OCP\AppFramework\Http; -use \OCA\News\BusinessLayer\BusinessLayerException; -use \OCA\News\BusinessLayer\BusinessLayerConflictException; +use \OCA\News\Service\ServiceNotFoundException; +use \OCA\News\Service\ServiceConflictException; use \OCA\News\Db\Folder; use \OCA\News\Db\Feed; use \OCA\News\Db\Item; @@ -26,9 +26,8 @@ require_once(__DIR__ . "/../../classloader.php"); class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { - private $folderBusinessLayer; - private $feedBusinessLayer; - private $itemBusinessLayer; + private $feedService; + private $itemService; private $feedAPI; private $appName; private $user; @@ -49,24 +48,19 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { '\OCP\IRequest') ->disableOriginalConstructor() ->getMock(); - $this->folderBusinessLayer = $this->getMockBuilder( - '\OCA\News\BusinessLayer\FolderBusinessLayer') + $this->feedService = $this->getMockBuilder( + '\OCA\News\Service\FeedService') ->disableOriginalConstructor() ->getMock(); - $this->feedBusinessLayer = $this->getMockBuilder( - '\OCA\News\BusinessLayer\FeedBusinessLayer') - ->disableOriginalConstructor() - ->getMock(); - $this->itemBusinessLayer = $this->getMockBuilder( - '\OCA\News\BusinessLayer\ItemBusinessLayer') + $this->itemService = $this->getMockBuilder( + '\OCA\News\Service\ItemService') ->disableOriginalConstructor() ->getMock(); $this->feedAPI = new FeedApiController( $this->appName, $this->request, - $this->folderBusinessLayer, - $this->feedBusinessLayer, - $this->itemBusinessLayer, + $this->feedService, + $this->itemService, $this->logger, $this->user, $this->loggerParams @@ -80,15 +74,15 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { $starredCount = 3; $newestItemId = 2; - $this->itemBusinessLayer->expects($this->once()) + $this->itemService->expects($this->once()) ->method('starredCount') ->with($this->equalTo($this->user)) ->will($this->returnValue($starredCount)); - $this->itemBusinessLayer->expects($this->once()) + $this->itemService->expects($this->once()) ->method('getNewestItemId') ->with($this->equalTo($this->user)) ->will($this->returnValue($newestItemId)); - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('findAll') ->with($this->equalTo($this->user)) ->will($this->returnValue($feeds)); @@ -107,15 +101,15 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { $feeds = [new Feed()]; $starredCount = 3; - $this->itemBusinessLayer->expects($this->once()) + $this->itemService->expects($this->once()) ->method('starredCount') ->with($this->equalTo($this->user)) ->will($this->returnValue($starredCount)); - $this->itemBusinessLayer->expects($this->once()) + $this->itemService->expects($this->once()) ->method('getNewestItemId') ->with($this->equalTo($this->user)) - ->will($this->throwException(new BusinessLayerException(''))); - $this->feedBusinessLayer->expects($this->once()) + ->will($this->throwException(new ServiceNotFoundException(''))); + $this->feedService->expects($this->once()) ->method('findAll') ->with($this->equalTo($this->user)) ->will($this->returnValue($feeds)); @@ -130,7 +124,7 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { public function testDelete() { - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('delete') ->with( $this->equalTo(2), @@ -141,9 +135,9 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { public function testDeleteDoesNotExist() { - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('delete') - ->will($this->throwException(new BusinessLayerException($this->msg))); + ->will($this->throwException(new ServiceNotFoundException($this->msg))); $response = $this->feedAPI->delete(2); @@ -156,17 +150,17 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { public function testCreate() { $feeds = [new Feed()]; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('create') ->with( $this->equalTo('url'), $this->equalTo(3), $this->equalTo($this->user)) ->will($this->returnValue($feeds[0])); - $this->itemBusinessLayer->expects($this->once()) + $this->itemService->expects($this->once()) ->method('getNewestItemId') ->will($this->returnValue(3)); @@ -182,19 +176,19 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { public function testCreateNoItems() { $feeds = [new Feed()]; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('create') ->with( $this->equalTo('ho'), $this->equalTo(3), $this->equalTo($this->user)) ->will($this->returnValue($feeds[0])); - $this->itemBusinessLayer->expects($this->once()) + $this->itemService->expects($this->once()) ->method('getNewestItemId') - ->will($this->throwException(new BusinessLayerException(''))); + ->will($this->throwException(new ServiceNotFoundException(''))); $response = $this->feedAPI->create('ho', 3); @@ -206,12 +200,12 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { public function testCreateExists() { - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('create') - ->will($this->throwException(new BusinessLayerConflictException($this->msg))); + ->will($this->throwException(new ServiceConflictException($this->msg))); $response = $this->feedAPI->create('ho', 3); @@ -222,9 +216,9 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { public function testCreateError() { - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('create') - ->will($this->throwException(new BusinessLayerException($this->msg))); + ->will($this->throwException(new ServiceNotFoundException($this->msg))); $response = $this->feedAPI->create('ho', 3); @@ -235,7 +229,7 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { public function testRead() { - $this->itemBusinessLayer->expects($this->once()) + $this->itemService->expects($this->once()) ->method('readFeed') ->with( $this->equalTo(3), @@ -247,7 +241,7 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { public function testMove() { - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('move') ->with( $this->equalTo(3), @@ -259,9 +253,9 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { public function testMoveDoesNotExist() { - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('move') - ->will($this->throwException(new BusinessLayerException($this->msg))); + ->will($this->throwException(new ServiceNotFoundException($this->msg))); $response = $this->feedAPI->move(3, 4); @@ -275,7 +269,7 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { $feedId = 3; $feedTitle = 'test'; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('rename') ->with( $this->equalTo($feedId), @@ -292,7 +286,7 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { $feed->setId(1); $feed->setUserId('john'); $feeds = [$feed]; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('findAllFromAllUsers') ->will($this->returnValue($feeds)); $response = json_encode($this->feedAPI->fromAllUsers()); @@ -304,7 +298,7 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { $feedId = 3; $userId = 'hi'; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('update') ->with($this->equalTo($feedId), $this->equalTo($userId)); @@ -315,7 +309,7 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { public function testUpdateError() { $feedId = 3; $userId = 'hi'; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('update') ->will($this->throwException(new \Exception($this->msg))); $this->logger->expects($this->once()) diff --git a/tests/unit/controller/FeedControllerTest.php b/tests/unit/controller/FeedControllerTest.php index b59175468..a2fc8bc22 100644 --- a/tests/unit/controller/FeedControllerTest.php +++ b/tests/unit/controller/FeedControllerTest.php @@ -17,8 +17,8 @@ use \OCP\AppFramework\Http; use \OCA\News\Db\Feed; use \OCA\News\Db\FeedType; -use \OCA\News\BusinessLayer\BusinessLayerException; -use \OCA\News\BusinessLayer\BusinessLayerConflictException; +use \OCA\News\Service\ServiceNotFoundException; +use \OCA\News\Service\ServiceConflictException; require_once(__DIR__ . "/../../classloader.php"); @@ -26,11 +26,11 @@ require_once(__DIR__ . "/../../classloader.php"); class FeedControllerTest extends \PHPUnit_Framework_TestCase { private $appName; - private $feedBusinessLayer; + private $feedService; private $request; private $controller; - private $folderBusinessLayer; - private $itemBusinessLayer; + private $folderService; + private $itemService; private $settings; private $exampleResult; @@ -45,13 +45,13 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { '\OCP\IConfig') ->disableOriginalConstructor() ->getMock(); - $this->itemBusinessLayer = $this->getMockBuilder('\OCA\News\BusinessLayer\ItemBusinessLayer') + $this->itemService = $this->getMockBuilder('\OCA\News\Service\ItemService') ->disableOriginalConstructor() ->getMock(); - $this->feedBusinessLayer = $this->getMockBuilder('\OCA\News\BusinessLayer\FeedBusinessLayer') + $this->feedService = $this->getMockBuilder('\OCA\News\Service\FeedService') ->disableOriginalConstructor() ->getMock(); - $this->folderBusinessLayer = $this->getMockBuilder('\OCA\News\BusinessLayer\FolderBusinessLayer') + $this->folderService = $this->getMockBuilder('\OCA\News\Service\FolderService') ->disableOriginalConstructor() ->getMock(); $this->request = $this->getMockBuilder( @@ -59,9 +59,9 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { ->disableOriginalConstructor() ->getMock(); $this->controller = new FeedController($this->appName, $this->request, - $this->folderBusinessLayer, - $this->feedBusinessLayer, - $this->itemBusinessLayer, + $this->folderService, + $this->feedService, + $this->itemService, $this->settings, $this->user); $this->exampleResult = [ @@ -80,15 +80,15 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { ], 'starred' => 13 ]; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('findAll') ->with($this->equalTo($this->user)) ->will($this->returnValue($result['feeds'])); - $this->itemBusinessLayer->expects($this->once()) + $this->itemService->expects($this->once()) ->method('getNewestItemId') ->with($this->equalTo($this->user)) - ->will($this->throwException(new BusinessLayerException(''))); - $this->itemBusinessLayer->expects($this->once()) + ->will($this->throwException(new ServiceNotFoundException(''))); + $this->itemService->expects($this->once()) ->method('starredCount') ->with($this->equalTo($this->user)) ->will($this->returnValue($result['starred'])); @@ -107,15 +107,15 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { 'starred' => 13, 'newestItemId' => 5 ]; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('findAll') ->with($this->equalTo($this->user)) ->will($this->returnValue($result['feeds'])); - $this->itemBusinessLayer->expects($this->once()) + $this->itemService->expects($this->once()) ->method('getNewestItemId') ->with($this->equalTo($this->user)) ->will($this->returnValue($result['newestItemId'])); - $this->itemBusinessLayer->expects($this->once()) + $this->itemService->expects($this->once()) ->method('starredCount') ->with($this->equalTo($this->user)) ->will($this->returnValue($result['starred'])); @@ -164,10 +164,10 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testActiveFeedDoesNotExist(){ $id = 3; $type = FeedType::FEED; - $ex = new BusinessLayerException('hiu'); + $ex = new ServiceNotFoundException('hiu'); $result = $this->exampleResult; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('find') ->with($this->equalTo($id), $this->equalTo($this->user)) ->will($this->throwException($ex)); @@ -183,10 +183,10 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testActiveFolderDoesNotExist(){ $id = 3; $type = FeedType::FOLDER; - $ex = new BusinessLayerException('hiu'); + $ex = new ServiceNotFoundException('hiu'); $result = $this->exampleResult; - $this->folderBusinessLayer->expects($this->once()) + $this->folderService->expects($this->once()) ->method('find') ->with($this->equalTo($id), $this->equalTo($this->user)) ->will($this->throwException($ex)); @@ -219,13 +219,13 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { 'newestItemId' => 3 ]; - $this->itemBusinessLayer->expects($this->once()) + $this->itemService->expects($this->once()) ->method('getNewestItemId') ->will($this->returnValue($result['newestItemId'])); - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('create') ->with($this->equalTo('hi'), $this->equalTo(4), @@ -241,15 +241,15 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testCreateNoItems(){ $result = ['feeds' => [new Feed()]]; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); - $this->itemBusinessLayer->expects($this->once()) + $this->itemService->expects($this->once()) ->method('getNewestItemId') - ->will($this->throwException(new BusinessLayerException(''))); + ->will($this->throwException(new ServiceNotFoundException(''))); - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('create') ->with($this->equalTo('hi'), $this->equalTo(4), @@ -264,11 +264,11 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testCreateReturnsErrorForInvalidCreate(){ $msg = 'except'; - $ex = new BusinessLayerException($msg); - $this->feedBusinessLayer->expects($this->once()) + $ex = new ServiceNotFoundException($msg); + $this->feedService->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('create') ->will($this->throwException($ex)); @@ -282,11 +282,11 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testCreateReturnsErrorForDuplicateCreate(){ $msg = 'except'; - $ex = new BusinessLayerConflictException($msg); - $this->feedBusinessLayer->expects($this->once()) + $ex = new ServiceConflictException($msg); + $this->feedService->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('create') ->will($this->throwException($ex)); @@ -299,7 +299,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testDelete(){ - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('markDeleted') ->with($this->equalTo(4)); @@ -310,9 +310,9 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testDeleteDoesNotExist(){ $msg = 'hehe'; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('markDeleted') - ->will($this->throwException(new BusinessLayerException($msg))); + ->will($this->throwException(new ServiceNotFoundException($msg))); $response = $this->controller->delete(4); $params = json_decode($response->render(), true); @@ -335,7 +335,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { ] ]; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('update') ->with($this->equalTo(4), $this->equalTo($this->user)) ->will($this->returnValue($feed)); @@ -347,10 +347,10 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testUpdateReturnsJSONError(){ - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('update') ->with($this->equalTo(4), $this->equalTo($this->user)) - ->will($this->throwException(new BusinessLayerException('NO!'))); + ->will($this->throwException(new ServiceNotFoundException('NO!'))); $response = $this->controller->update(4); $render = $response->render(); @@ -361,7 +361,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testMove(){ - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('move') ->with($this->equalTo(4), $this->equalTo(3), @@ -375,9 +375,9 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testMoveDoesNotExist(){ $msg = 'john'; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('move') - ->will($this->throwException(new BusinessLayerException($msg))); + ->will($this->throwException(new ServiceNotFoundException($msg))); $response = $this->controller->move(4, 3); $params = json_decode($response->render(), true); @@ -388,7 +388,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testRename(){ - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('rename') ->with($this->equalTo(4), $this->equalTo('title'), @@ -401,12 +401,12 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testRenameDoesNotExist(){ $msg = 'hi'; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('rename') ->with($this->equalTo(4), $this->equalTo('title'), $this->equalTo($this->user)) - ->will($this->throwException(new BusinessLayerException($msg))); + ->will($this->throwException(new ServiceNotFoundException($msg))); $response = $this->controller->rename(4, 'title'); @@ -424,7 +424,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { 'feeds' => [$feed] ]; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('importArticles') ->with($this->equalTo('json'), $this->equalTo($this->user)) @@ -437,7 +437,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testImportCreatesNoAdditionalFeed() { - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('importArticles') ->with($this->equalTo('json'), $this->equalTo($this->user)) @@ -459,7 +459,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { ] ]; - $this->itemBusinessLayer->expects($this->once()) + $this->itemService->expects($this->once()) ->method('readFeed') ->with($this->equalTo(4), $this->equalTo(5), $this->user); @@ -469,7 +469,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testRestore() { - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('unmarkDeleted') ->with($this->equalTo(4)); @@ -480,9 +480,9 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testRestoreDoesNotExist(){ $msg = 'hehe'; - $this->feedBusinessLayer->expects($this->once()) + $this->feedService->expects($this->once()) ->method('unmarkDeleted') - ->will($this->throwException(new BusinessLayerException($msg))); + ->will($this->throwException(new ServiceNotFoundException($msg))); $response = $this->controller->restore(4); $params = json_decode($response->render(), true); diff --git a/tests/unit/controller/FolderApiControllerTest.php b/tests/unit/controller/FolderApiControllerTest.php index d3171e397..8ddb9d14f 100644 --- a/tests/unit/controller/FolderApiControllerTest.php +++ b/tests/unit/controller/FolderApiControllerTest.php @@ -16,9 +16,9 @@ namespace OCA\News\Controller; use \OCP\AppFramework\Http; use \OCP\AppFramework\Http\JSONResponse; -use \OCA\News\BusinessLayer\BusinessLayerException; -use \OCA\News\BusinessLayer\BusinessLayerConflictException; -use \OCA\News\BusinessLayer\BusinessLayerValidationException; +use \OCA\News\Service\ServiceNotFoundException; +use \OCA\News\Service\ServiceConflictException; +use \OCA\News\Service\ServiceValidationException; use \OCA\News\Db\Folder; use \OCA\News\Db\Feed; @@ -29,8 +29,8 @@ require_once(__DIR__ . "/../../classloader.php"); class FolderApiControllerTest extends \PHPUnit_Framework_TestCase { - private $folderBusinessLayer; - private $itemBusinessLayer; + private $folderService; + private $itemService; private $folderAPI; private $appName; private $user; @@ -44,19 +44,19 @@ class FolderApiControllerTest extends \PHPUnit_Framework_TestCase { '\OCP\IRequest') ->disableOriginalConstructor() ->getMock(); - $this->folderBusinessLayer = $this->getMockBuilder( - '\OCA\News\BusinessLayer\FolderBusinessLayer') + $this->folderService = $this->getMockBuilder( + '\OCA\News\Service\FolderService') ->disableOriginalConstructor() ->getMock(); - $this->itemBusinessLayer = $this->getMockBuilder( - '\OCA\News\BusinessLayer\ItemBusinessLayer') + $this->itemService = $this->getMockBuilder( + '\OCA\News\Service\ItemService') ->disableOriginalConstructor() ->getMock(); $this->folderAPI = new FolderApiController( $this->appName, $this->request, - $this->folderBusinessLayer, - $this->itemBusinessLayer, + $this->folderService, + $this->itemService, $this->user ); $this->msg = 'test'; @@ -66,7 +66,7 @@ class FolderApiControllerTest extends \PHPUnit_Framework_TestCase { public function testIndex() { $folders = [new Folder()]; - $this->folderBusinessLayer->expects($this->once()) + $this->folderService->expects($this->once()) ->method('findAll') ->with($this->equalTo($this->user)) ->will($this->returnValue($folders)); @@ -83,10 +83,10 @@ class FolderApiControllerTest extends \PHPUnit_Framework_TestCase { $folder->setName($folderName); $folders = [$folder]; - $this->folderBusinessLayer->expects($this->once()) + $this->folderService->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); - $this->folderBusinessLayer->expects($this->once()) + $this->folderService->expects($this->once()) ->method('create') ->with($this->equalTo($folderName), $this->equalTo($this->user)) ->will($this->returnValue( |