Security update for Core, with self-updated composer
[yaffs-website] / vendor / twig / twig / test / Twig / Tests / Node / SetTest.php
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
12 class Twig_Tests_Node_SetTest extends Twig_Test_NodeTestCase
13 {
14     public function testConstructor()
15     {
16         $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1);
17         $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 1)), array(), 1);
18         $node = new Twig_Node_Set(false, $names, $values, 1);
19
20         $this->assertEquals($names, $node->getNode('names'));
21         $this->assertEquals($values, $node->getNode('values'));
22         $this->assertFalse($node->getAttribute('capture'));
23     }
24
25     public function getTests()
26     {
27         $tests = array();
28
29         $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1);
30         $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 1)), array(), 1);
31         $node = new Twig_Node_Set(false, $names, $values, 1);
32         $tests[] = array($node, <<<EOF
33 // line 1
34 \$context["foo"] = "foo";
35 EOF
36         );
37
38         $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1);
39         $values = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Constant('foo', 1), 1)), array(), 1);
40         $node = new Twig_Node_Set(true, $names, $values, 1);
41         $tests[] = array($node, <<<EOF
42 // line 1
43 ob_start();
44 echo "foo";
45 \$context["foo"] = ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());
46 EOF
47         );
48
49         $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1);
50         $values = new Twig_Node_Text('foo', 1);
51         $node = new Twig_Node_Set(true, $names, $values, 1);
52         $tests[] = array($node, <<<EOF
53 // line 1
54 \$context["foo"] = ('' === \$tmp = "foo") ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());
55 EOF
56         );
57
58         $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1), new Twig_Node_Expression_AssignName('bar', 1)), array(), 1);
59         $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 1), new Twig_Node_Expression_Name('bar', 1)), array(), 1);
60         $node = new Twig_Node_Set(false, $names, $values, 1);
61         $tests[] = array($node, <<<EOF
62 // line 1
63 list(\$context["foo"], \$context["bar"]) = array("foo", {$this->getVariableGetter('bar')});
64 EOF
65         );
66
67         return $tests;
68     }
69 }