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)
 @dataProvider 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.

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)

References $source, and getCompiler().

Referenced by testCompile().

+ 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.

64 {
65 if (function_exists('twig_template_get_attributes')) {
66 return 'twig_template_get_attributes($this, ';
67 }
68
69 return '$this->getAttribute(';
70 }

Referenced by Twig_Tests_Node_Expression_GetAttrTest\getTests().

+ 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.

39 {
40 return new Twig_Compiler(null === $environment ? $this->getEnvironment() : $environment);
41 }
Compiles a node to PHP code.
Definition: Compiler.php:19

References getEnvironment().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEnvironment()

Twig_Test_NodeTestCase::getEnvironment ( )
protected

Reimplemented in Twig_Tests_Node_Expression_FilterTest, Twig_Tests_Node_Expression_FunctionTest, and Twig_Tests_Node_Expression_TestTest.

Definition at line 43 of file NodeTestCase.php.

44 {
45 return new Twig_Environment(new Twig_Loader_Array(array()));
46 }
Stores the Twig configuration.
Definition: Environment.php:18
Loads a template from an array.
Definition: Array.php:27

Referenced by getCompiler().

+ 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.

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 }
sprintf('%.4f', $callTime)
if($format !==null) $name
Definition: metadata.php:146

References $name, and sprintf.

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

+ Here is the caller graph for this function:

◆ testCompile()

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

@dataProvider getTests

Definition at line 21 of file NodeTestCase.php.

22 {
23 $this->assertNodeCompilation($source, $node, $environment, $isPattern);
24 }
assertNodeCompilation($source, Twig_Node $node, Twig_Environment $environment=null, $isPattern=false)

References $source, and assertNodeCompilation().

+ Here is the call graph for this function:

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