1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Symfony-Util package. |
5
|
|
|
* |
6
|
|
|
* (c) Jean-Bernard Addor |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
use PHPUnit\Framework\TestCase; |
13
|
|
|
use Symfony\Bridge\Twig\TwigEngine; |
14
|
|
|
use Symfony\Component\HttpFoundation\Response; |
15
|
|
|
use Symfony\Component\Templating\TemplateNameParser; |
16
|
|
|
use SymfonyUtil\Controller\VariadicController; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @covers \SymfonyUtil\Controller\VariadicController |
20
|
|
|
* @requires PHP 5.6.0 |
21
|
|
|
*/ |
22
|
|
|
final class VariadicControllerTest extends TestCase |
|
|
|
|
23
|
|
|
{ |
24
|
|
View Code Duplication |
public function testCanBeCreated() |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
$this->assertInstanceOf( |
27
|
|
|
// VariadicController::class, // 5.4 < php (code is checked even if not executed!) |
28
|
|
|
'SymfonyUtil\Controller\VariadicController', |
29
|
|
|
new VariadicController(new TwigEngine( |
30
|
|
|
new Twig_Environment(new Twig_Loader_Array(['index.html.twig' => 'Hello World!'])), |
|
|
|
|
31
|
|
|
new TemplateNameParser() |
32
|
|
|
)) |
33
|
|
|
); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
View Code Duplication |
public function testEmptyReturnsResponse() |
|
|
|
|
37
|
|
|
{ |
38
|
|
|
$this->assertInstanceOf( |
39
|
|
|
// Response::class, // 5.4 < php (code is checked even if not executed!) |
40
|
|
|
'Symfony\Component\HttpFoundation\Response', |
41
|
|
|
(new VariadicController(new TwigEngine( |
42
|
|
|
new Twig_Environment(new Twig_Loader_Array(['index.html.twig' => 'Hello World!'])), |
|
|
|
|
43
|
|
|
new TemplateNameParser() |
44
|
|
|
)))->__invoke() |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
View Code Duplication |
public function testArrayReturnsResponse() |
|
|
|
|
49
|
|
|
{ |
50
|
|
|
$this->assertInstanceOf( |
51
|
|
|
// Response::class, // 5.4 < php (code is checked even if not executed!) |
52
|
|
|
'Symfony\Component\HttpFoundation\Response', |
53
|
|
|
(new VariadicController(new TwigEngine( |
54
|
|
|
new Twig_Environment(new Twig_Loader_Array([ |
|
|
|
|
55
|
|
|
'index.html.twig' => '<ul>{% for item in 0 %}<li>{{ item }}</li>{% endfor %}</ul>', |
56
|
|
|
])), |
57
|
|
|
new TemplateNameParser() |
58
|
|
|
)))->__invoke([ |
59
|
|
|
'One', |
60
|
|
|
'Two', |
61
|
|
|
'Three', |
62
|
|
|
]) |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
// http://api.symfony.com/3.3/Symfony/Bridge/Twig/TwigEngine.html |
68
|
|
|
// http://api.symfony.com/3.3/Symfony/Bundle/TwigBundle/TwigEngine.html |
69
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.