From 42d69a95f3276a2d6089ca68f635c4e2f6aa7a23 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Tue, 21 Oct 2014 16:45:36 +0200 Subject: convert tabs indention to indention with 4 spaces because of mixing of both variants in code and better readability on github and websites because you cant set the indention width there and 8 spaces will be used for a tab --- tests/unit/controller/FolderControllerTest.php | 422 ++++++++++++------------- 1 file changed, 211 insertions(+), 211 deletions(-) (limited to 'tests/unit/controller/FolderControllerTest.php') diff --git a/tests/unit/controller/FolderControllerTest.php b/tests/unit/controller/FolderControllerTest.php index 9ff293b2a..b06c97c79 100644 --- a/tests/unit/controller/FolderControllerTest.php +++ b/tests/unit/controller/FolderControllerTest.php @@ -24,275 +24,275 @@ use \OCA\News\Service\ServiceValidationException; class FolderControllerTest extends \PHPUnit_Framework_TestCase { - private $appName; - private $folderService; - private $itemService; - private $feedService; - private $request; - private $controller; - private $msg; - - - /** - * Gets run before each test - */ - public function setUp(){ - $this->appName = 'news'; - $this->user = 'jack'; - $this->folderService = $this->getMockBuilder( - '\OCA\News\Service\FolderService') - ->disableOriginalConstructor() - ->getMock(); - $this->feedService = $this->getMockBuilder( - '\OCA\News\Service\FeedService') - ->disableOriginalConstructor() - ->getMock(); - $this->itemService = $this->getMockBuilder( - '\OCA\News\Service\ItemService') - ->disableOriginalConstructor() - ->getMock(); - $this->request = $this->getMockBuilder( - '\OCP\IRequest') - ->disableOriginalConstructor() - ->getMock(); - $this->controller = new FolderController($this->appName, $this->request, - $this->folderService, - $this->feedService, - $this->itemService, - $this->user); - $this->msg = 'ron'; - } - - - - public function testIndex(){ - $return = [new Folder(), new Folder()]; - $this->folderService->expects($this->once()) - ->method('findAll') - ->will($this->returnValue($return)); - - $response = $this->controller->index(); - $expected = ['folders' => $return]; - $this->assertEquals($expected, $response); - } - - - public function testOpen(){ - $this->folderService->expects($this->once()) - ->method('open') - ->with($this->equalTo(3), - $this->equalTo(true), $this->equalTo($this->user)); - - $this->controller->open(3, true); - - } + private $appName; + private $folderService; + private $itemService; + private $feedService; + private $request; + private $controller; + private $msg; + + + /** + * Gets run before each test + */ + public function setUp(){ + $this->appName = 'news'; + $this->user = 'jack'; + $this->folderService = $this->getMockBuilder( + '\OCA\News\Service\FolderService') + ->disableOriginalConstructor() + ->getMock(); + $this->feedService = $this->getMockBuilder( + '\OCA\News\Service\FeedService') + ->disableOriginalConstructor() + ->getMock(); + $this->itemService = $this->getMockBuilder( + '\OCA\News\Service\ItemService') + ->disableOriginalConstructor() + ->getMock(); + $this->request = $this->getMockBuilder( + '\OCP\IRequest') + ->disableOriginalConstructor() + ->getMock(); + $this->controller = new FolderController($this->appName, $this->request, + $this->folderService, + $this->feedService, + $this->itemService, + $this->user); + $this->msg = 'ron'; + } + + + + public function testIndex(){ + $return = [new Folder(), new Folder()]; + $this->folderService->expects($this->once()) + ->method('findAll') + ->will($this->returnValue($return)); + + $response = $this->controller->index(); + $expected = ['folders' => $return]; + $this->assertEquals($expected, $response); + } + + + public function testOpen(){ + $this->folderService->expects($this->once()) + ->method('open') + ->with($this->equalTo(3), + $this->equalTo(true), $this->equalTo($this->user)); + + $this->controller->open(3, true); + + } - public function testOpenDoesNotExist(){ - $this->folderService->expects($this->once()) - ->method('open') - ->will($this->throwException(new ServiceNotFoundException($this->msg))); - - $response = $this->controller->open(5, true); + public function testOpenDoesNotExist(){ + $this->folderService->expects($this->once()) + ->method('open') + ->will($this->throwException(new ServiceNotFoundException($this->msg))); + + $response = $this->controller->open(5, true); - $params = json_decode($response->render(), true); + $params = json_decode($response->render(), true); - $this->assertEquals($this->msg, $params['message']); - $this->assertEquals($response->getStatus(), Http::STATUS_NOT_FOUND); - } + $this->assertEquals($this->msg, $params['message']); + $this->assertEquals($response->getStatus(), Http::STATUS_NOT_FOUND); + } - public function testCollapse(){ - $this->folderService->expects($this->once()) - ->method('open') - ->with($this->equalTo(5), - $this->equalTo(false), $this->equalTo($this->user)); + public function testCollapse(){ + $this->folderService->expects($this->once()) + ->method('open') + ->with($this->equalTo(5), + $this->equalTo(false), $this->equalTo($this->user)); - $this->controller->open(5, false); + $this->controller->open(5, false); - } + } - public function testCreate(){ - $result = ['folders' => [new Folder()]]; + public function testCreate(){ + $result = ['folders' => [new Folder()]]; - $this->folderService->expects($this->once()) - ->method('purgeDeleted') - ->with($this->equalTo($this->user), $this->equalTo(false)); - $this->folderService->expects($this->once()) - ->method('create') - ->with($this->equalTo('tech'), - $this->equalTo($this->user)) - ->will($this->returnValue($result['folders'][0])); + $this->folderService->expects($this->once()) + ->method('purgeDeleted') + ->with($this->equalTo($this->user), $this->equalTo(false)); + $this->folderService->expects($this->once()) + ->method('create') + ->with($this->equalTo('tech'), + $this->equalTo($this->user)) + ->will($this->returnValue($result['folders'][0])); - $response = $this->controller->create('tech'); + $response = $this->controller->create('tech'); - $this->assertEquals($result, $response); - } + $this->assertEquals($result, $response); + } - public function testCreateReturnsErrorForInvalidCreate(){ - $msg = 'except'; - $ex = new ServiceValidationException($msg); - $this->folderService->expects($this->once()) - ->method('purgeDeleted') - ->with($this->equalTo($this->user), $this->equalTo(false)); - $this->folderService->expects($this->once()) - ->method('create') - ->will($this->throwException($ex)); + public function testCreateReturnsErrorForInvalidCreate(){ + $msg = 'except'; + $ex = new ServiceValidationException($msg); + $this->folderService->expects($this->once()) + ->method('purgeDeleted') + ->with($this->equalTo($this->user), $this->equalTo(false)); + $this->folderService->expects($this->once()) + ->method('create') + ->will($this->throwException($ex)); - $response = $this->controller->create('tech'); - $params = json_decode($response->render(), true); + $response = $this->controller->create('tech'); + $params = json_decode($response->render(), true); - $this->assertEquals($response->getStatus(), Http::STATUS_UNPROCESSABLE_ENTITY); - $this->assertEquals($msg, $params['message']); - } + $this->assertEquals($response->getStatus(), Http::STATUS_UNPROCESSABLE_ENTITY); + $this->assertEquals($msg, $params['message']); + } - public function testCreateReturnsErrorForDuplicateCreate(){ - $msg = 'except'; - $ex = new ServiceConflictException($msg); - $this->folderService->expects($this->once()) - ->method('purgeDeleted') - ->with($this->equalTo($this->user), $this->equalTo(false)); - $this->folderService->expects($this->once()) - ->method('create') - ->will($this->throwException($ex)); + public function testCreateReturnsErrorForDuplicateCreate(){ + $msg = 'except'; + $ex = new ServiceConflictException($msg); + $this->folderService->expects($this->once()) + ->method('purgeDeleted') + ->with($this->equalTo($this->user), $this->equalTo(false)); + $this->folderService->expects($this->once()) + ->method('create') + ->will($this->throwException($ex)); - $response = $this->controller->create('tech'); - $params = json_decode($response->render(), true); + $response = $this->controller->create('tech'); + $params = json_decode($response->render(), true); - $this->assertEquals($response->getStatus(), Http::STATUS_CONFLICT); - $this->assertEquals($msg, $params['message']); - } + $this->assertEquals($response->getStatus(), Http::STATUS_CONFLICT); + $this->assertEquals($msg, $params['message']); + } - public function testDelete(){ - $this->folderService->expects($this->once()) - ->method('markDeleted') - ->with($this->equalTo(5), - $this->equalTo($this->user)); + public function testDelete(){ + $this->folderService->expects($this->once()) + ->method('markDeleted') + ->with($this->equalTo(5), + $this->equalTo($this->user)); - $this->controller->delete(5); - } + $this->controller->delete(5); + } - public function testDeleteDoesNotExist(){ - $this->folderService->expects($this->once()) - ->method('markDeleted') - ->will($this->throwException(new ServiceNotFoundException($this->msg))); + public function testDeleteDoesNotExist(){ + $this->folderService->expects($this->once()) + ->method('markDeleted') + ->will($this->throwException(new ServiceNotFoundException($this->msg))); - $response = $this->controller->delete(5); + $response = $this->controller->delete(5); - $params = json_decode($response->render(), true); + $params = json_decode($response->render(), true); - $this->assertEquals($this->msg, $params['message']); - $this->assertEquals($response->getStatus(), Http::STATUS_NOT_FOUND); - } + $this->assertEquals($this->msg, $params['message']); + $this->assertEquals($response->getStatus(), Http::STATUS_NOT_FOUND); + } - public function testRename(){ - $result = ['folders' => [new Folder()]]; + public function testRename(){ + $result = ['folders' => [new Folder()]]; - $this->folderService->expects($this->once()) - ->method('rename') - ->with($this->equalTo(4), - $this->equalTo('tech'), - $this->equalTo($this->user)) - ->will($this->returnValue($result['folders'][0])); + $this->folderService->expects($this->once()) + ->method('rename') + ->with($this->equalTo(4), + $this->equalTo('tech'), + $this->equalTo($this->user)) + ->will($this->returnValue($result['folders'][0])); - $response = $this->controller->rename('tech', 4); + $response = $this->controller->rename('tech', 4); - $this->assertEquals($result, $response); - } + $this->assertEquals($result, $response); + } - public function testRenameReturnsErrorForInvalidCreate(){ - $msg = 'except'; - $ex = new ServiceValidationException($msg); - $this->folderService->expects($this->once()) - ->method('rename') - ->will($this->throwException($ex)); + public function testRenameReturnsErrorForInvalidCreate(){ + $msg = 'except'; + $ex = new ServiceValidationException($msg); + $this->folderService->expects($this->once()) + ->method('rename') + ->will($this->throwException($ex)); - $response = $this->controller->rename('tech', 4); - $params = json_decode($response->render(), true); + $response = $this->controller->rename('tech', 4); + $params = json_decode($response->render(), true); - $this->assertEquals($response->getStatus(), Http::STATUS_UNPROCESSABLE_ENTITY); - $this->assertEquals($msg, $params['message']); - } + $this->assertEquals($response->getStatus(), Http::STATUS_UNPROCESSABLE_ENTITY); + $this->assertEquals($msg, $params['message']); + } - public function testRenameDoesNotExist(){ - $msg = 'except'; - $ex = new ServiceNotFoundException($msg); - $this->folderService->expects($this->once()) - ->method('rename') - ->will($this->throwException($ex)); + public function testRenameDoesNotExist(){ + $msg = 'except'; + $ex = new ServiceNotFoundException($msg); + $this->folderService->expects($this->once()) + ->method('rename') + ->will($this->throwException($ex)); - $response = $this->controller->rename('tech', 5); - $params = json_decode($response->render(), true); + $response = $this->controller->rename('tech', 5); + $params = json_decode($response->render(), true); - $this->assertEquals($response->getStatus(), Http::STATUS_NOT_FOUND); - $this->assertEquals($msg, $params['message']); - } + $this->assertEquals($response->getStatus(), Http::STATUS_NOT_FOUND); + $this->assertEquals($msg, $params['message']); + } - public function testRenameReturnsErrorForDuplicateCreate(){ - $msg = 'except'; - $ex = new ServiceConflictException($msg); - $this->folderService->expects($this->once()) - ->method('rename') - ->will($this->throwException($ex)); + public function testRenameReturnsErrorForDuplicateCreate(){ + $msg = 'except'; + $ex = new ServiceConflictException($msg); + $this->folderService->expects($this->once()) + ->method('rename') + ->will($this->throwException($ex)); - $response = $this->controller->rename('tech', 1); - $params = json_decode($response->render(), true); + $response = $this->controller->rename('tech', 1); + $params = json_decode($response->render(), true); - $this->assertEquals($response->getStatus(), Http::STATUS_CONFLICT); - $this->assertEquals($msg, $params['message']); - } + $this->assertEquals($response->getStatus(), Http::STATUS_CONFLICT); + $this->assertEquals($msg, $params['message']); + } - public function testRead(){ - $feed = new Feed(); - $expected = ['feeds' => [$feed]]; + public function testRead(){ + $feed = new Feed(); + $expected = ['feeds' => [$feed]]; - $this->itemService->expects($this->once()) - ->method('readFolder') - ->with($this->equalTo(4), - $this->equalTo(5), - $this->equalTo($this->user)); - $this->feedService->expects($this->once()) - ->method('findAll') - ->with($this->equalTo($this->user)) - ->will($this->returnValue([$feed])); + $this->itemService->expects($this->once()) + ->method('readFolder') + ->with($this->equalTo(4), + $this->equalTo(5), + $this->equalTo($this->user)); + $this->feedService->expects($this->once()) + ->method('findAll') + ->with($this->equalTo($this->user)) + ->will($this->returnValue([$feed])); - $response = $this->controller->read(4, 5); - $this->assertEquals($expected, $response); - } + $response = $this->controller->read(4, 5); + $this->assertEquals($expected, $response); + } - public function testRestore(){ - $this->folderService->expects($this->once()) - ->method('unmarkDeleted') - ->with($this->equalTo(5), - $this->equalTo($this->user)); + public function testRestore(){ + $this->folderService->expects($this->once()) + ->method('unmarkDeleted') + ->with($this->equalTo(5), + $this->equalTo($this->user)); - $this->controller->restore(5); - } + $this->controller->restore(5); + } - public function testRestoreDoesNotExist(){ - $this->folderService->expects($this->once()) - ->method('unmarkDeleted') - ->will($this->throwException(new ServiceNotFoundException($this->msg))); + public function testRestoreDoesNotExist(){ + $this->folderService->expects($this->once()) + ->method('unmarkDeleted') + ->will($this->throwException(new ServiceNotFoundException($this->msg))); - $response = $this->controller->restore(5); + $response = $this->controller->restore(5); - $params = json_decode($response->render(), true); + $params = json_decode($response->render(), true); - $this->assertEquals($response->getStatus(), Http::STATUS_NOT_FOUND); - $this->assertEquals($this->msg, $params['message']); - } + $this->assertEquals($response->getStatus(), Http::STATUS_NOT_FOUND); + $this->assertEquals($this->msg, $params['message']); + } } \ No newline at end of file -- cgit v1.2.3