16 $path = dirname(__FILE__).
'/../Fixtures';
18 $this->assertEquals(
'errors/index.html',
$loader->getSourceContext(
'errors/index.html')->getName());
19 $this->assertEquals(realpath(
$path.
'/errors/index.html'), realpath(
$loader->getSourceContext(
'errors/index.html')->getPath()));
33 $this->assertNotContains(
'Unable to find template', $e->getMessage());
40 array(
"AutoloaderTest\0.php"),
41 array(
'..\\AutoloaderTest.php'),
42 array(
'..\\\\\\AutoloaderTest.php'),
43 array(
'../AutoloaderTest.php'),
44 array(
'..////AutoloaderTest.php'),
45 array(
'./../AutoloaderTest.php'),
46 array(
'.\\..\\AutoloaderTest.php'),
47 array(
'././././././../AutoloaderTest.php'),
48 array(
'.\\./.\\./.\\./../AutoloaderTest.php'),
49 array(
'foo/../../AutoloaderTest.php'),
50 array(
'foo\\..\\..\\AutoloaderTest.php'),
51 array(
'foo/../bar/../../AutoloaderTest.php'),
52 array(
'foo/bar/../../../AutoloaderTest.php'),
53 array(
'filters/../../AutoloaderTest.php'),
54 array(
'filters//..//..//AutoloaderTest.php'),
55 array(
'filters\\..\\..\\AutoloaderTest.php'),
56 array(
'filters\\\\..\\\\..\\\\AutoloaderTest.php'),
57 array(
'filters\\//../\\/\\..\\AutoloaderTest.php'),
58 array(
'/../AutoloaderTest.php'),
65 public function testPaths($basePath, $cacheKey, $rootPath)
68 $loader->setPaths(
array($basePath.
'/named', $basePath.
'/named_bis'),
'named');
69 $loader->addPath($basePath.
'/named_ter',
'named');
70 $loader->addPath($basePath.
'/normal_ter');
71 $loader->prependPath($basePath.
'/normal_final');
72 $loader->prependPath($basePath.
'/named/../named_quater',
'named');
73 $loader->prependPath($basePath.
'/named_final',
'named');
75 $this->assertEquals(
array(
76 $basePath.
'/normal_final',
78 $basePath.
'/normal_bis',
79 $basePath.
'/normal_ter',
81 $this->assertEquals(
array(
82 $basePath.
'/named_final',
83 $basePath.
'/named/../named_quater',
85 $basePath.
'/named_bis',
86 $basePath.
'/named_ter',
90 $this->assertEquals($cacheKey, str_replace(
'\\',
'/',
$loader->getCacheKey(
'@named/named_absolute.html')));
91 $this->assertEquals(
"path (final)\n",
$loader->getSourceContext(
'index.html')->getCode());
92 $this->assertEquals(
"path (final)\n",
$loader->getSourceContext(
'@__main__/index.html')->getCode());
93 $this->assertEquals(
"named path (final)\n",
$loader->getSourceContext(
'@named/index.html')->getCode());
100 dirname(__FILE__).
'/Fixtures',
101 'test/Twig/Tests/Loader/Fixtures/named_quater/named_absolute.html',
105 dirname(__FILE__).
'/Fixtures/../Fixtures',
106 'test/Twig/Tests/Loader/Fixtures/named_quater/named_absolute.html',
110 'test/Twig/Tests/Loader/Fixtures',
111 'test/Twig/Tests/Loader/Fixtures/named_quater/named_absolute.html',
116 'Fixtures/named_quater/named_absolute.html',
117 getcwd().
'/test/Twig/Tests/Loader',
121 'Fixtures/named_quater/named_absolute.html',
122 getcwd().
'/test/../test/Twig/Tests/Loader',
138 $loader->addPath(sys_get_temp_dir(),
'named');
144 $basePath = dirname(__FILE__).
'/Fixtures';
147 $loader->addPath($basePath.
'/named',
'named');
150 $loader->getSourceContext(
'@named/nowhere.html');
152 $this->assertInstanceof(
'Twig_Error_Loader', $e);
153 $this->assertContains(
'Unable to find template "@named/nowhere.html"', $e->getMessage());
159 $basePath = dirname(__FILE__).
'/Fixtures';
162 $loader->addPath($basePath.
'/named',
'named');
165 $namedSource =
$loader->getSourceContext(
'@named/index.html')->getCode();
166 $this->assertEquals(
"named path\n", $namedSource);
169 $this->assertEquals(
"path\n",
$loader->getSourceContext(
'index.html')->getCode());
175 $loader->addPath(dirname(__FILE__).
'/Fixtures/themes/theme2');
176 $loader->addPath(dirname(__FILE__).
'/Fixtures/themes/theme1');
177 $loader->addPath(dirname(__FILE__).
'/Fixtures/themes/theme1',
'default_theme');
181 $template = $twig->loadTemplate(
'blocks.html.twig');
182 $this->assertSame(
'block from theme 1',
$template->renderBlock(
'b1',
array()));
184 $template = $twig->loadTemplate(
'blocks.html.twig');
185 $this->assertSame(
'block from theme 2', $template->renderBlock(
'b2',
array()));
191 'valid array inheritance' =>
array(
'array_inheritance_valid_parent.html.twig'),
192 'array inheritance with null first template' =>
array(
'array_inheritance_null_parent.html.twig'),
193 'array inheritance with empty first template' =>
array(
'array_inheritance_empty_parent.html.twig'),
194 'array inheritance with non-existent first template' =>
array(
'array_inheritance_nonexistent_parent.html.twig'),
206 $loader->addPath(dirname(__FILE__).
'/Fixtures/inheritance');
210 $template = $twig->loadTemplate($templateName);
211 $this->assertSame(
'VALID Child',
$template->renderBlock(
'body',
array()));
223 $loader->addPath(
'phar://'.dirname(__FILE__).
'/Fixtures/phar/phar-sample.phar');
224 $this->assertSame(
'hello from phar',
$loader->getSourceContext(
'hello.twig')->getCode());
testFindTemplateWithCache()
testLoadTemplateAndRenderBlockWithCache()
Exception thrown when an error occurs during template loading.
testLoadTemplateFromPhar()
PHP 5.3
Loads template from the filesystem.
testSecurity($template)
getSecurityTests
testPaths($basePath, $cacheKey, $rootPath)
getBasePaths
testFindTemplateExceptionNamespace()
Create styles array
The data for the language used.
getArrayInheritanceTests()
const MAIN_NAMESPACE
Identifier of the main namespace.
Stores the Twig configuration.
testArrayInheritance($templateName)
getArrayInheritanceTests