Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Wurst <ChristophWurst@users.noreply.github.com>2017-09-12 16:25:08 +0300
committerGitHub <noreply@github.com>2017-09-12 16:25:08 +0300
commiteb4b5588474978745501894e2995ba6da9b75634 (patch)
tree16799bfe5335d345142547c5ec61dc7f75a38351
parent29bc371e5bac036fb009e6707cd697afd56cd8b3 (diff)
parent56865a6a0db2691d35722ee6fbc53752cc9df961 (diff)
Merge pull request #511 from nextcloud/refactoring/cleanup-unused-controller-methodsnightly-20170913
Cleanup unused controller methods
-rw-r--r--lib/Account.php1
-rw-r--r--lib/Controller/FoldersController.php44
-rw-r--r--tests/Controller/FoldersControllerTest.php96
3 files changed, 5 insertions, 136 deletions
diff --git a/lib/Account.php b/lib/Account.php
index 666fa68e5..4bd35fdfb 100644
--- a/lib/Account.php
+++ b/lib/Account.php
@@ -166,6 +166,7 @@ class Account implements IAccount {
/**
* @param string $mailBox
+ * @param array $opts
* @return Mailbox
*/
public function createMailbox($mailBox, $opts = []) {
diff --git a/lib/Controller/FoldersController.php b/lib/Controller/FoldersController.php
index e5dd439d2..c85b8ee84 100644
--- a/lib/Controller/FoldersController.php
+++ b/lib/Controller/FoldersController.php
@@ -118,47 +118,11 @@ class FoldersController extends Controller {
/**
* @NoAdminRequired
- * @param int $accountId
- * @param string $folderId
- * @return JSONResponse
- */
- public function destroy($accountId, $folderId) {
- try {
- $account = $this->accountService->find($this->currentUserId, $accountId);
- $imap = $account->getImapConnection();
- $imap->deleteMailbox($folderId);
-
- return new JSONResponse();
- } catch (DoesNotExistException $e) {
- return new JSONResponse(null, 404);
- }
- }
-
- /**
- * @NoAdminRequired
- * @param int $accountId
- * @param string $mailbox
*/
- public function create($accountId, $mailbox) {
- try {
- $account = $this->accountService->find($this->currentUserId, $accountId);
- $imap = $account->getImapConnection();
-
- // TODO: read http://tools.ietf.org/html/rfc6154
- $imap->createMailbox($mailbox);
-
- return new JSONResponse([
- 'data' => [
- 'id' => $mailbox
- ]
- ], Http::STATUS_CREATED);
- } catch (Horde_Imap_Client_Exception $e) {
- $response = new JSONResponse();
- $response->setStatus(Http::STATUS_INTERNAL_SERVER_ERROR);
- return $response;
- } catch (DoesNotExistException $e) {
- return new JSONResponse();
- }
+ public function create() {
+ $response = new JSONResponse();
+ $response->setStatus(Http::STATUS_NOT_IMPLEMENTED);
+ return $response;
}
}
diff --git a/tests/Controller/FoldersControllerTest.php b/tests/Controller/FoldersControllerTest.php
index 47710d7b7..9d7f7ae43 100644
--- a/tests/Controller/FoldersControllerTest.php
+++ b/tests/Controller/FoldersControllerTest.php
@@ -107,100 +107,4 @@ class FoldersControllerTest extends TestCase {
$this->assertEquals(Http::STATUS_NOT_IMPLEMENTED, $result->getStatus());
}
- public function testDestroy() {
- $accountId = 28;
- $folderId = 'my folder';
- $account = $this->createMock(Account::class);
- $this->accountService->expects($this->once())
- ->method('find')
- ->with($this->userId, $accountId)
- ->will($this->returnValue($account));
- $imapConnection = $this->createMock(Horde_Imap_Client_Socket::class);
- $account->expects($this->once())
- ->method('getImapConnection')
- ->will($this->returnValue($imapConnection));
- $imapConnection->expects($this->once())
- ->method('deleteMailbox')
- ->with($folderId);
-
- $this->controller->destroy($accountId, $folderId);
- }
-
- public function testDestroyAccountNotFound() {
- $accountId = 28;
- $folderId = 'my folder';
- $this->accountService->expects($this->once())
- ->method('find')
- ->with($this->userId, $accountId)
- ->will($this->throwException(new DoesNotExistException('folder not found')));
-
- $response = $this->controller->destroy($accountId, $folderId);
- $expected = new JSONResponse(null, 404);
-
- $this->assertEquals($expected, $response);
- }
-
- public function testDestroyFolderNotFound() {
- // TODO: write test
- }
-
- public function testCreate() {
- $accountId = 13;
- $folderId = 'new folder';
- $account = $this->createMock(Account::class);
- $this->accountService->expects($this->once())
- ->method('find')
- ->with($this->userId, $accountId)
- ->will($this->returnValue($account));
- $imapConnection = $this->createMock(Horde_Imap_Client_Socket::class);
- $account->expects($this->once())
- ->method('getImapConnection')
- ->will($this->returnValue($imapConnection));
- $imapConnection->expects($this->once())
- ->method('createMailbox')
- ->with($folderId);
-
- $response = $this->controller->create($accountId, $folderId);
-
- $expected = new JSONResponse([
- 'data' => [
- 'id' => $folderId
- ]
- ], Http::STATUS_CREATED);
-
- $this->assertEquals($expected, $response);
- }
-
- public function testCreateWithError() {
- $accountId = 13;
- $folderId = 'new folder';
- $account = $this->createMock(Account::class);
- $this->accountService->expects($this->once())
- ->method('find')
- ->with($this->userId, $accountId)
- ->will($this->returnValue($account));
- $imapConnection = $this->createMock(Horde_Imap_Client_Socket::class);
- $account->expects($this->once())
- ->method('getImapConnection')
- ->will($this->returnValue($imapConnection));
- $imapConnection->expects($this->once())
- ->method('createMailbox')
- ->with($folderId)
- ->will($this->throwException(new Horde_Imap_Client_Exception()));
-
- $response = $this->controller->create($accountId, $folderId);
-
- $expected = new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
-
- $this->assertEquals($expected, $response);
- }
-
- public function testCreateSubFolder() {
- // TODO: write test
- }
-
- public function testDetectChanges() {
- // TODO: write test
- }
-
}