29 $compiler->compile($node);
32 $this->assertStringMatchesFormat(
$source, trim($compiler->getSource()));
34 $this->assertEquals(
$source, trim($compiler->getSource()));
50 $line = $line > 0 ?
"// line {$line}\n" :
'';
52 if (PHP_VERSION_ID >= 70000) {
53 return sprintf(
'%s($context["%s"] ?? null)', $line,
$name,
$name);
56 if (PHP_VERSION_ID >= 50400) {
57 return sprintf(
'%s(isset($context["%s"]) ? $context["%s"] : null)', $line,
$name,
$name);
60 return sprintf(
'%s$this->getContext($context, "%s")', $line,
$name);
65 if (function_exists(
'twig_template_get_attributes')) {
66 return 'twig_template_get_attributes($this, ';
69 return '$this->getAttribute(';
73 class_alias(
'Twig_Test_NodeTestCase',
'Twig\Test\NodeTestCase',
false);
74 class_exists(
'Twig_Environment');
75 class_exists(
'Twig_Node');
Represents a node in the AST.
assertNodeCompilation($source, Twig_Node $node, Twig_Environment $environment=null, $isPattern=false)
testCompile($node, $source, $environment=null, $isPattern=false)
getTests
Create styles array
The data for the language used.
getVariableGetter($name, $line=false)
Stores the Twig configuration.
Loads a template from an array.
getCompiler(Twig_Environment $environment=null)