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 Chris\Bundle\FrontRenderBundle\Tests\Render; |
||
4 | |||
5 | use Chris\Bundle\FrontRenderBundle\Render\FrontRender; |
||
6 | use Chris\Bundle\FrontRenderBundle\Subscriber\RenderSubscriber; |
||
7 | use Chris\Bundle\FrontRenderBundle\Twig\LexerManager; |
||
8 | use InvalidArgumentException; |
||
9 | use Phake; |
||
10 | use PHPUnit_Framework_TestCase; |
||
11 | use Symfony\Bundle\TwigBundle\TwigEngine; |
||
12 | use Symfony\Component\Config\FileLocator; |
||
13 | use Symfony\Component\EventDispatcher\EventDispatcher; |
||
14 | use Symfony\Component\Templating\TemplateNameParser; |
||
15 | use Twig_Environment; |
||
16 | use Twig_Error_Syntax; |
||
17 | use Twig_Loader_Filesystem; |
||
18 | |||
19 | class FrontRenderTest extends PHPUnit_Framework_TestCase |
||
20 | { |
||
21 | /** |
||
22 | * @var string TEMPLATE_PATH |
||
23 | */ |
||
24 | const TEMPLATE_PATH = 'Template'; |
||
25 | |||
26 | /** |
||
27 | * @var string TEMPLATE |
||
28 | */ |
||
29 | const TEMPLATE = 'index.html.twig'; |
||
30 | |||
31 | /** |
||
32 | * @var string FAILED_TEMPLATE |
||
33 | */ |
||
34 | const FAILED_TEMPLATE = 'failed.html.twig'; |
||
35 | |||
36 | /** |
||
37 | * @var string FAILED_PATH |
||
38 | */ |
||
39 | const FAILED_PATH = 'failedPath.html.twig'; |
||
40 | |||
41 | /** |
||
42 | * @var EventDispatcher |
||
43 | */ |
||
44 | protected $eventDispatcher; |
||
45 | |||
46 | /** |
||
47 | * @var Twig_Loader_Filesystem |
||
48 | */ |
||
49 | protected $twigLoader; |
||
50 | |||
51 | /** |
||
52 | * @var Twig_Environment |
||
53 | */ |
||
54 | protected $twigEnvironment; |
||
55 | |||
56 | /** |
||
57 | * @var RenderSubscriber |
||
58 | */ |
||
59 | protected $renderSubscriber; |
||
60 | |||
61 | /** |
||
62 | * @var TemplateNameParser |
||
63 | */ |
||
64 | protected $templateNameParser; |
||
65 | |||
66 | /** |
||
67 | * @var FileLocator |
||
68 | */ |
||
69 | protected $fileLocator; |
||
70 | |||
71 | /** |
||
72 | * @var TwigEngine |
||
73 | */ |
||
74 | protected $engine; |
||
75 | |||
76 | /** |
||
77 | * @var FrontRender |
||
78 | */ |
||
79 | protected $frontRender; |
||
80 | |||
81 | /** |
||
82 | * @var LexerManager |
||
83 | */ |
||
84 | protected $lexerManager; |
||
85 | |||
86 | /** |
||
87 | * Set up the front render test |
||
88 | */ |
||
89 | public function setUp() |
||
90 | { |
||
91 | parent::setUp(); |
||
92 | |||
93 | $this->eventDispatcher = Phake::mock(EventDispatcher::class); |
||
0 ignored issues
–
show
|
|||
94 | $this->twigLoader = Phake::partialMock(Twig_Loader_Filesystem::class, [__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . self::TEMPLATE_PATH]); |
||
0 ignored issues
–
show
It seems like
\Phake::partialMock(\Twi.... self::TEMPLATE_PATH)) of type object<Phake_IMock> is incompatible with the declared type object<Twig_Loader_Filesystem> of property $twigLoader .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
95 | $this->twigEnvironment = Phake::partialMock(Twig_Environment::class, $this->twigLoader); |
||
0 ignored issues
–
show
It seems like
\Phake::partialMock(\Twi...ass, $this->twigLoader) of type object<Phake_IMock> is incompatible with the declared type object<Twig_Environment> of property $twigEnvironment .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
96 | $this->lexerManager = Phake::partialMock(LexerManager::class, $this->twigEnvironment); |
||
0 ignored issues
–
show
It seems like
\Phake::partialMock(\Chr...$this->twigEnvironment) of type object<Phake_IMock> is incompatible with the declared type object<Chris\Bundle\Fron...ndle\Twig\LexerManager> of property $lexerManager .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
97 | $this->renderSubscriber = Phake::partialMock(RenderSubscriber::class, $this->lexerManager); |
||
0 ignored issues
–
show
It seems like
\Phake::partialMock(\Chr...s, $this->lexerManager) of type object<Phake_IMock> is incompatible with the declared type object<Chris\Bundle\Fron...riber\RenderSubscriber> of property $renderSubscriber .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
98 | |||
99 | $this->templateNameParser = Phake::mock(TemplateNameParser::class); |
||
0 ignored issues
–
show
It seems like
\Phake::mock(\Symfony\Co...plateNameParser::class) of type object<Phake_IMock> is incompatible with the declared type object<Symfony\Component...ing\TemplateNameParser> of property $templateNameParser .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
100 | $this->fileLocator = Phake::mock(FileLocator::class); |
||
0 ignored issues
–
show
It seems like
\Phake::mock(\Symfony\Co...fig\FileLocator::class) of type object<Phake_IMock> is incompatible with the declared type object<Symfony\Component\Config\FileLocator> of property $fileLocator .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
101 | $this->engine = Phake::partialMock(TwigEngine::class, $this->twigEnvironment, $this->templateNameParser, $this->fileLocator); |
||
0 ignored issues
–
show
It seems like
\Phake::partialMock(\Sym...er, $this->fileLocator) of type object<Phake_IMock> is incompatible with the declared type object<Symfony\Bundle\TwigBundle\TwigEngine> of property $engine .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
102 | |||
103 | $lexer = $this->lexerManager->getNewLexer(); |
||
0 ignored issues
–
show
The method
getNewLexer() does not seem to exist on object<Phake_IMock> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
104 | $this->twigEnvironment->setLexer($lexer); |
||
0 ignored issues
–
show
The method
setLexer() does not seem to exist on object<Phake_IMock> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
105 | } |
||
106 | |||
107 | /** |
||
108 | * Test render of the template with parameter |
||
109 | */ |
||
110 | View Code Duplication | public function testTemplateRenderWithParameter() |
|
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. ![]() |
|||
111 | { |
||
112 | $this->frontRender = new FrontRender($this->engine, $this->eventDispatcher, self::TEMPLATE); |
||
113 | |||
114 | $this->frontRender->setParameters( |
||
115 | [ |
||
116 | 'applicationName' => 'Test Render', |
||
117 | ] |
||
118 | ); |
||
119 | |||
120 | $this->assertContains( |
||
121 | 'Welcome on Test Render', |
||
122 | $this->frontRender->render() |
||
123 | ); |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * Test render of the template without parameter |
||
128 | */ |
||
129 | View Code Duplication | public function testTemplateRenderWithoutParameter() |
|
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. ![]() |
|||
130 | { |
||
131 | $this->frontRender = new FrontRender($this->engine, $this->eventDispatcher, self::TEMPLATE); |
||
132 | |||
133 | $this->assertNotContains( |
||
134 | 'Test Render', |
||
135 | $this->frontRender->render() |
||
136 | ); |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * Test on the update of lexer |
||
141 | * |
||
142 | * @dataProvider lexerTags |
||
143 | * |
||
144 | * @param string $oldTags |
||
145 | * @param string $newTags |
||
146 | */ |
||
147 | public function testSetLexer($oldTags, $newTags) |
||
148 | { |
||
149 | $this->frontRender = new FrontRender($this->engine, $this->eventDispatcher, self::TEMPLATE); |
||
150 | |||
151 | $this->frontRender->setParameters( |
||
152 | [ |
||
153 | 'applicationName' => 'Test Render', |
||
154 | ] |
||
155 | ); |
||
156 | |||
157 | $render = $this->frontRender->render(); |
||
158 | |||
159 | $this->assertContains( |
||
160 | $oldTags, |
||
161 | $render |
||
162 | ); |
||
163 | |||
164 | $this->assertNotContains( |
||
165 | $newTags, |
||
166 | $render |
||
167 | ); |
||
168 | } |
||
169 | |||
170 | /** |
||
171 | * Test on the failed template |
||
172 | * |
||
173 | * @expectedException Twig_Error_Syntax |
||
174 | */ |
||
175 | public function testExceptionOnSyntax() |
||
176 | { |
||
177 | $this->frontRender = new FrontRender($this->engine, $this->eventDispatcher, self::FAILED_TEMPLATE); |
||
178 | |||
179 | $this->frontRender->render(); |
||
180 | } |
||
181 | |||
182 | /** |
||
183 | * Test when the template doesn't exist |
||
184 | * |
||
185 | * @expectedException InvalidArgumentException |
||
186 | */ |
||
187 | public function testExceptionOnFailedPath() |
||
188 | { |
||
189 | $this->frontRender = new FrontRender($this->engine, $this->eventDispatcher, self::FAILED_PATH); |
||
190 | |||
191 | $this->frontRender->render(); |
||
192 | } |
||
193 | |||
194 | /** |
||
195 | * Test when the template path is empty |
||
196 | * |
||
197 | * @expectedException Chris\Bundle\FrontRenderBundle\Exception\FrontRenderException |
||
198 | */ |
||
199 | public function testExceptionOnEmptyPath() |
||
200 | { |
||
201 | $this->frontRender = new FrontRender($this->engine, $this->eventDispatcher, ''); |
||
202 | |||
203 | $this->frontRender->render(); |
||
204 | } |
||
205 | |||
206 | /** |
||
207 | * Provide the lexer tags |
||
208 | * |
||
209 | * @return array |
||
0 ignored issues
–
show
|
|||
210 | */ |
||
211 | public function lexerTags() |
||
212 | { |
||
213 | return [ |
||
214 | ['{#', '{*'], |
||
215 | ['{%', '{@'], |
||
216 | ['{{', '{$'] |
||
217 | ]; |
||
218 | |||
219 | } |
||
220 | } |
||
221 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..