1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
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
|
|
|
namespace Sylius\Bundle\ThemeBundle\Tests\Functional; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @author Kamil Kokot <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
final class TemplatingTest extends ThemeBundleTestCase |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @test |
21
|
|
|
* @dataProvider getBundleTemplates |
22
|
|
|
* |
23
|
|
|
* @param string $templateName |
24
|
|
|
* @param string $contents |
25
|
|
|
*/ |
26
|
|
|
public function it_renders_bundle_templates($templateName, $contents) |
27
|
|
|
{ |
28
|
|
|
$client = $this->getClient(); |
29
|
|
|
|
30
|
|
|
$crawler = $client->request('GET', '/template/'.$templateName); |
31
|
|
|
$this->assertEquals($contents, trim($crawler->text())); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return array |
|
|
|
|
36
|
|
|
*/ |
37
|
|
|
public function getBundleTemplates() |
38
|
|
|
{ |
39
|
|
|
return [ |
40
|
|
|
['TestBundle:Templating:vanillaTemplate.txt.twig', 'TestBundle:Templating:vanillaTemplate.txt.twig'], |
41
|
|
|
['TestBundle:Templating:vanillaOverriddenTemplate.txt.twig', 'TestBundle:Templating:vanillaOverriddenTemplate.txt.twig (app overridden)'], |
42
|
|
|
['TestBundle:Templating:vanillaOverriddenThemeTemplate.txt.twig', 'TestBundle:Templating:vanillaOverriddenThemeTemplate.txt.twig|sylius/first-test-theme'], |
43
|
|
|
['TestBundle:Templating:bothThemesTemplate.txt.twig', 'TestBundle:Templating:bothThemesTemplate.txt.twig|sylius/first-test-theme'], |
44
|
|
|
['TestBundle:Templating:lastThemeTemplate.txt.twig', 'TestBundle:Templating:lastThemeTemplate.txt.twig|sylius/second-test-theme'], |
45
|
|
|
]; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @test |
50
|
|
|
* @dataProvider getBundleTemplatesUsingNamespacedPaths |
51
|
|
|
* |
52
|
|
|
* @param string $templateName |
53
|
|
|
* @param string $contents |
54
|
|
|
*/ |
55
|
|
|
public function it_renders_bundle_templates_using_namespaced_paths($templateName, $contents) |
56
|
|
|
{ |
57
|
|
|
$client = $this->getClient(); |
58
|
|
|
|
59
|
|
|
$crawler = $client->request('GET', '/template/'.$templateName); |
60
|
|
|
$this->assertEquals($contents, trim($crawler->text())); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return array |
|
|
|
|
65
|
|
|
*/ |
66
|
|
|
public function getBundleTemplatesUsingNamespacedPaths() |
67
|
|
|
{ |
68
|
|
|
return [ |
69
|
|
|
['@Test/Templating/vanillaTemplate.txt.twig', 'TestBundle:Templating:vanillaTemplate.txt.twig'], |
70
|
|
|
['@Test/Templating/vanillaOverriddenTemplate.txt.twig', 'TestBundle:Templating:vanillaOverriddenTemplate.txt.twig (app overridden)'], |
71
|
|
|
['@Test/Templating/vanillaOverriddenThemeTemplate.txt.twig', 'TestBundle:Templating:vanillaOverriddenThemeTemplate.txt.twig|sylius/first-test-theme'], |
72
|
|
|
['@Test/Templating/bothThemesTemplate.txt.twig', 'TestBundle:Templating:bothThemesTemplate.txt.twig|sylius/first-test-theme'], |
73
|
|
|
['@Test/Templating/lastThemeTemplate.txt.twig', 'TestBundle:Templating:lastThemeTemplate.txt.twig|sylius/second-test-theme'], |
74
|
|
|
]; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @test |
79
|
|
|
* @dataProvider getAppTemplates |
80
|
|
|
* |
81
|
|
|
* @param string $templateName |
82
|
|
|
* @param string $contents |
83
|
|
|
*/ |
84
|
|
|
public function it_renders_application_templates($templateName, $contents) |
85
|
|
|
{ |
86
|
|
|
$client = $this->getClient(); |
87
|
|
|
|
88
|
|
|
$crawler = $client->request('GET', '/template/'.$templateName); |
89
|
|
|
$this->assertEquals($contents, trim($crawler->text())); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return array |
|
|
|
|
94
|
|
|
*/ |
95
|
|
|
public function getAppTemplates() |
96
|
|
|
{ |
97
|
|
|
return [ |
98
|
|
|
[':Templating:vanillaTemplate.txt.twig', ':Templating:vanillaTemplate.txt.twig'], |
99
|
|
|
[':Templating:bothThemesTemplate.txt.twig', ':Templating:bothThemesTemplate.txt.twig|sylius/first-test-theme'], |
100
|
|
|
[':Templating:lastThemeTemplate.txt.twig', ':Templating:lastThemeTemplate.txt.twig|sylius/second-test-theme'], |
101
|
|
|
]; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @test |
106
|
|
|
* @dataProvider getAppTemplatesUsingNamespacedPaths |
107
|
|
|
* |
108
|
|
|
* @param string $templateName |
109
|
|
|
* @param string $contents |
110
|
|
|
*/ |
111
|
|
|
public function it_renders_application_templates_using_namespaced_paths($templateName, $contents) |
112
|
|
|
{ |
113
|
|
|
$client = $this->getClient(); |
114
|
|
|
|
115
|
|
|
$crawler = $client->request('GET', '/template/'.$templateName); |
116
|
|
|
$this->assertEquals($contents, trim($crawler->text())); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return array |
|
|
|
|
121
|
|
|
*/ |
122
|
|
|
public function getAppTemplatesUsingNamespacedPaths() |
123
|
|
|
{ |
124
|
|
|
return [ |
125
|
|
|
['/Templating/vanillaTemplate.txt.twig', ':Templating:vanillaTemplate.txt.twig'], |
126
|
|
|
['/Templating/bothThemesTemplate.txt.twig', ':Templating:bothThemesTemplate.txt.twig|sylius/first-test-theme'], |
127
|
|
|
['/Templating/lastThemeTemplate.txt.twig', ':Templating:lastThemeTemplate.txt.twig|sylius/second-test-theme'], |
128
|
|
|
]; |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.