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 /vendor/symfony/twig-bridge/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php | |
parent | 2b840e0cfb63a453bea67a98541f3df9c273c5f5 (diff) | |
download | wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.gz wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.zst wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.zip |
twig implementation
Diffstat (limited to 'vendor/symfony/twig-bridge/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php')
-rw-r--r-- | vendor/symfony/twig-bridge/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/vendor/symfony/twig-bridge/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php b/vendor/symfony/twig-bridge/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php new file mode 100644 index 00000000..077cd76a --- /dev/null +++ b/vendor/symfony/twig-bridge/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php | |||
@@ -0,0 +1,108 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Bridge\Twig\Tests\Node; | ||
13 | |||
14 | use Symfony\Bridge\Twig\Tests\TestCase; | ||
15 | use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser; | ||
16 | use Symfony\Bridge\Twig\Node\FormThemeNode; | ||
17 | |||
18 | class FormThemeTokenParserTest extends TestCase | ||
19 | { | ||
20 | protected function setUp() | ||
21 | { | ||
22 | parent::setUp(); | ||
23 | |||
24 | if (version_compare(\Twig_Environment::VERSION, '1.5.0', '<')) { | ||
25 | $this->markTestSkipped('Requires Twig version to be at least 1.5.0.'); | ||
26 | } | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * @dataProvider getTestsForFormTheme | ||
31 | */ | ||
32 | public function testCompile($source, $expected) | ||
33 | { | ||
34 | $env = new \Twig_Environment(new \Twig_Loader_String(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); | ||
35 | $env->addTokenParser(new FormThemeTokenParser()); | ||
36 | $stream = $env->tokenize($source); | ||
37 | $parser = new \Twig_Parser($env); | ||
38 | |||
39 | $this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0)); | ||
40 | } | ||
41 | |||
42 | public function getTestsForFormTheme() | ||
43 | { | ||
44 | return array( | ||
45 | array( | ||
46 | '{% form_theme form "tpl1" %}', | ||
47 | new FormThemeNode( | ||
48 | new \Twig_Node_Expression_Name('form', 1), | ||
49 | new \Twig_Node_Expression_Array(array( | ||
50 | new \Twig_Node_Expression_Constant(0, 1), | ||
51 | new \Twig_Node_Expression_Constant('tpl1', 1), | ||
52 | ), 1), | ||
53 | 1, | ||
54 | 'form_theme' | ||
55 | ) | ||
56 | ), | ||
57 | array( | ||
58 | '{% form_theme form "tpl1" "tpl2" %}', | ||
59 | new FormThemeNode( | ||
60 | new \Twig_Node_Expression_Name('form', 1), | ||
61 | new \Twig_Node_Expression_Array(array( | ||
62 | new \Twig_Node_Expression_Constant(0, 1), | ||
63 | new \Twig_Node_Expression_Constant('tpl1', 1), | ||
64 | new \Twig_Node_Expression_Constant(1, 1), | ||
65 | new \Twig_Node_Expression_Constant('tpl2', 1) | ||
66 | ), 1), | ||
67 | 1, | ||
68 | 'form_theme' | ||
69 | ) | ||
70 | ), | ||
71 | array( | ||
72 | '{% form_theme form with "tpl1" %}', | ||
73 | new FormThemeNode( | ||
74 | new \Twig_Node_Expression_Name('form', 1), | ||
75 | new \Twig_Node_Expression_Constant('tpl1', 1), | ||
76 | 1, | ||
77 | 'form_theme' | ||
78 | ) | ||
79 | ), | ||
80 | array( | ||
81 | '{% form_theme form with ["tpl1"] %}', | ||
82 | new FormThemeNode( | ||
83 | new \Twig_Node_Expression_Name('form', 1), | ||
84 | new \Twig_Node_Expression_Array(array( | ||
85 | new \Twig_Node_Expression_Constant(0, 1), | ||
86 | new \Twig_Node_Expression_Constant('tpl1', 1), | ||
87 | ), 1), | ||
88 | 1, | ||
89 | 'form_theme' | ||
90 | ) | ||
91 | ), | ||
92 | array( | ||
93 | '{% form_theme form with ["tpl1", "tpl2"] %}', | ||
94 | new FormThemeNode( | ||
95 | new \Twig_Node_Expression_Name('form', 1), | ||
96 | new \Twig_Node_Expression_Array(array( | ||
97 | new \Twig_Node_Expression_Constant(0, 1), | ||
98 | new \Twig_Node_Expression_Constant('tpl1', 1), | ||
99 | new \Twig_Node_Expression_Constant(1, 1), | ||
100 | new \Twig_Node_Expression_Constant('tpl2', 1) | ||
101 | ), 1), | ||
102 | 1, | ||
103 | 'form_theme' | ||
104 | ) | ||
105 | ), | ||
106 | ); | ||
107 | } | ||
108 | } | ||