-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathEmailTest.php
More file actions
46 lines (38 loc) · 1.43 KB
/
EmailTest.php
File metadata and controls
46 lines (38 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace Utopia\Tests\Adapter\Email;
use Utopia\Messaging\Adapter\Email\Mock;
use Utopia\Messaging\Messages\Email;
use Utopia\Tests\Adapter\Base;
class EmailTest extends Base
{
public function testSendEmail(): void
{
$sender = new Mock();
$to = 'tester@localhost.test';
$subject = 'Test Subject';
$content = 'Test Content';
$fromName = 'Test Sender';
$fromEmail = 'sender@localhost.test';
$cc = [['email' => 'tester2@localhost.test']];
$bcc = [['name' => 'Tester3', 'email' => 'tester3@localhost.test']];
$message = new Email(
to: [$to],
subject: $subject,
content: $content,
fromName: $fromName,
fromEmail: $fromEmail,
cc: $cc,
bcc: $bcc,
);
$response = $sender->send($message);
$lastEmail = $this->getLastEmail();
$this->assertResponse($response);
$this->assertSame($to, $lastEmail['to'][0]['address']);
$this->assertSame($fromEmail, $lastEmail['from'][0]['address']);
$this->assertSame($fromName, $lastEmail['from'][0]['name']);
$this->assertSame($subject, $lastEmail['subject']);
$this->assertSame($content, \trim($lastEmail['text']));
$this->assertSame($cc[0]['email'], $lastEmail['cc'][0]['address']);
$this->assertSame($bcc[0]['email'], $lastEmail['envelope']['to'][2]['address']);
}
}