Skip to content

Commit

Permalink
feat: mail provider backend
Browse files Browse the repository at this point in the history
Signed-off-by: SebastianKrupinski <[email protected]>
  • Loading branch information
SebastianKrupinski committed Aug 26, 2024
1 parent 3ef1f9f commit 5053bf3
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 76 deletions.
4 changes: 2 additions & 2 deletions lib/Db/MailAccountMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public function findByUserId(string $userId): array {
*
* @since 4.0.0
*
* @param string $userId system user id
* @param string $address mail address (e.g. [email protected])
* @param string $userId system user id
* @param string $address mail address (e.g. [email protected])
*
* @return MailAccount[]
*
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/AccountService.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public function findById(int $id): Account {
*
* @since 4.0.0
*
* @param string $userId system user id
* @param string $address mail address (e.g. [email protected])
* @param string $userId system user id
* @param string $address mail address (e.g. [email protected])
*
* @return Account[]
*
Expand Down
56 changes: 28 additions & 28 deletions tests/Unit/Provider/Command/MessageSendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@

class MessageSendTest extends TestCase {

/** @var IConfig&MockObject*/
/** @var IConfig&MockObject */
private $config;
/** @var ITimeFactory&MockObject*/
/** @var ITimeFactory&MockObject */
private $time;
/** @var AccountService&MockObject*/
/** @var AccountService&MockObject */
private $accountService;
/** @var OutboxService&MockObject*/
/** @var OutboxService&MockObject */
private $outboxService;
/** @var AttachmentService&MockObject*/
/** @var AttachmentService&MockObject */
private $attachmentService;
/** @var AccountService&MockObject*/
/** @var AccountService&MockObject */
private $commandSend;

protected function setUp(): void {
Expand Down Expand Up @@ -110,12 +110,12 @@ public function testPerformWithAttachment(): void {
$localAttachmentReturned = LocalAttachment::fromParams($localAttachmentReturned);
// define attachment service returns
$this->attachmentService->expects($this->once())->method('addFileFromString')
->with(
'user1',
$this->mailAttachment->getName(),
$this->mailAttachment->getType(),
$this->mailAttachment->getContents()
)->willReturn($localAttachmentReturned);
->with(
'user1',
$this->mailAttachment->getName(),
$this->mailAttachment->getType(),
$this->mailAttachment->getContents()
)->willReturn($localAttachmentReturned);
// construct mail app message objects
$localMessageFresh = $this->localMessageData;
$localMessageFresh['sendAt'] = $this->time->getTime($localMessageFresh);
Expand All @@ -127,14 +127,14 @@ public function testPerformWithAttachment(): void {
$localMessageReturned = LocalMessage::fromParams($localMessageReturned);
// define attachment service returns
$this->outboxService->expects($this->once())->method('saveMessage')
->with(
$this->localAccount,
$localMessageFresh,
[['email' => '[email protected]', 'label' => 'User Two']],
[],
[],
[$localAttachmentReturned->jsonSerialize()]
)->willReturn($localMessageReturned);
->with(
$this->localAccount,
$localMessageFresh,
[['email' => '[email protected]', 'label' => 'User Two']],
[],
[],
[$localAttachmentReturned->jsonSerialize()]
)->willReturn($localMessageReturned);
// construct mail provider message with attachment
$mailMessage = $this->mailMessage;
$mailMessage->setAttachments($this->mailAttachment);
Expand Down Expand Up @@ -162,14 +162,14 @@ public function testPerformWithOutAttachment(): void {
$localMessageReturned = LocalMessage::fromParams($localMessageReturned);
// define attachment service returns
$this->outboxService->expects($this->once())->method('saveMessage')
->with(
$this->localAccount,
$localMessageFresh,
[['email' => '[email protected]', 'label' => 'User Two']],
[],
[],
[]
)->willReturn($localMessageReturned);
->with(
$this->localAccount,
$localMessageFresh,
[['email' => '[email protected]', 'label' => 'User Two']],
[],
[],
[]
)->willReturn($localMessageReturned);
// construct mail provider message
$mailMessage = $this->mailMessage;
// test send message
Expand Down
84 changes: 42 additions & 42 deletions tests/Unit/Provider/MailProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

class MailProviderTest extends TestCase {

/** @var ContainerInterfaceMockObject*/
/** @var ContainerInterfaceMockObject */
private $containerInterface;
/** @var AccountServiceMockObject*/
/** @var AccountServiceMockObject */
private $accountService;

protected function setUp(): void {
Expand Down Expand Up @@ -69,16 +69,16 @@ public function testHasServices(): void {
]));
// define account services find
$this->accountService
->expects($this->any())
->method('findByUserId')
->will(
$this->returnValueMap(
[
['user0', []],
['user1', [100 => $mailAccount]]
]
)
);
->expects($this->any())
->method('findByUserId')
->will(
$this->returnValueMap(
[
['user0', []],
['user1', [100 => $mailAccount]]
]
)
);
// construct mail provider
$mailProvider = new MailProvider($this->containerInterface, $this->accountService);
// test result with no services found
Expand Down Expand Up @@ -114,16 +114,16 @@ public function testListServices(): void {
);
// define account services find
$this->accountService
->expects($this->any())
->method('findByUserId')
->will(
$this->returnValueMap(
[
['user0', []],
['user1', [$mailAccount]]
]
)
);
->expects($this->any())
->method('findByUserId')
->will(
$this->returnValueMap(
[
['user0', []],
['user1', [$mailAccount]]
]
)
);
// construct mail provider
$mailProvider = new MailProvider($this->containerInterface, $this->accountService);
// test result with no services found
Expand Down Expand Up @@ -159,16 +159,16 @@ public function testFindServiceById(): void {
);
// define account services find
$this->accountService
->expects($this->any())
->method('find')
->will(
$this->returnValueMap(
[
['user0', 100, $this->throwException(new ClientException())],
['user1', 100, $mailAccount]
]
)
);
->expects($this->any())
->method('find')
->will(
$this->returnValueMap(
[
['user0', 100, $this->throwException(new ClientException())],
['user1', 100, $mailAccount]
]
)
);
// construct mail provider
$mailProvider = new MailProvider($this->containerInterface, $this->accountService);
// test result with no services found
Expand Down Expand Up @@ -204,16 +204,16 @@ public function testFindServiceByAddress(): void {
);
// define account services find
$this->accountService
->expects($this->any())
->method('findByUserIdAndAddress')
->will(
$this->returnValueMap(
[
['user0', '[email protected]', $this->throwException(new ClientException())],
['user1', '[email protected]', [$mailAccount]]
]
)
);
->expects($this->any())
->method('findByUserIdAndAddress')
->will(
$this->returnValueMap(
[
['user0', '[email protected]', $this->throwException(new ClientException())],
['user1', '[email protected]', [$mailAccount]]
]
)
);
// construct mail provider
$mailProvider = new MailProvider($this->containerInterface, $this->accountService);
// test result with no services found
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Provider/MailServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
use Psr\Container\ContainerInterface;

class MailServiceTest extends TestCase {
/** @var MailService*/
/** @var MailService */
private $mailService;
/** @var Address*/
/** @var Address */
private $primaryAddress;

protected function setUp(): void {
Expand Down

0 comments on commit 5053bf3

Please sign in to comment.