Definition at line 14 of file EnvironmentTest.php.
◆ escapingStrategyCallback()
Twig_Tests_EnvironmentTest::escapingStrategyCallback |
( |
|
$name | ) |
|
◆ getMockLoader()
Twig_Tests_EnvironmentTest::getMockLoader |
( |
|
$templateName, |
|
|
|
$templateContent |
|
) |
| |
|
protected |
◆ handleError()
Twig_Tests_EnvironmentTest::handleError |
( |
|
$type, |
|
|
|
$msg |
|
) |
| |
◆ testAddExtension()
Twig_Tests_EnvironmentTest::testAddExtension |
( |
| ) |
|
Definition at line 319 of file EnvironmentTest.php.
321 $twig =
new Twig_Environment($this->getMockBuilder(
'Twig_LoaderInterface')->getMock());
324 $this->assertArrayHasKey(
'test', $twig->getTags());
325 $this->assertArrayHasKey(
'foo_filter', $twig->getFilters());
326 $this->assertArrayHasKey(
'foo_function', $twig->getFunctions());
327 $this->assertArrayHasKey(
'foo_test', $twig->getTests());
328 $this->assertArrayHasKey(
'foo_unary', $twig->getUnaryOperators());
329 $this->assertArrayHasKey(
'foo_binary', $twig->getBinaryOperators());
330 $this->assertArrayHasKey(
'foo_global', $twig->getGlobals());
331 $visitors = $twig->getNodeVisitors();
333 foreach ($visitors as $visitor) {
338 $this->assertTrue($found);
Stores the Twig configuration.
◆ testAddExtensionWithDeprecatedGetGlobals()
Twig_Tests_EnvironmentTest::testAddExtensionWithDeprecatedGetGlobals |
( |
| ) |
|
PHP 5.3
Definition at line 344 of file EnvironmentTest.php.
References array.
346 $twig =
new Twig_Environment($this->getMockBuilder(
'Twig_LoaderInterface')->getMock());
349 $this->deprecations =
array();
350 set_error_handler(
array($this,
'handleError'));
352 $this->assertArrayHasKey(
'foo_global', $twig->getGlobals());
354 $this->assertCount(1, $this->deprecations);
355 $this->assertContains(
'Defining the getGlobals() method in the "Twig_Tests_EnvironmentTest_Extension_WithGlobals" extension ', $this->deprecations[0]);
357 restore_error_handler();
Create styles array
The data for the language used.
Stores the Twig configuration.
◆ testAddMockExtension()
Twig_Tests_EnvironmentTest::testAddMockExtension |
( |
| ) |
|
Definition at line 379 of file EnvironmentTest.php.
References $loader, array, EOF, and time.
383 $extension = eval(<<<
EOF 384 class Twig_Tests_EnvironmentTest_ExtensionInEval extends
Twig_Extension 389 $extension =
new Twig_Tests_EnvironmentTest_ExtensionInEval();
394 $twig->addExtension($extension);
396 $this->assertInstanceOf(
'Twig_ExtensionInterface', $twig->getExtension(get_class($extension)));
397 $this->assertTrue($twig->isTemplateFresh(
'page',
time()));
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
Stores the Twig configuration.
Loads a template from an array.
const EOF
How fgetc() reports an End Of File.
◆ testAddRuntimeLoader()
Twig_Tests_EnvironmentTest::testAddRuntimeLoader |
( |
| ) |
|
Definition at line 457 of file EnvironmentTest.php.
References $loader, and array.
459 $runtimeLoader = $this->getMockBuilder(
'Twig_RuntimeLoaderInterface')->getMock();
463 'func_array' =>
'{{ from_runtime_array("foo") }}',
464 'func_array_default' =>
'{{ from_runtime_array() }}',
465 'func_array_named_args' =>
'{{ from_runtime_array(name="foo") }}',
466 'func_string' =>
'{{ from_runtime_string("foo") }}',
467 'func_string_default' =>
'{{ from_runtime_string() }}',
468 'func_string_named_args' =>
'{{ from_runtime_string(name="foo") }}',
473 $twig->addRuntimeLoader($runtimeLoader);
475 $this->assertEquals(
'foo', $twig->render(
'func_array'));
476 $this->assertEquals(
'bar', $twig->render(
'func_array_default'));
477 $this->assertEquals(
'foo', $twig->render(
'func_array_named_args'));
478 $this->assertEquals(
'foo', $twig->render(
'func_string'));
479 $this->assertEquals(
'bar', $twig->render(
'func_string_default'));
480 $this->assertEquals(
'foo', $twig->render(
'func_string_named_args'));
Create styles array
The data for the language used.
Stores the Twig configuration.
Loads a template from an array.
◆ testAutoescapeOption()
Twig_Tests_EnvironmentTest::testAutoescapeOption |
( |
| ) |
|
Definition at line 50 of file EnvironmentTest.php.
References $loader, and array.
53 'html' =>
'{{ foo }} {{ foo }}',
54 'js' =>
'{{ bar }} {{ bar }}',
60 'autoescape' =>
array($this,
'escapingStrategyCallback'),
63 $this->assertEquals(
'foo<br/ > foo<br/ >', $twig->render(
'html',
array(
'foo' =>
'foo<br/ >')));
64 $this->assertEquals(
'foo\x3Cbr\x2F\x20\x3E foo\x3Cbr\x2F\x20\x3E', $twig->render(
'js',
array(
'bar' =>
'foo<br/ >')));
Create styles array
The data for the language used.
Stores the Twig configuration.
Loads a template from an array.
◆ testAutoReloadCacheHit()
Twig_Tests_EnvironmentTest::testAutoReloadCacheHit |
( |
| ) |
|
Definition at line 228 of file EnvironmentTest.php.
References $loader, array, getMockLoader(), and time.
230 $templateName = __FUNCTION__;
231 $templateContent = __FUNCTION__;
233 $cache = $this->getMockBuilder(
'Twig_CacheInterface')->getMock();
241 $cache->expects($this->once())
242 ->method(
'generateKey')
243 ->will($this->returnValue(
'key'));
244 $cache->expects($this->once())
245 ->method(
'getTimestamp')
246 ->will($this->returnValue($now));
247 $loader->expects($this->once())
249 ->will($this->returnValue(
true));
250 $cache->expects($this->atLeastOnce())
253 $twig->loadTemplate($templateName);
getMockLoader($templateName, $templateContent)
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
Stores the Twig configuration.
◆ testAutoReloadCacheMiss()
Twig_Tests_EnvironmentTest::testAutoReloadCacheMiss |
( |
| ) |
|
Definition at line 201 of file EnvironmentTest.php.
References $loader, array, and getMockLoader().
203 $templateName = __FUNCTION__;
204 $templateContent = __FUNCTION__;
206 $cache = $this->getMockBuilder(
'Twig_CacheInterface')->getMock();
212 $cache->expects($this->once())
213 ->method(
'generateKey')
214 ->will($this->returnValue(
'key'));
215 $cache->expects($this->once())
216 ->method(
'getTimestamp')
217 ->will($this->returnValue(0));
218 $loader->expects($this->never())
220 $cache->expects($this->once())
222 $cache->expects($this->once())
225 $twig->loadTemplate($templateName);
getMockLoader($templateName, $templateContent)
Create styles array
The data for the language used.
Stores the Twig configuration.
◆ testAutoReloadOutdatedCacheHit()
Twig_Tests_EnvironmentTest::testAutoReloadOutdatedCacheHit |
( |
| ) |
|
Definition at line 256 of file EnvironmentTest.php.
References $loader, array, getMockLoader(), and time.
258 $templateName = __FUNCTION__;
259 $templateContent = __FUNCTION__;
261 $cache = $this->getMockBuilder(
'Twig_CacheInterface')->getMock();
267 $cache->expects($this->once())
268 ->method(
'generateKey')
269 ->will($this->returnValue(
'key'));
270 $cache->expects($this->once())
271 ->method(
'getTimestamp')
272 ->will($this->returnValue($now));
273 $loader->expects($this->once())
275 ->will($this->returnValue(
false));
276 $cache->expects($this->once())
278 $cache->expects($this->once())
281 $twig->loadTemplate($templateName);
getMockLoader($templateName, $templateContent)
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
Stores the Twig configuration.
◆ testExtensionsAreNotInitializedWhenRenderingACompiledTemplate()
Twig_Tests_EnvironmentTest::testExtensionsAreNotInitializedWhenRenderingACompiledTemplate |
( |
| ) |
|
Definition at line 173 of file EnvironmentTest.php.
References $key, $loader, $options, $output, array, and Twig_Tests_FilesystemHelper\removeDir().
176 $options =
array(
'cache' => $cache,
'auto_reload' =>
false,
'debug' =>
false);
181 $key = $cache->generateKey(
'index', $twig->getTemplateClass(
'index'));
182 $cache->write(
$key, $twig->compileSource(
new Twig_Source(
'{{ foo }}',
'index')));
186 ->getMockBuilder(
'Twig_Environment')
188 ->setMethods(
array(
'initExtensions'))
192 $twig->expects($this->never())->method(
'initExtensions');
195 $output = $twig->render(
'index',
array(
'foo' =>
'bar'));
196 $this->assertEquals(
'bar',
$output);
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
Create styles array
The data for the language used.
Implements a cache on the filesystem.
Holds information about a non-compiled Twig template.
Stores the Twig configuration.
Loads a template from an array.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
◆ testFailLoadTemplateOnCircularReference()
Twig_Tests_EnvironmentTest::testFailLoadTemplateOnCircularReference |
( |
| ) |
|
Twig_Error_Runtime Circular reference detected for Twig template "base.html.twig", path: base.html.twig -> base.html.twig in "base.html.twig" at line 1
Definition at line 487 of file EnvironmentTest.php.
References array.
490 'base.html.twig' =>
'{% extends "base.html.twig" %}',
493 $twig->loadTemplate(
'base.html.twig');
Create styles array
The data for the language used.
Stores the Twig configuration.
Loads a template from an array.
◆ testFailLoadTemplateOnComplexCircularReference()
Twig_Tests_EnvironmentTest::testFailLoadTemplateOnComplexCircularReference |
( |
| ) |
|
Twig_Error_Runtime Circular reference detected for Twig template "base1.html.twig", path: base1.html.twig -> base2.html.twig -> base1.html.twig in "base1.html.twig" at line 1
Definition at line 500 of file EnvironmentTest.php.
References array.
503 'base1.html.twig' =>
'{% extends "base2.html.twig" %}',
504 'base2.html.twig' =>
'{% extends "base1.html.twig" %}',
507 $twig->loadTemplate(
'base1.html.twig');
Create styles array
The data for the language used.
Stores the Twig configuration.
Loads a template from an array.
◆ testGlobals()
Twig_Tests_EnvironmentTest::testGlobals |
( |
| ) |
|
Definition at line 72 of file EnvironmentTest.php.
References $loader, $template, and array.
75 $loader = $this->getMockBuilder(
'Twig_EnvironmentTestLoaderInterface')->getMock();
77 $loader->expects($this->any())->method(
'getSourceContext')->will($this->returnValue(
new Twig_Source(
'',
'')));
82 $twig->addGlobal(
'foo',
'foo');
84 $twig->addGlobal(
'foo',
'bar');
85 $globals = $twig->getGlobals();
86 $this->assertEquals(
'bar', $globals[
'foo']);
90 $twig->addGlobal(
'foo',
'foo');
92 $twig->loadTemplate(
'index');
93 $twig->addGlobal(
'foo',
'bar');
94 $globals = $twig->getGlobals();
95 $this->assertEquals(
'bar', $globals[
'foo']);
99 $twig->addGlobal(
'foo',
'foo');
101 $twig->getFunctions();
102 $twig->addGlobal(
'foo',
'bar');
103 $globals = $twig->getGlobals();
104 $this->assertEquals(
'bar', $globals[
'foo']);
109 $twig->addGlobal(
'foo',
'foo');
111 $twig->getFunctions();
112 $twig->loadTemplate(
'index');
113 $twig->addGlobal(
'foo',
'bar');
114 $globals = $twig->getGlobals();
115 $this->assertEquals(
'bar', $globals[
'foo']);
119 $twig->addGlobal(
'foo',
'bar');
120 $template = $twig->loadTemplate(
'index');
Create styles array
The data for the language used.
Holds information about a non-compiled Twig template.
Stores the Twig configuration.
Loads a template from an array.
◆ testHasGetExtensionByClassName()
Twig_Tests_EnvironmentTest::testHasGetExtensionByClassName |
( |
| ) |
|
Definition at line 305 of file EnvironmentTest.php.
307 $twig =
new Twig_Environment($this->getMockBuilder(
'Twig_LoaderInterface')->getMock());
309 $this->assertTrue($twig->hasExtension(
'Twig_Tests_EnvironmentTest_Extension'));
310 $this->assertTrue($twig->hasExtension(
'\Twig_Tests_EnvironmentTest_Extension'));
312 $this->assertSame($ext, $twig->getExtension(
'Twig_Tests_EnvironmentTest_Extension'));
313 $this->assertSame($ext, $twig->getExtension(
'\Twig_Tests_EnvironmentTest_Extension'));
315 $this->assertTrue($twig->hasExtension(
'Twig\Tests\EnvironmentTest\Extension'));
316 $this->assertSame($ext, $twig->getExtension(
'Twig\Tests\EnvironmentTest\Extension'));
Stores the Twig configuration.
◆ testHasGetExtensionWithDynamicName()
Twig_Tests_EnvironmentTest::testHasGetExtensionWithDynamicName |
( |
| ) |
|
legacy
Definition at line 287 of file EnvironmentTest.php.
289 $twig =
new Twig_Environment($this->getMockBuilder(
'Twig_LoaderInterface')->getMock());
293 $twig->addExtension($ext1);
294 $twig->addExtension($ext2);
296 $this->assertTrue($twig->hasExtension(
'ext1'));
297 $this->assertTrue($twig->hasExtension(
'ext2'));
299 $this->assertTrue($twig->hasExtension(
'Twig_Tests_EnvironmentTest_Extension_DynamicWithDeprecatedName'));
301 $this->assertSame($ext1, $twig->getExtension(
'ext1'));
302 $this->assertSame($ext2, $twig->getExtension(
'ext2'));
Stores the Twig configuration.
◆ testInitRuntimeWithAnExtensionUsingInitRuntimeDeprecation()
Twig_Tests_EnvironmentTest::testInitRuntimeWithAnExtensionUsingInitRuntimeDeprecation |
( |
| ) |
|
PHP 5.3
Definition at line 414 of file EnvironmentTest.php.
References array.
416 $twig =
new Twig_Environment($this->getMockBuilder(
'Twig_LoaderInterface')->getMock());
419 $this->deprecations =
array();
420 set_error_handler(
array($this,
'handleError'));
422 $twig->initRuntime();
424 $this->assertCount(1, $this->deprecations);
425 $this->assertContains(
'Defining the initRuntime() method in the "Twig_Tests_EnvironmentTest_ExtensionWithDeprecationInitRuntime" extension is deprecated since version 1.23.', $this->deprecations[0]);
427 restore_error_handler();
Create styles array
The data for the language used.
Stores the Twig configuration.
◆ testInitRuntimeWithAnExtensionUsingInitRuntimeNoDeprecation()
Twig_Tests_EnvironmentTest::testInitRuntimeWithAnExtensionUsingInitRuntimeNoDeprecation |
( |
| ) |
|
Definition at line 400 of file EnvironmentTest.php.
402 $twig =
new Twig_Environment($this->getMockBuilder(
'Twig_LoaderInterface')->getMock());
404 $twig->initRuntime();
408 $this->addToAssertionCount(1);
Stores the Twig configuration.
◆ testLegacyCompileSourceSignature()
Twig_Tests_EnvironmentTest::testLegacyCompileSourceSignature |
( |
| ) |
|
legacy
Definition at line 32 of file EnvironmentTest.php.
References $env, $loader, and array.
36 $this->assertContains(
'getTemplateName',
$env->compileSource(
'{{ foo }}',
'foo'));
Create styles array
The data for the language used.
Stores the Twig configuration.
Loads a template from an array.
◆ testLegacyTokenizeSignature()
Twig_Tests_EnvironmentTest::testLegacyTokenizeSignature |
( |
| ) |
|
◆ testOverrideExtension()
Twig_Tests_EnvironmentTest::testOverrideExtension |
( |
| ) |
|
PHP 5.3
Definition at line 440 of file EnvironmentTest.php.
References array.
442 $twig =
new Twig_Environment($this->getMockBuilder(
'Twig_LoaderInterface')->getMock());
445 $this->deprecations =
array();
446 set_error_handler(
array($this,
'handleError'));
451 $this->assertCount(1, $this->deprecations);
452 $this->assertContains(
'The possibility to register the same extension twice', $this->deprecations[0]);
454 restore_error_handler();
Create styles array
The data for the language used.
Stores the Twig configuration.
◆ testRemoveExtension()
Twig_Tests_EnvironmentTest::testRemoveExtension |
( |
| ) |
|
legacy
Definition at line 363 of file EnvironmentTest.php.
365 $twig =
new Twig_Environment($this->getMockBuilder(
'Twig_LoaderInterface')->getMock());
367 $twig->removeExtension(
'environment_test');
369 $this->assertArrayNotHasKey(
'test', $twig->getTags());
370 $this->assertArrayNotHasKey(
'foo_filter', $twig->getFilters());
371 $this->assertArrayNotHasKey(
'foo_function', $twig->getFunctions());
372 $this->assertArrayNotHasKey(
'foo_test', $twig->getTests());
373 $this->assertArrayNotHasKey(
'foo_unary', $twig->getUnaryOperators());
374 $this->assertArrayNotHasKey(
'foo_binary', $twig->getBinaryOperators());
375 $this->assertArrayNotHasKey(
'foo_global', $twig->getGlobals());
376 $this->assertCount(2, $twig->getNodeVisitors());
Stores the Twig configuration.
◆ testRenderNoLoader()
Twig_Tests_EnvironmentTest::testRenderNoLoader |
( |
| ) |
|
LogicException You must set a loader first.
legacy
Definition at line 44 of file EnvironmentTest.php.
References $env.
Stores the Twig configuration.
◆ $deprecations
Twig_Tests_EnvironmentTest::$deprecations = array() |
|
private |
The documentation for this class was generated from the following file: