ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
23 $vars = new Twig_Node_Expression_Array(array(new Twig_Node_Expression_Constant('foo', 1), new Twig_Node_Expression_Constant(true, 1)), 1);
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);
38EOF
39 );
40
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);
51EOF
52 );
53
54 $expr = new Twig_Node_Expression_Constant('foo.twig', 1);
55 $vars = new Twig_Node_Expression_Array(array(new Twig_Node_Expression_Constant('foo', 1), new Twig_Node_Expression_Constant(true, 1)), 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)));
60EOF
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));
67EOF
68 );
69
70 $node = new Twig_Node_Include($expr, $vars, true, true, 1);
71 $tests[] = array($node, <<<EOF
72// line 1
73try {
74 \$this->loadTemplate("foo.twig", null, 1)->display(array("foo" => true));
75} catch (Twig_Error_Loader \$e) {
76 // ignore missing template
77}
78EOF
79 );
80
81 return $tests;
82 }
83}
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.
Exception thrown when an error occurs during template loading.
Definition: Loader.php:26
Represents an include node.
Definition: Include.php:19
$tests
Definition: bench.php:104
$context
Definition: webdav.php:25