These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Redaxscript\Tests\Template; |
||
3 | |||
4 | use org\bovigo\vfs\vfsStream as Stream; |
||
5 | use org\bovigo\vfs\vfsStreamFile as StreamFile; |
||
6 | use org\bovigo\vfs\vfsStreamWrapper as StreamWrapper; |
||
7 | use Redaxscript\Db; |
||
8 | use Redaxscript\Model; |
||
9 | use Redaxscript\Template; |
||
10 | use Redaxscript\Tests\TestCaseAbstract; |
||
11 | |||
12 | /** |
||
13 | * TagTest |
||
14 | * |
||
15 | * @since 2.3.0 |
||
16 | * |
||
17 | * @package Redaxscript |
||
18 | * @category Tests |
||
19 | * @author Henry Ruhs |
||
20 | * |
||
21 | * @covers Redaxscript\Template\Tag |
||
22 | */ |
||
23 | |||
24 | class TagTest extends TestCaseAbstract |
||
25 | { |
||
26 | /** |
||
27 | * setUp |
||
28 | * |
||
29 | * @since 3.1.0 |
||
30 | */ |
||
31 | |||
32 | public function setUp() : void |
||
33 | { |
||
34 | parent::setUp(); |
||
35 | $optionArray = |
||
36 | [ |
||
37 | 'adminName' => 'Test', |
||
38 | 'adminUser' => 'test', |
||
39 | 'adminPassword' => 'test', |
||
40 | 'adminEmail' => '[email protected]' |
||
41 | ]; |
||
42 | $installer = $this->installerFactory(); |
||
0 ignored issues
–
show
|
|||
43 | $installer->init(); |
||
44 | $installer->rawCreate(); |
||
45 | $installer->insertSettings($optionArray); |
||
46 | $categoryOne = Db::forTablePrefix('categories')->create(); |
||
47 | $categoryOne |
||
48 | ->set( |
||
49 | [ |
||
50 | 'title' => 'Category One', |
||
51 | 'alias' => 'category-one' |
||
52 | ]) |
||
53 | ->save(); |
||
54 | $articleOne = Db::forTablePrefix('articles')->create(); |
||
55 | $articleOne |
||
56 | ->set( |
||
57 | [ |
||
58 | 'title' => 'Article One', |
||
59 | 'alias' => 'article-one', |
||
60 | 'category' => $categoryOne->id, |
||
61 | 'comments' => 1 |
||
62 | ]) |
||
63 | ->save(); |
||
64 | Db::forTablePrefix('articles') |
||
65 | ->create() |
||
66 | ->set( |
||
67 | [ |
||
68 | 'title' => 'Article Two', |
||
69 | 'alias' => 'article-two', |
||
70 | 'category' => $categoryOne->id |
||
71 | ]) |
||
72 | ->save(); |
||
73 | Db::forTablePrefix('comments') |
||
74 | ->create() |
||
75 | ->set( |
||
76 | [ |
||
77 | 'author' => 'Comment One', |
||
78 | 'text' => 'Comment One', |
||
79 | 'article' => $articleOne->id |
||
80 | ]) |
||
81 | ->save(); |
||
82 | Db::forTablePrefix('comments') |
||
83 | ->create() |
||
84 | ->set( |
||
85 | [ |
||
86 | 'author' => 'Comment Two', |
||
87 | 'text' => 'Comment Two', |
||
88 | 'article' => $articleOne->id |
||
89 | ]) |
||
90 | ->save(); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * tearDown |
||
95 | * |
||
96 | * @since 3.1.0 |
||
97 | */ |
||
98 | |||
99 | public function tearDown() : void |
||
100 | { |
||
101 | $this->dropDatabase(); |
||
0 ignored issues
–
show
The method
dropDatabase() does not seem to exist on object<Redaxscript\Tests\Template\TagTest> .
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.
Loading history...
|
|||
102 | } |
||
103 | |||
104 | /** |
||
105 | * testBase |
||
106 | * |
||
107 | * @since 3.0.0 |
||
108 | */ |
||
109 | |||
110 | public function testBase() : void |
||
111 | { |
||
112 | /* actual */ |
||
113 | |||
114 | $actual = Template\Tag::base(); |
||
115 | |||
116 | /* compare */ |
||
117 | |||
118 | $this->assertIsString($actual); |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * testTitle |
||
123 | * |
||
124 | * @since 3.0.0 |
||
125 | */ |
||
126 | |||
127 | public function testTitle() : void |
||
128 | { |
||
129 | /* actual */ |
||
130 | |||
131 | $actual = Template\Tag::title('test'); |
||
132 | |||
133 | /* compare */ |
||
134 | |||
135 | $this->assertIsString($actual); |
||
136 | } |
||
137 | |||
138 | /** |
||
139 | * testLink |
||
140 | * |
||
141 | * @since 3.0.0 |
||
142 | */ |
||
143 | |||
144 | public function testLink() : void |
||
145 | { |
||
146 | /* actual */ |
||
147 | |||
148 | $actual = Template\Tag::link(); |
||
149 | |||
150 | /* compare */ |
||
151 | |||
152 | $this->assertInstanceOf('Redaxscript\Head\Link', $actual); |
||
153 | } |
||
154 | |||
155 | /** |
||
156 | * testMeta |
||
157 | * |
||
158 | * @since 3.0.0 |
||
159 | */ |
||
160 | |||
161 | public function testMeta() : void |
||
162 | { |
||
163 | /* actual */ |
||
164 | |||
165 | $actual = Template\Tag::meta(); |
||
166 | |||
167 | /* compare */ |
||
168 | |||
169 | $this->assertInstanceOf('Redaxscript\Head\Meta', $actual); |
||
170 | } |
||
171 | |||
172 | /** |
||
173 | * testScript |
||
174 | * |
||
175 | * @since 3.0.0 |
||
176 | */ |
||
177 | |||
178 | public function testScript() : void |
||
179 | { |
||
180 | /* actual */ |
||
181 | |||
182 | $actual = Template\Tag::script(); |
||
183 | |||
184 | /* compare */ |
||
185 | |||
186 | $this->assertInstanceOf('Redaxscript\Head\Script', $actual); |
||
187 | } |
||
188 | |||
189 | /** |
||
190 | * testStyle |
||
191 | * |
||
192 | * @since 3.0.0 |
||
193 | */ |
||
194 | |||
195 | public function testStyle() : void |
||
196 | { |
||
197 | /* actual */ |
||
198 | |||
199 | $actual = Template\Tag::style(); |
||
200 | |||
201 | /* compare */ |
||
202 | |||
203 | $this->assertInstanceOf('Redaxscript\Head\Style', $actual); |
||
204 | } |
||
205 | |||
206 | /** |
||
207 | * testBreadcrumb |
||
208 | * |
||
209 | * @since 2.3.0 |
||
210 | */ |
||
211 | |||
212 | public function testBreadcrumb() : void |
||
213 | { |
||
214 | /* actual */ |
||
215 | |||
216 | $actual = Template\Tag::breadcrumb(); |
||
217 | |||
218 | /* compare */ |
||
219 | |||
220 | $this->assertIsString($actual); |
||
221 | } |
||
222 | |||
223 | /** |
||
224 | * testPartial |
||
225 | * |
||
226 | * @since 2.3.0 |
||
227 | */ |
||
228 | |||
229 | public function testPartial() : void |
||
230 | { |
||
231 | /* setup */ |
||
232 | |||
233 | Stream::setup('root'); |
||
234 | $file = new StreamFile('partial.phtml'); |
||
235 | StreamWrapper::getRoot()->addChild($file); |
||
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
org\bovigo\vfs\vfsStreamContent as the method addChild() does only exist in the following implementations of said interface: org\bovigo\vfs\DotDirectory , org\bovigo\vfs\vfsStreamDirectory .
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Loading history...
|
|||
236 | |||
237 | /* actual */ |
||
238 | |||
239 | $actual = Template\Tag::partial(Stream::url('root' . DIRECTORY_SEPARATOR . 'partial.phtml')); |
||
240 | |||
241 | /* compare */ |
||
242 | |||
243 | $this->assertIsString($actual); |
||
244 | } |
||
245 | |||
246 | /** |
||
247 | * testPaginationArticles |
||
248 | * |
||
249 | * @since 4.0.0 |
||
250 | */ |
||
251 | |||
252 | public function testPaginationArticles() : void |
||
253 | { |
||
254 | /* setup */ |
||
255 | |||
256 | $settingModel = new Model\Setting(); |
||
257 | $settingModel->set('limit', 1); |
||
258 | |||
259 | /* actual */ |
||
260 | |||
261 | $actual = Template\Tag::pagination('articles', 1); |
||
262 | |||
263 | /* compare */ |
||
264 | |||
265 | $this->assertIsString($actual); |
||
266 | } |
||
267 | |||
268 | /** |
||
269 | * testPaginationComments |
||
270 | * |
||
271 | * @since 4.0.0 |
||
272 | */ |
||
273 | |||
274 | public function testPaginationComments() : void |
||
275 | { |
||
276 | /* setup */ |
||
277 | |||
278 | $settingModel = new Model\Setting(); |
||
279 | $settingModel->set('limit', 1); |
||
280 | |||
281 | /* actual */ |
||
282 | |||
283 | $actual = Template\Tag::pagination('comments', 1); |
||
284 | |||
285 | /* compare */ |
||
286 | |||
287 | $this->assertIsString($actual); |
||
288 | } |
||
289 | |||
290 | /** |
||
291 | * testPaginationInvalid |
||
292 | * |
||
293 | * @since 4.0.0 |
||
294 | */ |
||
295 | |||
296 | public function testPaginationInvalid() : void |
||
297 | { |
||
298 | /* actual */ |
||
299 | |||
300 | $actual = Template\Tag::pagination('invalid', 1); |
||
301 | |||
302 | /* compare */ |
||
303 | |||
304 | $this->assertNull($actual); |
||
305 | } |
||
306 | |||
307 | /** |
||
308 | * testNavigationCategories |
||
309 | * |
||
310 | * @since 3.3.1 |
||
311 | */ |
||
312 | |||
313 | public function testNavigationCategories() : void |
||
314 | { |
||
315 | /* actual */ |
||
316 | |||
317 | $actual = Template\Tag::navigation('categories'); |
||
318 | |||
319 | /* compare */ |
||
320 | |||
321 | $this->assertIsString($actual); |
||
322 | } |
||
323 | |||
324 | /** |
||
325 | * testNavigationArticles |
||
326 | * |
||
327 | * @since 3.3.1 |
||
328 | */ |
||
329 | |||
330 | public function testNavigationArticles() : void |
||
331 | { |
||
332 | /* actual */ |
||
333 | |||
334 | $actual = Template\Tag::navigation('articles'); |
||
335 | |||
336 | /* compare */ |
||
337 | |||
338 | $this->assertIsString($actual); |
||
339 | } |
||
340 | |||
341 | /** |
||
342 | * testNavigationComments |
||
343 | * |
||
344 | * @since 3.3.1 |
||
345 | */ |
||
346 | |||
347 | public function testNavigationComments() : void |
||
348 | { |
||
349 | /* actual */ |
||
350 | |||
351 | $actual = Template\Tag::navigation('comments'); |
||
352 | |||
353 | /* compare */ |
||
354 | |||
355 | $this->assertIsString($actual); |
||
356 | } |
||
357 | |||
358 | /** |
||
359 | * testNavigationLanguages |
||
360 | * |
||
361 | * @since 3.3.1 |
||
362 | */ |
||
363 | |||
364 | public function testNavigationLanguages() : void |
||
365 | { |
||
366 | /* actual */ |
||
367 | |||
368 | $actual = Template\Tag::navigation('languages'); |
||
369 | |||
370 | /* compare */ |
||
371 | |||
372 | $this->assertIsString($actual); |
||
373 | } |
||
374 | |||
375 | /** |
||
376 | * testNavigationTemplates |
||
377 | * |
||
378 | * @since 3.3.1 |
||
379 | */ |
||
380 | |||
381 | public function testNavigationTemplates() : void |
||
382 | { |
||
383 | /* actual */ |
||
384 | |||
385 | $actual = Template\Tag::navigation('templates'); |
||
386 | |||
387 | /* compare */ |
||
388 | |||
389 | $this->assertIsString($actual); |
||
390 | } |
||
391 | |||
392 | /** |
||
393 | * testNavigationTemplates |
||
394 | * |
||
395 | * @since 3.3.1 |
||
396 | */ |
||
397 | |||
398 | public function testNavigationInvalid() : void |
||
399 | { |
||
400 | /* actual */ |
||
401 | |||
402 | $actual = Template\Tag::navigation('invalid'); |
||
403 | |||
404 | /* compare */ |
||
405 | |||
406 | $this->assertNull($actual); |
||
407 | } |
||
408 | |||
409 | /** |
||
410 | * testConsole |
||
411 | * |
||
412 | * @since 3.0.0 |
||
413 | */ |
||
414 | |||
415 | public function testConsole() : void |
||
416 | { |
||
417 | /* setup */ |
||
418 | |||
419 | $this->_request->setPost('argv', 'help'); |
||
420 | |||
421 | /* actual */ |
||
422 | |||
423 | $actual = Template\Tag::console(); |
||
424 | |||
425 | /* compare */ |
||
426 | |||
427 | $this->assertIsString($actual); |
||
428 | } |
||
429 | |||
430 | /** |
||
431 | * testConsoleInvalid |
||
432 | * |
||
433 | * @since 3.0.0 |
||
434 | */ |
||
435 | |||
436 | public function testConsoleInvalid() : void |
||
437 | { |
||
438 | /* setup */ |
||
439 | |||
440 | $this->_request->setPost('argv', 'invalidCommand'); |
||
441 | |||
442 | /* actual */ |
||
443 | |||
444 | $actual = Template\Tag::console(); |
||
445 | |||
446 | /* compare */ |
||
447 | |||
448 | $this->assertNull($actual); |
||
449 | } |
||
450 | |||
451 | /** |
||
452 | * testConsoleForm |
||
453 | * |
||
454 | * @since 3.0.0 |
||
455 | */ |
||
456 | |||
457 | public function testConsoleForm() : void |
||
458 | { |
||
459 | /* actual */ |
||
460 | |||
461 | $actual = Template\Tag::consoleForm(); |
||
462 | |||
463 | /* compare */ |
||
464 | |||
465 | $this->assertIsString($actual); |
||
466 | } |
||
467 | |||
468 | /** |
||
469 | * testCommentForm |
||
470 | * |
||
471 | * @since 4.0.0 |
||
472 | */ |
||
473 | |||
474 | public function testCommentForm() : void |
||
475 | { |
||
476 | /* actual */ |
||
477 | |||
478 | $actual = Template\Tag::commentForm(1); |
||
479 | |||
480 | /* compare */ |
||
481 | |||
482 | $this->assertIsString($actual); |
||
483 | } |
||
484 | |||
485 | /** |
||
486 | * testSearchForm |
||
487 | * |
||
488 | * @since 3.0.0 |
||
489 | */ |
||
490 | |||
491 | public function testSearchForm() : void |
||
492 | { |
||
493 | /* actual */ |
||
494 | |||
495 | $actual = Template\Tag::searchForm(); |
||
496 | |||
497 | /* compare */ |
||
498 | |||
499 | $this->assertIsString($actual); |
||
500 | } |
||
501 | |||
502 | } |
||
503 |
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.