|
@@ 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 |
|
{ |
|
@@ 108-116 (lines=9) @@
|
| 105 |
|
$this->assertEquals($twigTemplate->render([]), '1 minute ago'); |
| 106 |
|
} |
| 107 |
|
|
| 108 |
|
public function testStrftimeFunction() |
| 109 |
|
{ |
| 110 |
|
$twig = $this->getTwig(); |
| 111 |
|
|
| 112 |
|
$template = "{{ '2016-03-24 23:05' | strftime('%d.%m.%Y %H:%M:%S') }}"; |
| 113 |
|
|
| 114 |
|
$twigTemplate = $twig->createTemplate($template); |
| 115 |
|
$this->assertEquals($twigTemplate->render([]), '24.03.2016 23:05:00'); |
| 116 |
|
} |
| 117 |
|
|
| 118 |
|
public function testUppercaseFunction() |
| 119 |
|
{ |
|
@@ 118-126 (lines=9) @@
|
| 115 |
|
$this->assertEquals($twigTemplate->render([]), '24.03.2016 23:05:00'); |
| 116 |
|
} |
| 117 |
|
|
| 118 |
|
public function testUppercaseFunction() |
| 119 |
|
{ |
| 120 |
|
$twig = $this->getTwig(); |
| 121 |
|
|
| 122 |
|
$template = "{{ 'Jack' | uppercase }}"; |
| 123 |
|
|
| 124 |
|
$twigTemplate = $twig->createTemplate($template); |
| 125 |
|
$this->assertEquals($twigTemplate->render([]), 'JACK'); |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
public function testLowercaseFunction() |
| 129 |
|
{ |
|
@@ 128-136 (lines=9) @@
|
| 125 |
|
$this->assertEquals($twigTemplate->render([]), 'JACK'); |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
public function testLowercaseFunction() |
| 129 |
|
{ |
| 130 |
|
$twig = $this->getTwig(); |
| 131 |
|
|
| 132 |
|
$template = "{{ 'JACK' | lowercase }}"; |
| 133 |
|
|
| 134 |
|
$twigTemplate = $twig->createTemplate($template); |
| 135 |
|
$this->assertEquals($twigTemplate->render([]), 'jack'); |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
public function testUcfirstFunction() |
| 139 |
|
{ |
|
@@ 138-146 (lines=9) @@
|
| 135 |
|
$this->assertEquals($twigTemplate->render([]), 'jack'); |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
public function testUcfirstFunction() |
| 139 |
|
{ |
| 140 |
|
$twig = $this->getTwig(); |
| 141 |
|
|
| 142 |
|
$template = "{{ 'jack' | ucfirst }}"; |
| 143 |
|
|
| 144 |
|
$twigTemplate = $twig->createTemplate($template); |
| 145 |
|
$this->assertEquals($twigTemplate->render([]), 'Jack'); |
| 146 |
|
} |
| 147 |
|
|
| 148 |
|
public function testLcfirstFunction() |
| 149 |
|
{ |
|
@@ 148-156 (lines=9) @@
|
| 145 |
|
$this->assertEquals($twigTemplate->render([]), 'Jack'); |
| 146 |
|
} |
| 147 |
|
|
| 148 |
|
public function testLcfirstFunction() |
| 149 |
|
{ |
| 150 |
|
$twig = $this->getTwig(); |
| 151 |
|
|
| 152 |
|
$template = "{{ 'JACK' | lcfirst }}"; |
| 153 |
|
|
| 154 |
|
$twigTemplate = $twig->createTemplate($template); |
| 155 |
|
$this->assertEquals($twigTemplate->render([]), 'jACK'); |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
public function testLtrimFunction() |
| 159 |
|
{ |
|
@@ 158-166 (lines=9) @@
|
| 155 |
|
$this->assertEquals($twigTemplate->render([]), 'jACK'); |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
public function testLtrimFunction() |
| 159 |
|
{ |
| 160 |
|
$twig = $this->getTwig(); |
| 161 |
|
|
| 162 |
|
$template = "{{ ' jack' | ltrim }}"; |
| 163 |
|
|
| 164 |
|
$twigTemplate = $twig->createTemplate($template); |
| 165 |
|
$this->assertEquals($twigTemplate->render([]), 'jack'); |
| 166 |
|
} |
| 167 |
|
|
| 168 |
|
public function testRtrimFunction() |
| 169 |
|
{ |
|
@@ 168-176 (lines=9) @@
|
| 165 |
|
$this->assertEquals($twigTemplate->render([]), 'jack'); |
| 166 |
|
} |
| 167 |
|
|
| 168 |
|
public function testRtrimFunction() |
| 169 |
|
{ |
| 170 |
|
$twig = $this->getTwig(); |
| 171 |
|
|
| 172 |
|
$template = "{{ 'jack ' | rtrim }}"; |
| 173 |
|
|
| 174 |
|
$twigTemplate = $twig->createTemplate($template); |
| 175 |
|
$this->assertEquals($twigTemplate->render([]), 'jack'); |
| 176 |
|
} |
| 177 |
|
|
| 178 |
|
public function testStrRepeatFunction() |
| 179 |
|
{ |
|
@@ 178-186 (lines=9) @@
|
| 175 |
|
$this->assertEquals($twigTemplate->render([]), 'jack'); |
| 176 |
|
} |
| 177 |
|
|
| 178 |
|
public function testStrRepeatFunction() |
| 179 |
|
{ |
| 180 |
|
$twig = $this->getTwig(); |
| 181 |
|
|
| 182 |
|
$template = "{{ ' best' | str_repeat(3) }}"; |
| 183 |
|
|
| 184 |
|
$twigTemplate = $twig->createTemplate($template); |
| 185 |
|
$this->assertEquals($twigTemplate->render([]), ' best best best'); |
| 186 |
|
} |
| 187 |
|
|
| 188 |
|
public function testPluralFunction() |
| 189 |
|
{ |
|
@@ 198-206 (lines=9) @@
|
| 195 |
|
$this->assertEquals($twigTemplate->render([]), 'mails'); |
| 196 |
|
} |
| 197 |
|
|
| 198 |
|
public function testStrpadFunction() |
| 199 |
|
{ |
| 200 |
|
$twig = $this->getTwig(); |
| 201 |
|
|
| 202 |
|
$template = "{{ 'test' | strpad(10) }}"; |
| 203 |
|
|
| 204 |
|
$twigTemplate = $twig->createTemplate($template); |
| 205 |
|
$this->assertEquals($twigTemplate->render([]), ' test '); |
| 206 |
|
} |
| 207 |
|
|
| 208 |
|
public function testLeftpadFunction() |
| 209 |
|
{ |
|
@@ 208-216 (lines=9) @@
|
| 205 |
|
$this->assertEquals($twigTemplate->render([]), ' test '); |
| 206 |
|
} |
| 207 |
|
|
| 208 |
|
public function testLeftpadFunction() |
| 209 |
|
{ |
| 210 |
|
$twig = $this->getTwig(); |
| 211 |
|
|
| 212 |
|
$template = "{{ 'test' | leftpad(7) }}"; |
| 213 |
|
|
| 214 |
|
$twigTemplate = $twig->createTemplate($template); |
| 215 |
|
$this->assertEquals($twigTemplate->render([]), ' test'); |
| 216 |
|
} |
| 217 |
|
|
| 218 |
|
public function testRightpadFunction() |
| 219 |
|
{ |
|
@@ 238-246 (lines=9) @@
|
| 235 |
|
$this->assertContains('string(4) "test"', $twigTemplate->render([])); |
| 236 |
|
} |
| 237 |
|
|
| 238 |
|
public function testVardumpFilter() |
| 239 |
|
{ |
| 240 |
|
$twig = $this->getTwig(); |
| 241 |
|
|
| 242 |
|
$template = "{{ 'test' | var_dump }}"; |
| 243 |
|
|
| 244 |
|
$twigTemplate = $twig->createTemplate($template); |
| 245 |
|
$this->assertContains('string(4) "test"', $twigTemplate->render([])); |
| 246 |
|
} |
| 247 |
|
|
| 248 |
|
public function testConfigFunction() |
| 249 |
|
{ |
|
@@ 273-282 (lines=10) @@
|
| 270 |
|
$this->assertEquals($twigTemplate->render([]), 'test value'); |
| 271 |
|
} |
| 272 |
|
|
| 273 |
|
public function testTransFunction() |
| 274 |
|
{ |
| 275 |
|
$twig = $this->getTwig(); |
| 276 |
|
Config::set('app.locale', 'en'); |
| 277 |
|
|
| 278 |
|
$template = "{{ trans('validation.accepted') }}"; |
| 279 |
|
|
| 280 |
|
$twigTemplate = $twig->createTemplate($template); |
| 281 |
|
$this->assertEquals($twigTemplate->render([]), 'The :attribute must be accepted.'); |
| 282 |
|
} |
| 283 |
|
} |
| 284 |
|
|