-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: SebastianKrupinski <[email protected]>
- Loading branch information
1 parent
6652724
commit 55772d9
Showing
2 changed files
with
14 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,10 @@ class MessageSendTest extends TestCase { | |
private AttachmentService&MockObject $attachmentService; | ||
private MessageSend $commandSend; | ||
private Message $mailMessage; | ||
private Attachment $mailAttachment; | ||
private Account $localAccount; | ||
private array $localMessageData; | ||
private array $localAttachmentData; | ||
|
||
protected function setUp(): void { | ||
parent::setUp(); | ||
|
@@ -271,45 +275,6 @@ public function testPerformWithAttachmentServiceFailure(): void { | |
$this->commandSend->perform('user1', '100', $mailMessage); | ||
} | ||
|
||
public function testPerformWithOutboxServiceSaveFailure(): void { | ||
// define time factory return | ||
$this->time->method('getTime')->willReturn(1719792000); | ||
// define account service returns | ||
$this->accountService->method('find')->will( | ||
$this->returnValueMap([ | ||
['user1', 100, $this->localAccount] | ||
]) | ||
); | ||
// construct mail app message objects | ||
$localMessageFresh = $this->localMessageData; | ||
$localMessageFresh['sendAt'] = $this->time->getTime($localMessageFresh); | ||
$localMessageFresh = LocalMessage::fromParams($localMessageFresh); | ||
$localMessageReturned = $this->localMessageData; | ||
$localMessageReturned['id'] = 1; | ||
$localMessageReturned['recipients'] = [['email' => '[email protected]', 'label' => 'User Two']]; | ||
$localMessageReturned['sendAt'] = $this->time->getTime(); | ||
$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']], | ||
[], | ||
[], | ||
[] | ||
)->will( | ||
$this->throwException(new \Exception('Something went wrong')) | ||
); | ||
// construct mail provider message | ||
$mailMessage = $this->mailMessage; | ||
// define exception condition | ||
$this->expectException(SendException::class); | ||
$this->expectExceptionMessage('Error: occurred while saving mail message'); | ||
// test send message | ||
$this->commandSend->perform('user1', '100', $mailMessage); | ||
} | ||
|
||
public function testPerformWithOutboxServiceSendFailure(): void { | ||
// define time factory return | ||
$this->time->method('getTime')->willReturn(1719792000); | ||
|