]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/twig/twig/test/Twig/Tests/Node/SetTest.php
d64d671a8ee58de9df99e8359f50a7069fd7ad75
4 * This file is part of Twig.
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 class Twig_Tests_Node_SetTest
extends Twig_Test_NodeTestCase
15 * @covers Twig_Node_Set::__construct
17 public function testConstructor()
19 $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1);
20 $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 1)), array(), 1);
21 $node = new Twig_Node_Set(false, $names, $values, 1);
23 $this->assertEquals($names, $node->getNode('names'));
24 $this->assertEquals($values, $node->getNode('values'));
25 $this->assertEquals(false, $node->getAttribute('capture'));
29 * @covers Twig_Node_Set::compile
30 * @dataProvider getTests
32 public function testCompile($node, $source, $environment = null)
34 parent
::testCompile($node, $source, $environment);
37 public function getTests()
41 $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1);
42 $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 1)), array(), 1);
43 $node = new Twig_Node_Set(false, $names, $values, 1);
44 $tests[] = array($node, <<<EOF
46 \$context["foo"] = "foo";
50 $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1);
51 $values = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Constant('foo', 1), 1)), array(), 1);
52 $node = new Twig_Node_Set(true, $names, $values, 1);
53 $tests[] = array($node, <<<EOF
57 \$context["foo"] = ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());
61 $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1);
62 $values = new Twig_Node_Text('foo', 1);
63 $node = new Twig_Node_Set(true, $names, $values, 1);
64 $tests[] = array($node, <<<EOF
66 \$context["foo"] = ('' === \$tmp = "foo") ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());
70 $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1), new Twig_Node_Expression_AssignName('bar', 1)), array(), 1);
71 $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 1), new Twig_Node_Expression_Name('bar', 1)), array(), 1);
72 $node = new Twig_Node_Set(false, $names, $values, 1);
73 $tests[] = array($node, <<<EOF
75 list(\$context["foo"], \$context["bar"]) = array("foo", {$this->getVariableGetter('bar')});