1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace FH\Bundle\MailerBundle\Tests\Composer; |
||
6 | |||
7 | use FH\Bundle\MailerBundle\Composer\TemplatedEmailComposer; |
||
8 | use FH\Bundle\MailerBundle\Email\MessageOptions; |
||
9 | use FH\Bundle\MailerBundle\Email\Participants; |
||
10 | use PHPUnit\Framework\TestCase; |
||
0 ignored issues
–
show
|
|||
11 | use Symfony\Bridge\Twig\Mime\TemplatedEmail; |
||
12 | use Symfony\Component\Mailer\Exception\InvalidArgumentException; |
||
13 | use Symfony\Component\Mime\Address; |
||
14 | use Symfony\Component\Mime\Email; |
||
15 | |||
16 | /** |
||
17 | * @covers \FH\Bundle\MailerBundle\Composer\TemplatedEmailComposer |
||
18 | */ |
||
19 | final class TemplatedEmailComposerTest extends TestCase |
||
20 | { |
||
21 | /** @var MessageOptions */ |
||
22 | private $messageOptions; |
||
23 | |||
24 | /** @var TemplatedEmailComposer */ |
||
25 | private $templatedEmailComposer; |
||
26 | |||
27 | protected function setUp(): void |
||
28 | { |
||
29 | $sender = new Address('[email protected]', 'Mr. Test'); |
||
30 | $to = new Address('[email protected]', 'Ms. Test'); |
||
31 | |||
32 | $this->messageOptions = new MessageOptions( |
||
33 | 'Test email', |
||
34 | 'test.html.twig', |
||
35 | 'test.txt.twig', |
||
36 | new Participants( |
||
37 | $sender, |
||
38 | [$sender], |
||
39 | [$sender], |
||
40 | [$to], |
||
41 | [$to], |
||
42 | [$to] |
||
43 | ) |
||
44 | ); |
||
45 | |||
46 | $this->templatedEmailComposer = new TemplatedEmailComposer($this->messageOptions); |
||
47 | } |
||
48 | |||
49 | public function testWrongMessageType(): void |
||
50 | { |
||
51 | $this->expectException(InvalidArgumentException::class); |
||
52 | |||
53 | $this->templatedEmailComposer->compose([], new Email()); |
||
54 | } |
||
55 | |||
56 | public function testReturnedMessageType(): void |
||
57 | { |
||
58 | $email = $this->templatedEmailComposer->compose(); |
||
59 | |||
60 | $this->assertInstanceOf(TemplatedEmail::class, $email); |
||
61 | } |
||
62 | |||
63 | public function testSelectedTemplate(): void |
||
64 | { |
||
65 | $email = $this->templatedEmailComposer->compose(); |
||
66 | |||
67 | $this->assertSame('test.txt.twig', $email->getTextTemplate()); |
||
68 | $this->assertSame('test.html.twig', $email->getHtmlTemplate()); |
||
69 | } |
||
70 | |||
71 | public function testContext(): void |
||
72 | { |
||
73 | $context = ['foo' => 'bar']; |
||
74 | $email = $this->templatedEmailComposer->compose($context); |
||
75 | |||
76 | $this->assertSame($context, $email->getContext()); |
||
77 | } |
||
78 | } |
||
79 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths