ApplyEmailMessageOptionsTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testOptionsApplied() 0 11 1
A setUp() 0 29 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FH\Bundle\MailerBundle\Tests\Composer;
6
7
use FH\Bundle\MailerBundle\Composer\ApplyEmailMessageOptions;
8
use FH\Bundle\MailerBundle\Email\MessageOptions;
9
use FH\Bundle\MailerBundle\Email\Participants;
10
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...
11
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
12
use Symfony\Component\Mime\Address;
13
14
/**
15
 * @covers \FH\Bundle\MailerBundle\Composer\ApplyEmailMessageOptions
16
 */
17
final class ApplyEmailMessageOptionsTest extends TestCase
18
{
19
    /** @var MessageOptions */
20
    private $messageOptions;
21
22
    /** @var ApplyEmailMessageOptions */
23
    private $applyEmailMessageOptions;
24
25
    /** @var TemplatedEmail */
26
    private $assertEmail;
27
28
    protected function setUp(): void
29
    {
30
        $sender = new Address('[email protected]', 'Mr. Test');
31
        $to = new Address('[email protected]', 'Ms. Test');
32
33
        $this->messageOptions = new MessageOptions(
34
            'Test email',
35
            'test.html.twig',
36
            'test.txt.twig',
37
            new Participants(
38
                $sender,
39
                [$sender],
40
                [$sender],
41
                [$to],
42
                [$to],
43
                [$to]
44
            )
45
        );
46
47
        $this->assertEmail = new TemplatedEmail();
48
        $this->assertEmail->subject('Test email');
49
        $this->assertEmail->sender($sender);
50
        $this->assertEmail->from($sender);
51
        $this->assertEmail->replyTo($sender);
52
        $this->assertEmail->to($to);
53
        $this->assertEmail->cc($to);
54
        $this->assertEmail->bcc($to);
55
56
        $this->applyEmailMessageOptions = new ApplyEmailMessageOptions();
57
    }
58
59
    public function testOptionsApplied(): void
60
    {
61
        $email = new TemplatedEmail();
62
        $this->applyEmailMessageOptions->apply($email, $this->messageOptions);
63
64
        $this->assertSame($this->assertEmail->getSubject(), $email->getSubject());
65
        $this->assertSame($this->assertEmail->getSender(), $email->getSender());
66
        $this->assertSame($this->assertEmail->getFrom(), $email->getFrom());
67
        $this->assertSame($this->assertEmail->getTo(), $email->getTo());
68
        $this->assertSame($this->assertEmail->getCc(), $email->getCc());
69
        $this->assertSame($this->assertEmail->getBcc(), $email->getBcc());
70
    }
71
}
72