MessageOptionsTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 31
dl 0
loc 59
rs 10
c 1
b 0
f 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testFromArray() 0 14 1
A setUp() 0 35 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FH\Bundle\MailerBundle\Tests\Email;
6
7
use FH\Bundle\MailerBundle\Email\MessageOptions;
8
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
/**
11
 * @covers \FH\Bundle\MailerBundle\Email\MessageOptions
12
 */
13
final class MessageOptionsTest extends TestCase
14
{
15
    /** @var MessageOptions */
16
    private $messageOptions;
17
18
    protected function setUp(): void
19
    {
20
        $this->messageOptions = MessageOptions::fromArray([
21
            'html_template' => 'test.html.twig',
22
            'text_template' => 'test.text.twig',
23
            'subject' => 'Test email',
24
            'participants' => [
25
                'from' => [
26
                    [
27
                        'name' => 'Mr. Test',
28
                        'address' => '[email protected]',
29
                    ],
30
                ],
31
                'reply_to' => [
32
                    [
33
                        'name' => 'Mr. Test',
34
                        'address' => '[email protected]',
35
                    ],
36
                ],
37
                'to' => [
38
                    [
39
                        'name' => 'Ms. Test',
40
                        'address' => '[email protected]',
41
                    ],
42
                ],
43
                'cc' => [
44
                    [
45
                        'name' => 'Ms. Test',
46
                        'address' => '[email protected]',
47
                    ],
48
                ],
49
                'bcc' => [
50
                    [
51
                        'name' => 'Ms. Test',
52
                        'address' => '[email protected]',
53
                    ],
54
                ],
55
        ], ]);
56
    }
57
58
    public function testFromArray(): void
59
    {
60
        $this->assertTrue($this->messageOptions->hasSubject());
61
        $this->assertSame('Test email', $this->messageOptions->getSubject());
62
63
        $this->assertTrue($this->messageOptions->hasHtmlTemplate());
64
        $this->assertSame('test.html.twig', $this->messageOptions->getHtmlTemplate());
65
66
        $this->assertTrue($this->messageOptions->hasTextTemplate());
67
        $this->assertSame('test.text.twig', $this->messageOptions->getTextTemplate());
68
69
        $participants = $this->messageOptions->getParticipants();
70
        $this->assertCount(1, $participants->getFrom());
71
        $this->assertSame('Mr. Test', $participants->getFrom()[0]->getName());
72
    }
73
}
74