This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Liip\MonitorBundle\Tests\DependencyInjection\Compiler; |
||
4 | |||
5 | use Liip\MonitorBundle\DependencyInjection\Compiler\MailerCompilerPass; |
||
6 | use Liip\MonitorBundle\Helper\SwiftMailerReporter; |
||
7 | use Liip\MonitorBundle\Helper\SymfonyMailerReporter; |
||
8 | use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; |
||
9 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
||
10 | use Symfony\Component\DependencyInjection\Definition; |
||
11 | use Symfony\Component\DependencyInjection\Reference; |
||
12 | use Symfony\Component\Mailer\MailerInterface; |
||
13 | |||
14 | class MailerCompilerPassTest extends AbstractCompilerPassTestCase |
||
15 | { |
||
16 | public function testDisabledMailer() |
||
17 | { |
||
18 | $this->setParameter('liip_monitor.mailer.enabled', false); |
||
19 | |||
20 | $this->compile(); |
||
21 | |||
22 | $this->assertContainerBuilderNotHasService('liip_monitor.reporter.symfony_mailer'); |
||
23 | $this->assertContainerBuilderNotHasService('liip_monitor.reporter.swift_mailer'); |
||
24 | } |
||
25 | |||
26 | View Code Duplication | public function testSwiftMailer() |
|
0 ignored issues
–
show
|
|||
27 | { |
||
28 | $this->setParameter('liip_monitor.mailer.enabled', true); |
||
29 | $this->setDefinition('mailer', new Definition(\Swift_Mailer::class)); |
||
30 | |||
31 | $this->compile(); |
||
32 | |||
33 | $this->assertContainerBuilderNotHasService('liip_monitor.reporter.symfony_mailer'); |
||
34 | $this->assertContainerBuilderHasService('liip_monitor.reporter.swift_mailer', SwiftMailerReporter::class); |
||
35 | |||
36 | $this->assertContainerBuilderHasServiceDefinitionWithArgument( |
||
37 | 'liip_monitor.reporter.swift_mailer', |
||
38 | 0, |
||
39 | new Reference('mailer') |
||
40 | ); |
||
41 | $this->assertContainerBuilderHasServiceDefinitionWithArgument( |
||
42 | 'liip_monitor.reporter.swift_mailer', |
||
43 | 1, |
||
44 | '%liip_monitor.mailer.recipient%' |
||
45 | ); |
||
46 | $this->assertContainerBuilderHasServiceDefinitionWithArgument( |
||
47 | 'liip_monitor.reporter.swift_mailer', |
||
48 | 2, |
||
49 | '%liip_monitor.mailer.sender%' |
||
50 | ); |
||
51 | $this->assertContainerBuilderHasServiceDefinitionWithArgument( |
||
52 | 'liip_monitor.reporter.swift_mailer', |
||
53 | 3, |
||
54 | '%liip_monitor.mailer.subject%' |
||
55 | ); |
||
56 | $this->assertContainerBuilderHasServiceDefinitionWithArgument( |
||
57 | 'liip_monitor.reporter.swift_mailer', |
||
58 | 4, |
||
59 | '%liip_monitor.mailer.send_on_warning%' |
||
60 | ); |
||
61 | $this->assertContainerBuilderHasServiceDefinitionWithTag( |
||
62 | 'liip_monitor.reporter.swift_mailer', |
||
63 | 'liip_monitor.additional_reporter', |
||
64 | ['alias' => 'swift_mailer'] |
||
65 | ); |
||
66 | } |
||
67 | |||
68 | View Code Duplication | public function testSwiftMailerWithAliasDefinition() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
69 | { |
||
70 | $this->setParameter('liip_monitor.mailer.enabled', true); |
||
71 | $this->setDefinition('swift.mailer', new Definition(\Swift_Mailer::class)); |
||
72 | $this->container->setAlias('mailer', 'swift.mailer'); |
||
73 | |||
74 | $this->assertContainerBuilderHasAlias('mailer'); |
||
75 | |||
76 | $this->compile(); |
||
77 | |||
78 | $this->assertContainerBuilderHasService('liip_monitor.reporter.swift_mailer', SwiftMailerReporter::class); |
||
79 | } |
||
80 | |||
81 | View Code Duplication | public function testSymfonyMailer() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
82 | { |
||
83 | $this->setParameter('liip_monitor.mailer.enabled', true); |
||
84 | $this->setDefinition('mailer', new Definition(MailerInterface::class)); |
||
85 | |||
86 | $this->compile(); |
||
87 | |||
88 | $this->assertContainerBuilderNotHasService('liip_monitor.reporter.swift_mailer'); |
||
89 | $this->assertContainerBuilderHasService('liip_monitor.reporter.symfony_mailer', SymfonyMailerReporter::class); |
||
90 | |||
91 | $this->assertContainerBuilderHasServiceDefinitionWithArgument( |
||
92 | 'liip_monitor.reporter.symfony_mailer', |
||
93 | 0, |
||
94 | new Reference('mailer') |
||
95 | ); |
||
96 | $this->assertContainerBuilderHasServiceDefinitionWithArgument( |
||
97 | 'liip_monitor.reporter.symfony_mailer', |
||
98 | 1, |
||
99 | '%liip_monitor.mailer.recipient%' |
||
100 | ); |
||
101 | $this->assertContainerBuilderHasServiceDefinitionWithArgument( |
||
102 | 'liip_monitor.reporter.symfony_mailer', |
||
103 | 2, |
||
104 | '%liip_monitor.mailer.sender%' |
||
105 | ); |
||
106 | $this->assertContainerBuilderHasServiceDefinitionWithArgument( |
||
107 | 'liip_monitor.reporter.symfony_mailer', |
||
108 | 3, |
||
109 | '%liip_monitor.mailer.subject%' |
||
110 | ); |
||
111 | $this->assertContainerBuilderHasServiceDefinitionWithArgument( |
||
112 | 'liip_monitor.reporter.symfony_mailer', |
||
113 | 4, |
||
114 | '%liip_monitor.mailer.send_on_warning%' |
||
115 | ); |
||
116 | $this->assertContainerBuilderHasServiceDefinitionWithTag( |
||
117 | 'liip_monitor.reporter.symfony_mailer', |
||
118 | 'liip_monitor.additional_reporter', |
||
119 | ['alias' => 'symfony_mailer'] |
||
120 | ); |
||
121 | } |
||
122 | |||
123 | View Code Duplication | public function testSymfonyMailerWithAliasDefinition() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
124 | { |
||
125 | $this->setParameter('liip_monitor.mailer.enabled', true); |
||
126 | $this->setDefinition('symfony.mailer', new Definition(MailerInterface::class)); |
||
127 | $this->container->setAlias('mailer', 'symfony.mailer'); |
||
128 | |||
129 | $this->assertContainerBuilderHasAlias('mailer'); |
||
130 | |||
131 | $this->compile(); |
||
132 | |||
133 | $this->assertContainerBuilderHasService('liip_monitor.reporter.symfony_mailer', SymfonyMailerReporter::class); |
||
134 | } |
||
135 | |||
136 | public function testMailerWithoutPackage() |
||
137 | { |
||
138 | $this->setParameter('liip_monitor.mailer.enabled', true); |
||
139 | $this->expectExceptionMessage('To enable mail reporting you have to install the "swiftmailer/swiftmailer" or "symfony/mailer".'); |
||
140 | $this->expectException(\InvalidArgumentException::class); |
||
141 | |||
142 | $this->assertContainerBuilderNotHasService('mailer'); |
||
143 | $this->compile(); |
||
144 | } |
||
145 | |||
146 | public function testMailerMissingAliasDefinition() |
||
147 | { |
||
148 | $this->setParameter('liip_monitor.mailer.enabled', true); |
||
149 | $this->setDefinition('swift.mailer', new Definition(\Swift_Mailer::class)); |
||
150 | |||
151 | $this->assertFalse($this->container->hasAlias('mailer')); |
||
152 | |||
153 | $this->expectException(\InvalidArgumentException::class); |
||
154 | $this->expectExceptionMessage('To enable mail reporting you have to install the "swiftmailer/swiftmailer" or "symfony/mailer".'); |
||
155 | |||
156 | $this->compile(); |
||
157 | } |
||
158 | |||
159 | protected function registerCompilerPass(ContainerBuilder $container): void |
||
160 | { |
||
161 | $container->addCompilerPass(new MailerCompilerPass()); |
||
162 | } |
||
163 | } |
||
164 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.