@@ 25-34 (lines=10) @@ | ||
22 | return App::make('twig.environment'); |
|
23 | } |
|
24 | ||
25 | public function testTemplateFromStringFunction() |
|
26 | { |
|
27 | $twig = $this->getTwig(); |
|
28 | ||
29 | $template = "{% set name = 'John' %}"; |
|
30 | $template .= '{{ include(template_from_string("Hello {{ name }}")) }}'; |
|
31 | ||
32 | $twigTemplate = $twig->createTemplate($template); |
|
33 | $this->assertEquals($twigTemplate->render([]), 'Hello John'); |
|
34 | } |
|
35 | ||
36 | public function testTruncateFilterForFive() |
|
37 | { |
|
@@ 46-54 (lines=9) @@ | ||
43 | $this->assertEquals($twigTemplate->render([]), 'Gordo...'); |
|
44 | } |
|
45 | ||
46 | public function testTruncateFilterForDefault() |
|
47 | { |
|
48 | $twig = $this->getTwig(); |
|
49 | ||
50 | $template = "{{ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit' | truncate }}"; |
|
51 | ||
52 | $twigTemplate = $twig->createTemplate($template); |
|
53 | $this->assertEquals($twigTemplate->render([]), 'Lorem ipsum dolor sit amet, co...'); |
|
54 | } |
|
55 | ||
56 | public function testTruncateFilterWithSeparator() |
|
57 | { |
|
@@ 66-74 (lines=9) @@ | ||
63 | $this->assertEquals($twigTemplate->render([]), 'Gordo-'); |
|
64 | } |
|
65 | ||
66 | public function testWordWrapFilter() |
|
67 | { |
|
68 | $twig = $this->getTwig(); |
|
69 | ||
70 | $template = "{{ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit' | wordwrap(10) }}"; |
|
71 | ||
72 | $twigTemplate = $twig->createTemplate($template); |
|
73 | $this->assertEquals($twigTemplate->render([]), "Lorem ipsu\nm dolor si\nt amet, co\nnsectetur \nadipiscing\n elit"); |
|
74 | } |
|
75 | ||
76 | public function testShuffleFilter() |
|
77 | { |
|
@@ 99-107 (lines=9) @@ | ||
96 | $this->assertEquals($twigTemplate->render([]), '1 minute ago'); |
|
97 | } |
|
98 | ||
99 | public function testStrftimeFunction() |
|
100 | { |
|
101 | $twig = $this->getTwig(); |
|
102 | ||
103 | $template = "{{ '2016-03-24 23:05' | strftime('%d.%m.%Y %H:%M:%S') }}"; |
|
104 | ||
105 | $twigTemplate = $twig->createTemplate($template); |
|
106 | $this->assertEquals($twigTemplate->render([]), '24.03.2016 23:05:00'); |
|
107 | } |
|
108 | ||
109 | public function testUppercaseFunction() |
|
110 | { |
|
@@ 109-117 (lines=9) @@ | ||
106 | $this->assertEquals($twigTemplate->render([]), '24.03.2016 23:05:00'); |
|
107 | } |
|
108 | ||
109 | public function testUppercaseFunction() |
|
110 | { |
|
111 | $twig = $this->getTwig(); |
|
112 | ||
113 | $template = "{{ 'Jack' | uppercase }}"; |
|
114 | ||
115 | $twigTemplate = $twig->createTemplate($template); |
|
116 | $this->assertEquals($twigTemplate->render([]), 'JACK'); |
|
117 | } |
|
118 | ||
119 | public function testLowercaseFunction() |
|
120 | { |
|
@@ 119-127 (lines=9) @@ | ||
116 | $this->assertEquals($twigTemplate->render([]), 'JACK'); |
|
117 | } |
|
118 | ||
119 | public function testLowercaseFunction() |
|
120 | { |
|
121 | $twig = $this->getTwig(); |
|
122 | ||
123 | $template = "{{ 'JACK' | lowercase }}"; |
|
124 | ||
125 | $twigTemplate = $twig->createTemplate($template); |
|
126 | $this->assertEquals($twigTemplate->render([]), 'jack'); |
|
127 | } |
|
128 | ||
129 | public function testUcfirstFunction() |
|
130 | { |
|
@@ 129-137 (lines=9) @@ | ||
126 | $this->assertEquals($twigTemplate->render([]), 'jack'); |
|
127 | } |
|
128 | ||
129 | public function testUcfirstFunction() |
|
130 | { |
|
131 | $twig = $this->getTwig(); |
|
132 | ||
133 | $template = "{{ 'jack' | ucfirst }}"; |
|
134 | ||
135 | $twigTemplate = $twig->createTemplate($template); |
|
136 | $this->assertEquals($twigTemplate->render([]), 'Jack'); |
|
137 | } |
|
138 | ||
139 | public function testLcfirstFunction() |
|
140 | { |
|
@@ 139-147 (lines=9) @@ | ||
136 | $this->assertEquals($twigTemplate->render([]), 'Jack'); |
|
137 | } |
|
138 | ||
139 | public function testLcfirstFunction() |
|
140 | { |
|
141 | $twig = $this->getTwig(); |
|
142 | ||
143 | $template = "{{ 'JACK' | lcfirst }}"; |
|
144 | ||
145 | $twigTemplate = $twig->createTemplate($template); |
|
146 | $this->assertEquals($twigTemplate->render([]), 'jACK'); |
|
147 | } |
|
148 | ||
149 | public function testLtrimFunction() |
|
150 | { |
|
@@ 149-157 (lines=9) @@ | ||
146 | $this->assertEquals($twigTemplate->render([]), 'jACK'); |
|
147 | } |
|
148 | ||
149 | public function testLtrimFunction() |
|
150 | { |
|
151 | $twig = $this->getTwig(); |
|
152 | ||
153 | $template = "{{ ' jack' | ltrim }}"; |
|
154 | ||
155 | $twigTemplate = $twig->createTemplate($template); |
|
156 | $this->assertEquals($twigTemplate->render([]), 'jack'); |
|
157 | } |
|
158 | ||
159 | public function testRtrimFunction() |
|
160 | { |
|
@@ 159-167 (lines=9) @@ | ||
156 | $this->assertEquals($twigTemplate->render([]), 'jack'); |
|
157 | } |
|
158 | ||
159 | public function testRtrimFunction() |
|
160 | { |
|
161 | $twig = $this->getTwig(); |
|
162 | ||
163 | $template = "{{ 'jack ' | rtrim }}"; |
|
164 | ||
165 | $twigTemplate = $twig->createTemplate($template); |
|
166 | $this->assertEquals($twigTemplate->render([]), 'jack'); |
|
167 | } |
|
168 | ||
169 | public function testStrRepeatFunction() |
|
170 | { |
|
@@ 169-177 (lines=9) @@ | ||
166 | $this->assertEquals($twigTemplate->render([]), 'jack'); |
|
167 | } |
|
168 | ||
169 | public function testStrRepeatFunction() |
|
170 | { |
|
171 | $twig = $this->getTwig(); |
|
172 | ||
173 | $template = "{{ ' best' | str_repeat(3) }}"; |
|
174 | ||
175 | $twigTemplate = $twig->createTemplate($template); |
|
176 | $this->assertEquals($twigTemplate->render([]), ' best best best'); |
|
177 | } |
|
178 | ||
179 | public function testPluralFunction() |
|
180 | { |
|
@@ 189-197 (lines=9) @@ | ||
186 | $this->assertEquals($twigTemplate->render([]), 'mails'); |
|
187 | } |
|
188 | ||
189 | public function testStrpadFunction() |
|
190 | { |
|
191 | $twig = $this->getTwig(); |
|
192 | ||
193 | $template = "{{ 'test' | strpad(10) }}"; |
|
194 | ||
195 | $twigTemplate = $twig->createTemplate($template); |
|
196 | $this->assertEquals($twigTemplate->render([]), ' test '); |
|
197 | } |
|
198 | ||
199 | public function testLeftpadFunction() |
|
200 | { |
|
@@ 199-207 (lines=9) @@ | ||
196 | $this->assertEquals($twigTemplate->render([]), ' test '); |
|
197 | } |
|
198 | ||
199 | public function testLeftpadFunction() |
|
200 | { |
|
201 | $twig = $this->getTwig(); |
|
202 | ||
203 | $template = "{{ 'test' | leftpad(7) }}"; |
|
204 | ||
205 | $twigTemplate = $twig->createTemplate($template); |
|
206 | $this->assertEquals($twigTemplate->render([]), ' test'); |
|
207 | } |
|
208 | ||
209 | public function testRightpadFunction() |
|
210 | { |