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:
authorDaniel Kesselberg <mail@danielkesselberg.de>2021-04-06 17:55:22 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-04-19 14:10:27 +0300
commit28ea91bf6b15e098c158bd68ff4435334db00849 (patch)
tree5dea2595a40d5ee9bb56ad96978640be3c57d1eb /tests
parente39a7f9654879f6b2be2d2983ef48aab5832fca8 (diff)
Allow signatures for aliases
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de> Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r--tests/Integration/Db/AliasMapperTest.php7
-rw-r--r--tests/Unit/Controller/AliasesControllerTest.php45
-rw-r--r--tests/Unit/Service/AliasesServiceTest.php24
3 files changed, 74 insertions, 2 deletions
diff --git a/tests/Integration/Db/AliasMapperTest.php b/tests/Integration/Db/AliasMapperTest.php
index ed79edf1e..96be70a0d 100644
--- a/tests/Integration/Db/AliasMapperTest.php
+++ b/tests/Integration/Db/AliasMapperTest.php
@@ -77,6 +77,7 @@ class AliasMapperTest extends TestCase {
$this->alias->setAccountId($a->getId());
$this->alias->setAlias('alias@marvel.com');
$this->alias->setName('alias');
+ $this->alias->setSignature('Kind regards<br>Alias');
/** @var Alias $b */
$b = $this->mapper->insert($this->alias);
@@ -87,12 +88,14 @@ class AliasMapperTest extends TestCase {
'accountId' => $this->alias->getAccountId(),
'name' => $this->alias->getName(),
'alias' => $this->alias->getAlias(),
- 'id' => $this->alias->getId()
+ 'id' => $this->alias->getId(),
+ 'signature' => $this->alias->getSignature(),
], [
'accountId' => $result->getAccountId(),
'name' => $result->getName(),
'alias' => $result->getAlias(),
- 'id' => $result->getId()
+ 'id' => $result->getId(),
+ 'signature' => $this->alias->getSignature(),
]
);
}
diff --git a/tests/Unit/Controller/AliasesControllerTest.php b/tests/Unit/Controller/AliasesControllerTest.php
index 9b63b6cf4..fa44ea4f0 100644
--- a/tests/Unit/Controller/AliasesControllerTest.php
+++ b/tests/Unit/Controller/AliasesControllerTest.php
@@ -159,4 +159,49 @@ class AliasesControllerTest extends TestCase {
$entity->getName()
);
}
+
+ public function testUpdateSignature(): void {
+ $alias = new Alias();
+ $alias->setId(102);
+ $alias->setAccountId(200);
+ $alias->setName('Jane Doe');
+ $alias->setAlias('jane@doe.com');
+ $alias->setSignature('my old signature');
+
+ $this->aliasMapper->expects($this->once())
+ ->method('find')
+ ->willReturn($alias);
+ $this->aliasMapper->expects($this->once())
+ ->method('update');
+
+ $expectedResponse = new JSONResponse(
+ [],
+ Http::STATUS_OK
+ );
+ $response = $this->controller->updateSignature(
+ $alias->getId(),
+ 'my new signature'
+ );
+
+ $this->assertEquals($expectedResponse, $response);
+ }
+
+ public function testUpdateSignatureInvalidAliasId(): void {
+ $this->expectException(DoesNotExistException::class);
+
+ $entity = new Alias();
+ $entity->setId(999999);
+ $entity->setAccountId(200);
+ $entity->setAlias('jane@doe.com');
+ $entity->setName('Jane Doe');
+
+ $this->aliasMapper->expects($this->once())
+ ->method('find')
+ ->willThrowException(new DoesNotExistException('Alias does not exist'));
+
+ $this->controller->updateSignature(
+ $entity->getId(),
+ 'my new signature'
+ );
+ }
}
diff --git a/tests/Unit/Service/AliasesServiceTest.php b/tests/Unit/Service/AliasesServiceTest.php
index d8345fabd..ddbe4ed04 100644
--- a/tests/Unit/Service/AliasesServiceTest.php
+++ b/tests/Unit/Service/AliasesServiceTest.php
@@ -147,4 +147,28 @@ class AliasesServiceTest extends TestCase {
$this->service->delete($aliasId, $this->user);
}
+
+ public function testUpdateSignature(): void {
+ $aliasId = 400;
+ $this->aliasMapper->expects($this->once())
+ ->method('find')
+ ->with($aliasId, $this->user)
+ ->willReturn($this->alias);
+ $this->aliasMapper->expects($this->once())
+ ->method('update');
+
+ $this->service->updateSignature($this->user, $aliasId, 'Kind regards<br>Herbert');
+ }
+
+ public function testUpateSignatureInvalidAliasId(): void {
+ $this->expectException(DoesNotExistException::class);
+
+ $this->aliasMapper->expects($this->once())
+ ->method('find')
+ ->willThrowException(new DoesNotExistException('Alias does not exist'));
+ $this->aliasMapper->expects($this->never())
+ ->method('update');
+
+ $this->service->updateSignature($this->user, '999999', 'Kind regards<br>Herbert');
+ }
}