ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Twig_Test_NodeTestCase Class Reference
+ Inheritance diagram for Twig_Test_NodeTestCase:
+ Collaboration diagram for Twig_Test_NodeTestCase:

Public Member Functions

 getTests ()
 
 testCompile ($node, $source, $environment=null, $isPattern=false)
 getTests More...
 
 assertNodeCompilation ($source, Twig_Node $node, Twig_Environment $environment=null, $isPattern=false)
 

Protected Member Functions

 getCompiler (Twig_Environment $environment=null)
 
 getEnvironment ()
 
 getVariableGetter ($name, $line=false)
 
 getAttributeGetter ()
 

Detailed Description

Definition at line 14 of file NodeTestCase.php.

Member Function Documentation

◆ assertNodeCompilation()

Twig_Test_NodeTestCase::assertNodeCompilation (   $source,
Twig_Node  $node,
Twig_Environment  $environment = null,
  $isPattern = false 
)

Definition at line 26 of file NodeTestCase.php.

References $source, and getCompiler().

Referenced by testCompile().

27  {
28  $compiler = $this->getCompiler($environment);
29  $compiler->compile($node);
30 
31  if ($isPattern) {
32  $this->assertStringMatchesFormat($source, trim($compiler->getSource()));
33  } else {
34  $this->assertEquals($source, trim($compiler->getSource()));
35  }
36  }
$source
Definition: linkback.php:22
getCompiler(Twig_Environment $environment=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAttributeGetter()

Twig_Test_NodeTestCase::getAttributeGetter ( )
protected

Definition at line 63 of file NodeTestCase.php.

Referenced by Twig_Tests_Node_Expression_GetAttrTest\getTests().

64  {
65  if (function_exists('twig_template_get_attributes')) {
66  return 'twig_template_get_attributes($this, ';
67  }
68 
69  return '$this->getAttribute(';
70  }
+ Here is the caller graph for this function:

◆ getCompiler()

Twig_Test_NodeTestCase::getCompiler ( Twig_Environment  $environment = null)
protected

Definition at line 38 of file NodeTestCase.php.

References getEnvironment().

Referenced by assertNodeCompilation(), Twig_Tests_Node_Expression_FilterTest\testCompileWithMissingNamedArgument(), and Twig_Tests_Node_Expression_FilterTest\testCompileWithWrongNamedArgumentName().

39  {
40  return new Twig_Compiler(null === $environment ? $this->getEnvironment() : $environment);
41  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEnvironment()

Twig_Test_NodeTestCase::getEnvironment ( )
protected

Definition at line 43 of file NodeTestCase.php.

References array.

Referenced by getCompiler().

44  {
45  return new Twig_Environment(new Twig_Loader_Array(array()));
46  }
Create styles array
The data for the language used.
Stores the Twig configuration.
Definition: Environment.php:17
Loads a template from an array.
Definition: Array.php:26
+ Here is the caller graph for this function:

◆ getTests()

Twig_Test_NodeTestCase::getTests ( )
abstract

◆ getVariableGetter()

Twig_Test_NodeTestCase::getVariableGetter (   $name,
  $line = false 
)
protected

Definition at line 48 of file NodeTestCase.php.

References $name.

Referenced by Twig_Tests_Node_Expression_NameTest\getTests(), Twig_Tests_Node_SetTest\getTests(), Twig_Tests_Node_Expression_GetAttrTest\getTests(), Twig_Tests_Node_IfTest\getTests(), Twig_Tests_Node_TransTest\getTests(), and Twig_Tests_Node_ForTest\getTests().

49  {
50  $line = $line > 0 ? "// line {$line}\n" : '';
51 
52  if (PHP_VERSION_ID >= 70000) {
53  return sprintf('%s($context["%s"] ?? null)', $line, $name, $name);
54  }
55 
56  if (PHP_VERSION_ID >= 50400) {
57  return sprintf('%s(isset($context["%s"]) ? $context["%s"] : null)', $line, $name, $name);
58  }
59 
60  return sprintf('%s$this->getContext($context, "%s")', $line, $name);
61  }
if($format !==null) $name
Definition: metadata.php:146
+ Here is the caller graph for this function:

◆ testCompile()

Twig_Test_NodeTestCase::testCompile (   $node,
  $source,
  $environment = null,
  $isPattern = false 
)

getTests

Definition at line 21 of file NodeTestCase.php.

References $source, and assertNodeCompilation().

22  {
23  $this->assertNodeCompilation($source, $node, $environment, $isPattern);
24  }
assertNodeCompilation($source, Twig_Node $node, Twig_Environment $environment=null, $isPattern=false)
$source
Definition: linkback.php:22
+ Here is the call graph for this function:

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