File: SendEmailRequestTest.php

package info (click to toggle)
php-async-aws-ses 1.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 320 kB
  • sloc: php: 1,658; makefile: 28
file content (87 lines) | stat: -rw-r--r-- 3,460 bytes parent folder | download | duplicates (2)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php

namespace AsyncAws\Ses\Tests\Unit\Input;

use AsyncAws\Core\Test\TestCase;
use AsyncAws\Ses\Input\SendEmailRequest;
use AsyncAws\Ses\ValueObject\Body;
use AsyncAws\Ses\ValueObject\Content;
use AsyncAws\Ses\ValueObject\Destination;
use AsyncAws\Ses\ValueObject\EmailContent;
use AsyncAws\Ses\ValueObject\Message;

class SendEmailRequestTest extends TestCase
{
    public function testRequest(): void
    {
        $input = new SendEmailRequest([
            'FromEmailAddress' => 'jeremy@derusse.com',
            'Destination' => new Destination([
                'ToAddresses' => ['recipient1@example.com', 'recipient2@example.com'],
                'CcAddresses' => ['recipient3@example.com'],
                'BccAddresses' => [],
            ]),
            'ReplyToAddresses' => [],
            'Content' => new EmailContent([
                'Simple' => new Message([
                    'Subject' => new Content([
                        'Data' => 'Test email',
                        'Charset' => 'UTF-8',
                    ]),
                    'Body' => new Body([
                        'Text' => new Content([
                            'Data' => 'This is the message body in text format.',
                            'Charset' => 'UTF-8',
                        ]),
                        'Html' => new Content([
                            'Data' => 'This message body contains HTML formatting. It can, for example, contain links like this one: <a class="ulink" href="http://docs.aws.amazon.com/ses/latest/DeveloperGuide" target="_blank">Amazon SES Developer Guide</a>.',
                            'Charset' => 'UTF-8',
                        ]),
                    ]),
                ]),
            ]),
        ]);

        // see example-1.json from SDK
        $expected = '
            POST /v2/email/outbound-emails HTTP/1.0
            Content-type: application/json
            Accept: application/json

            {
                "FromEmailAddress": "jeremy@derusse.com",
                "Destination": {
                    "ToAddresses": [
                        "recipient1@example.com",
                        "recipient2@example.com"
                    ],
                    "CcAddresses": [
                        "recipient3@example.com"
                    ],
                    "BccAddresses": []
                },
                "ReplyToAddresses": [],
                "Content": {
                    "Simple": {
                        "Subject": {
                            "Data": "Test email",
                            "Charset": "UTF-8"
                        },
                        "Body": {
                            "Text": {
                                "Data": "This is the message body in text format.",
                                "Charset": "UTF-8"
                            },
                            "Html": {
                                "Data": "This message body contains HTML formatting. It can, for example, contain links like this one: <a class=\\"ulink\\" href=\\"http:\\/\\/docs.aws.amazon.com\\/ses\\/latest\\/DeveloperGuide\\" target=\\"_blank\\">Amazon SES Developer Guide<\\/a>.",
                                "Charset": "UTF-8"
                            }
                        }
                    }
                }
            }
        ';

        self::assertRequestEqualsHttpRequest($expected, $input->request());
    }
}