ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SetTest.php
Go to the documentation of this file.
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
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";
35EOF
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
43ob_start();
44echo "foo";
45\$context["foo"] = ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());
46EOF
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());
55EOF
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
63list(\$context["foo"], \$context["bar"]) = array("foo", {$this->getVariableGetter('bar')});
64EOF
65 );
66
67 return $tests;
68 }
69}
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92
An exception for terminatinating execution or to throw for unit testing.
Marks a content as safe.
Definition: Markup.php:18
Represents a node that outputs an expression.
Definition: Print.php:19
Represents a set node.
Definition: Set.php:18
Represents a text node.
Definition: Text.php:19
Represents a node in the AST.
Definition: Node.php:19
getVariableGetter($name, $line=false)