ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
IncludeTest.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  $expr = new Twig_Node_Expression_Constant('foo.twig', 1);
17  $node = new Twig_Node_Include($expr, null, false, false, 1);
18 
19  $this->assertFalse($node->hasNode('variables'));
20  $this->assertEquals($expr, $node->getNode('expr'));
21  $this->assertFalse($node->getAttribute('only'));
22 
24  $node = new Twig_Node_Include($expr, $vars, true, false, 1);
25  $this->assertEquals($vars, $node->getNode('variables'));
26  $this->assertTrue($node->getAttribute('only'));
27  }
28 
29  public function getTests()
30  {
31  $tests = array();
32 
33  $expr = new Twig_Node_Expression_Constant('foo.twig', 1);
34  $node = new Twig_Node_Include($expr, null, false, false, 1);
35  $tests[] = array($node, <<<EOF
36 // line 1
37 \$this->loadTemplate("foo.twig", null, 1)->display(\$context);
38 EOF
39  );
40 
42  new Twig_Node_Expression_Constant(true, 1),
43  new Twig_Node_Expression_Constant('foo', 1),
44  new Twig_Node_Expression_Constant('foo', 1),
45  0
46  );
47  $node = new Twig_Node_Include($expr, null, false, false, 1);
48  $tests[] = array($node, <<<EOF
49 // line 1
50 \$this->loadTemplate(((true) ? ("foo") : ("foo")), null, 1)->display(\$context);
51 EOF
52  );
53 
54  $expr = new Twig_Node_Expression_Constant('foo.twig', 1);
56  $node = new Twig_Node_Include($expr, $vars, false, false, 1);
57  $tests[] = array($node, <<<EOF
58 // line 1
59 \$this->loadTemplate("foo.twig", null, 1)->display(array_merge(\$context, array("foo" => true)));
60 EOF
61  );
62 
63  $node = new Twig_Node_Include($expr, $vars, true, false, 1);
64  $tests[] = array($node, <<<EOF
65 // line 1
66 \$this->loadTemplate("foo.twig", null, 1)->display(array("foo" => true));
67 EOF
68  );
69 
70  $node = new Twig_Node_Include($expr, $vars, true, true, 1);
71  $tests[] = array($node, <<<EOF
72 // line 1
73 try {
74  \$this->loadTemplate("foo.twig", null, 1)->display(array("foo" => true));
75 } catch (Twig_Error_Loader \$e) {
76  // ignore missing template
77 }
78 EOF
79  );
80 
81  return $tests;
82  }
83 }
Represents an include node.
Definition: Include.php:18
Exception thrown when an error occurs during template loading.
Definition: Loader.php:25
Create styles array
The data for the language used.
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92