*/
public function testFilterBodyNodes($input, $expected)
{
- list($parser, $invoker) = $this->getParserForFilterBodyNodes();
+ $parser = $this->getParserForFilterBodyNodes();
- $this->assertEquals($expected, $invoker->invoke($parser, $input));
+ $this->assertEquals($expected, $parser->filterBodyNodes($input));
}
public function getFilterBodyNodesData()
*/
public function testFilterBodyNodesThrowsException($input)
{
- list($parser, $invoker) = $this->getParserForFilterBodyNodes();
+ $parser = $this->getParserForFilterBodyNodes();
- $invoker->invoke($parser, $input);
+ $parser->filterBodyNodes($input);
}
public function getFilterBodyNodesDataThrowsException()
protected function getParserForFilterBodyNodes()
{
- $invoker = new ReflectionMethod('Twig_Parser', 'filterBodyNodes');
- $invoker->setAccessible(true);
+ $parser = new TestParser(new Twig_Environment());
+ $parser->setParent(new Twig_Node());
+ $parser->stream = $this->getMockBuilder('Twig_TokenStream')->disableOriginalConstructor()->getMock();
- $p = new ReflectionProperty('Twig_Parser', 'stream');
- $p->setAccessible(true);
+ return $parser;
+ }
+}
- $parser = new Twig_Parser(new Twig_Environment());
- $parser->setParent(new Twig_Node());
- $p->setValue($parser, $this->getMockBuilder('Twig_TokenStream')->disableOriginalConstructor()->getMock());
+class TestParser extends Twig_Parser
+{
+ public $stream;
- return array($parser, $invoker);
+ public function filterBodyNodes(Twig_NodeInterface $node)
+ {
+ return parent::filterBodyNodes($node);
}
}