Completed
Push — develop ( 2307d8...93b7d1 )
by Misha
07:40 queued 04:45
created

MessageOptionsTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 35
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 20
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 35
rs 9.6
1
<?php
2
declare(strict_types=1);
3
4
namespace FH\Bundle\MailerBundle\Tests\Email;
5
6
use FH\Bundle\MailerBundle\Email\MessageOptions;
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * @covers \FH\Bundle\MailerBundle\Email\MessageOptions
11
 */
12
final class MessageOptionsTest extends TestCase
13
{
14
    private $messageOptions;
15
16
    protected function setUp(): void
17
    {
18
        $this->messageOptions = MessageOptions::fromArray([
19
            'html_template' => 'test.html.twig',
20
            'text_template' => 'test.text.twig',
21
            'subject' => 'Test email',
22
            'participants' => [
23
                'from' => [
24
                    [
25
                        'name' => 'Mr. Test',
26
                        'address' => '[email protected]',
27
                    ],
28
                ],
29
                'reply_to' => [
30
                    [
31
                        'name' => 'Mr. Test',
32
                        'address' => '[email protected]',
33
                    ],
34
                ],
35
                'to' => [
36
                    [
37
                        'name' => 'Ms. Test',
38
                        'address' => '[email protected]',
39
                    ],
40
                ],
41
                'cc' => [
42
                    [
43
                        'name' => 'Ms. Test',
44
                        'address' => '[email protected]',
45
                    ],
46
                ],
47
                'bcc' => [
48
                    [
49
                        'name' => 'Ms. Test',
50
                        'address' => '[email protected]',
51
                    ],
52
                ],
53
        ]]);
54
    }
55
56
    public function testFromArray(): void
57
    {
58
        $this->assertTrue($this->messageOptions->hasSubject());
59
        $this->assertSame('Test email', $this->messageOptions->getSubject());
60
61
        $this->assertTrue($this->messageOptions->hasHtmlTemplate());
62
        $this->assertSame('test.html.twig', $this->messageOptions->getHtmlTemplate());
63
64
        $this->assertTrue($this->messageOptions->hasTextTemplate());
65
        $this->assertSame('test.text.twig', $this->messageOptions->getTextTemplate());
66
67
        $participants = $this->messageOptions->getParticipants();
68
        $this->assertCount(1, $participants->getFrom());
69
        $this->assertSame('Mr. Test', $participants->getFrom()[0]->getName());
70
    }
71
}
72