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
path: root/tests
diff options
context:
space:
mode:
authorAnna Larch <anna@nextcloud.com>2021-02-18 16:41:33 +0300
committerAnna Larch <anna@nextcloud.com>2021-02-19 11:41:41 +0300
commitebe98b47f7d8b89fea6356c661b54eb0548af605 (patch)
treec6e6cd259abff58fe11215905e1c68e8dea464a8 /tests
parent324ddd3e0b4cce10da8f31172b91349170d214e9 (diff)
Add delete command to OCC
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/Command/DeleteAccountTest.php68
-rw-r--r--tests/Unit/Service/AccountServiceTest.php29
2 files changed, 97 insertions, 0 deletions
diff --git a/tests/Unit/Command/DeleteAccountTest.php b/tests/Unit/Command/DeleteAccountTest.php
new file mode 100644
index 000000000..4bbc3c951
--- /dev/null
+++ b/tests/Unit/Command/DeleteAccountTest.php
@@ -0,0 +1,68 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @author Anna Larch <anna.larch@nextcloud.com>
+ *
+ * Mail
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Mail\Tests\Unit\Command;
+
+use ChristophWurst\Nextcloud\Testing\TestCase;
+use OCA\Mail\Command\DeleteAccount;
+use OCA\Mail\Service\AccountService;
+use Psr\Log\LoggerInterface;
+
+class DeleteAccountTest extends TestCase {
+ private $accountService;
+ private $logger;
+ private $command;
+ private $args = [
+ 'account-id',
+ ];
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->accountService = $this->getMockBuilder(AccountService::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->logger = $this->getMockBuilder(LoggerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->command = new DeleteAccount($this->accountService, $this->logger);
+ }
+
+ public function testName() {
+ $this->assertSame('mail:account:delete', $this->command->getName());
+ }
+
+ public function testDescription() {
+ $this->assertSame('Delete an IMAP account', $this->command->getDescription());
+ }
+
+ public function testArguments() {
+ $actual = $this->command->getDefinition()->getArguments();
+
+ foreach ($actual as $actArg) {
+ $this->assertTrue($actArg->isRequired());
+ $this->assertTrue(in_array($actArg->getName(), $this->args));
+ }
+ }
+}
diff --git a/tests/Unit/Service/AccountServiceTest.php b/tests/Unit/Service/AccountServiceTest.php
index 9184e4b69..b6c3133ee 100644
--- a/tests/Unit/Service/AccountServiceTest.php
+++ b/tests/Unit/Service/AccountServiceTest.php
@@ -106,6 +106,21 @@ class AccountServiceTest extends TestCase {
$this->assertEquals($expected, $actual);
}
+ public function testFindById() {
+ $accountId = 123;
+
+ $this->mapper->expects($this->once())
+ ->method('findById')
+ ->with($accountId)
+ ->will($this->returnValue($this->account1));
+
+ $expected = new Account($this->account1);
+ $actual = $this->accountService->findById($accountId);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+
public function testDelete() {
$accountId = 33;
@@ -120,6 +135,20 @@ class AccountServiceTest extends TestCase {
$this->accountService->delete($this->user, $accountId);
}
+ public function testDeleteByAccountId() {
+ $accountId = 33;
+
+ $this->mapper->expects($this->once())
+ ->method('findById')
+ ->with($accountId)
+ ->will($this->returnValue($this->account1));
+ $this->mapper->expects($this->once())
+ ->method('delete')
+ ->with($this->account1);
+
+ $this->accountService->deleteByAccountId($accountId);
+ }
+
public function testSave() {
$account = new MailAccount();