ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Twig_Tests_Node_MacroTest Class Reference
+ Inheritance diagram for Twig_Tests_Node_MacroTest:
+ Collaboration diagram for Twig_Tests_Node_MacroTest:

Public Member Functions

 testConstructor ()
 
 getTests ()
 
- Public Member Functions inherited from Twig_Test_NodeTestCase
 getTests ()
 
 testCompile ($node, $source, $environment=null, $isPattern=false)
 getTests More...
 
 assertNodeCompilation ($source, Twig_Node $node, Twig_Environment $environment=null, $isPattern=false)
 

Additional Inherited Members

- Protected Member Functions inherited from Twig_Test_NodeTestCase
 getCompiler (Twig_Environment $environment=null)
 
 getEnvironment ()
 
 getVariableGetter ($name, $line=false)
 
 getAttributeGetter ()
 

Detailed Description

Definition at line 12 of file MacroTest.php.

Member Function Documentation

◆ getTests()

Twig_Tests_Node_MacroTest::getTests ( )

Definition at line 25 of file MacroTest.php.

References EOF.

26  {
27  $body = new Twig_Node_Text('foo', 1);
28  $arguments = new Twig_Node(array(
29  'foo' => new Twig_Node_Expression_Constant(null, 1),
30  'bar' => new Twig_Node_Expression_Constant('Foo', 1),
31  ), array(), 1);
32  $node = new Twig_Node_Macro('foo', $body, $arguments, 1);
33 
34  if (PHP_VERSION_ID >= 50600) {
35  $declaration = ', ...$__varargs__';
36  $varargs = '$__varargs__';
37  } else {
38  $declaration = '';
39  $varargs = 'func_num_args() > 2 ? array_slice(func_get_args(), 2) : array()';
40  }
41 
42  return array(
43  array($node, <<<EOF
44 // line 1
45 public function getfoo(\$__foo__ = null, \$__bar__ = "Foo"$declaration)
46 {
47  \$context = \$this->env->mergeGlobals(array(
48  "foo" => \$__foo__,
49  "bar" => \$__bar__,
50  "varargs" => $varargs,
51  ));
52 
53  \$blocks = array();
54 
55  ob_start();
56  try {
57  echo "foo";
58  } catch (Exception \$e) {
59  ob_end_clean();
60 
61  throw \$e;
62  } catch (Throwable \$e) {
63  ob_end_clean();
64 
65  throw \$e;
66  }
67 
68  return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());
69 }
70 EOF
71  ),
72  );
73  }
Represents a node in the AST.
Definition: Node.php:18
Represents a macro node.
Definition: Macro.php:17
Represents a text node.
Definition: Text.php:18
Marks a content as safe.
Definition: Markup.php:17
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92

◆ testConstructor()

Twig_Tests_Node_MacroTest::testConstructor ( )

Definition at line 14 of file MacroTest.php.

15  {
16  $body = new Twig_Node_Text('foo', 1);
17  $arguments = new Twig_Node(array(new Twig_Node_Expression_Name('foo', 1)), array(), 1);
18  $node = new Twig_Node_Macro('foo', $body, $arguments, 1);
19 
20  $this->assertEquals($body, $node->getNode('body'));
21  $this->assertEquals($arguments, $node->getNode('arguments'));
22  $this->assertEquals('foo', $node->getAttribute('name'));
23  }
Represents a node in the AST.
Definition: Node.php:18
Represents a macro node.
Definition: Macro.php:17
Represents a text node.
Definition: Text.php:18

The documentation for this class was generated from the following file: