mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 20:06:31 +00:00
fix BC, revert to pre 1.23 behavior, and make use of pattern an option
This commit is contained in:
@@ -15,17 +15,21 @@ abstract class Twig_Test_NodeTestCase extends PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* @dataProvider getTests
|
* @dataProvider getTests
|
||||||
*/
|
*/
|
||||||
public function testCompile($node, $source, $environment = null)
|
public function testCompile($node, $source, $environment = null, $isPattern = false)
|
||||||
{
|
{
|
||||||
$this->assertNodeCompilation($source, $node, $environment);
|
$this->assertNodeCompilation($source, $node, $environment, $isPattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function assertNodeCompilation($source, Twig_Node $node, Twig_Environment $environment = null)
|
public function assertNodeCompilation($source, Twig_Node $node, Twig_Environment $environment = null, $isPattern = false)
|
||||||
{
|
{
|
||||||
$compiler = $this->getCompiler($environment);
|
$compiler = $this->getCompiler($environment);
|
||||||
$compiler->compile($node);
|
$compiler->compile($node);
|
||||||
|
|
||||||
$this->assertStringMatchesFormat($source, trim($compiler->getSource()));
|
if ($isPattern) {
|
||||||
|
$this->assertStringMatchesFormat($source, trim($compiler->getSource()));
|
||||||
|
} else {
|
||||||
|
$this->assertEquals($source, trim($compiler->getSource()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getCompiler(Twig_Environment $environment = null)
|
protected function getCompiler(Twig_Environment $environment = null)
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class __TwigTemplate_%x extends Twig_Template
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
, $twig);
|
, $twig, true);
|
||||||
|
|
||||||
$import = new Twig_Node_Import(new Twig_Node_Expression_Constant('foo.twig', 1), new Twig_Node_Expression_AssignName('macro', 1), 2);
|
$import = new Twig_Node_Import(new Twig_Node_Expression_Constant('foo.twig', 1), new Twig_Node_Expression_AssignName('macro', 1), 2);
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ class __TwigTemplate_%x extends Twig_Template
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
, $twig);
|
, $twig, true);
|
||||||
|
|
||||||
$set = new Twig_Node_Set(false, new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 4))), new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 4))), 4);
|
$set = new Twig_Node_Set(false, new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 4))), new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 4))), 4);
|
||||||
$body = new Twig_Node(array($set));
|
$body = new Twig_Node(array($set));
|
||||||
@@ -176,7 +176,7 @@ class __TwigTemplate_%x extends Twig_Template
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
, $twig);
|
, $twig, true);
|
||||||
|
|
||||||
return $tests;
|
return $tests;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user