Passed
Pull Request — main (#17)
by Rizart
10:12
created

SendTest::send_an_email_with_attachment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 16
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 21
rs 9.7333
1
<?php
2
3
namespace Tests\Integration\Email;
4
5
use ElasticEmail\ElasticEmail;
6
use Tests\Integration\IntegrationTestCase;
7
8
class SendTest extends IntegrationTestCase
9
{
10
    /** @test */
11
    public function send_an_email()
12
    {
13
        $this->loadEnv();
14
        $subject = "elasticemail-php: Integration test ensuring email send.";
15
16
        $elasticEmail = new ElasticEmail($_ENV['ELASTIC_EMAIL_API_KEY']);
17
        $response = $elasticEmail->email()->send([
18
            'to' => $_ENV['TEST_EMAIL_TO'],
19
            'from' => $_ENV['TEST_EMAIL_FROM'],
20
            'subject' => $subject,
21
            'bodyText' => 'Your mind will answer most questions if you learn '
22
                . 'to relax and wait for the answer.',
23
        ]);
24
25
        $this->assertTrue($response->wasSuccessful());
26
        $this->assertEquals(200, $response->getStatusCode());
27
28
        d($response->getBody());
29
    }
30
31
    /** @test */
32
    public function send_an_email_with_attachment()
33
    {
34
        $this->loadEnv();
35
        $subject = "elasticemail-php: Integration test: validate email "
36
            . "attachment send.";
37
        $attachments = [
38
            __DIR__ . '/alpha-attachment.txt',
39
             __DIR__ . '/beta-attachment.txt'
40
        ];
41
        $elasticEmail = new ElasticEmail($_ENV['ELASTIC_EMAIL_API_KEY']);
42
        $response = $elasticEmail->email()->send([
43
            'to' => $_ENV['TEST_EMAIL_TO'],
44
            'from' => $_ENV['TEST_EMAIL_FROM'],
45
            'subject' => $subject,
46
            'bodyText' => 'Wake up Samurai!',
47
        ], $attachments);
48
49
        $this->assertTrue($response->wasSuccessful());
50
        $this->assertEquals(200, $response->getStatusCode());
51
52
        d($response->getBody());
53
    }
54
}
55