diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-03 19:26:54 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-03 19:26:54 +0200 |
commit | 4f5b44bd3bd490309eb2ba7b44df4769816ba729 (patch) | |
tree | 6cefe170dfe0a5a361cb1e2d1fc4d580a3316d02 /inc/3rdparty/Twig/Test/NodeTestCase.php | |
parent | 2b840e0cfb63a453bea67a98541f3df9c273c5f5 (diff) | |
download | wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.gz wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.zst wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.zip |
twig implementation
Diffstat (limited to 'inc/3rdparty/Twig/Test/NodeTestCase.php')
-rw-r--r-- | inc/3rdparty/Twig/Test/NodeTestCase.php | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/inc/3rdparty/Twig/Test/NodeTestCase.php b/inc/3rdparty/Twig/Test/NodeTestCase.php deleted file mode 100644 index b15c85ff..00000000 --- a/inc/3rdparty/Twig/Test/NodeTestCase.php +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) Fabien Potencier | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | abstract class Twig_Test_NodeTestCase extends PHPUnit_Framework_TestCase | ||
12 | { | ||
13 | abstract public function getTests(); | ||
14 | |||
15 | /** | ||
16 | * @dataProvider getTests | ||
17 | */ | ||
18 | public function testCompile($node, $source, $environment = null) | ||
19 | { | ||
20 | $this->assertNodeCompilation($source, $node, $environment); | ||
21 | } | ||
22 | |||
23 | public function assertNodeCompilation($source, Twig_Node $node, Twig_Environment $environment = null) | ||
24 | { | ||
25 | $compiler = $this->getCompiler($environment); | ||
26 | $compiler->compile($node); | ||
27 | |||
28 | $this->assertEquals($source, trim($compiler->getSource())); | ||
29 | } | ||
30 | |||
31 | protected function getCompiler(Twig_Environment $environment = null) | ||
32 | { | ||
33 | return new Twig_Compiler(null === $environment ? $this->getEnvironment() : $environment); | ||
34 | } | ||
35 | |||
36 | protected function getEnvironment() | ||
37 | { | ||
38 | return new Twig_Environment(); | ||
39 | } | ||
40 | |||
41 | protected function getVariableGetter($name) | ||
42 | { | ||
43 | if (version_compare(phpversion(), '5.4.0RC1', '>=')) { | ||
44 | return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); | ||
45 | } | ||
46 | |||
47 | return sprintf('$this->getContext($context, "%s")', $name); | ||
48 | } | ||
49 | |||
50 | protected function getAttributeGetter() | ||
51 | { | ||
52 | if (function_exists('twig_template_get_attributes')) { | ||
53 | return 'twig_template_get_attributes($this, '; | ||
54 | } | ||
55 | |||
56 | return '$this->getAttribute('; | ||
57 | } | ||
58 | } | ||