From bac4974e250491685448e85491792e23cec6a898 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 8 Aug 2011 23:00:24 +0200 Subject: [PATCH] changed unit tests so that they work for PHP 5.2 --- test/Twig/Tests/ParserTest.php | 28 ++++++++++++++++------------ 1 files changed, 16 insertions(+), 12 deletions(-) diff --git a/test/Twig/Tests/ParserTest.php b/test/Twig/Tests/ParserTest.php index e82433a..614a867 100644 --- a/test/Twig/Tests/ParserTest.php +++ b/test/Twig/Tests/ParserTest.php @@ -24,9 +24,9 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase */ 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() @@ -49,9 +49,9 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase */ public function testFilterBodyNodesThrowsException($input) { - list($parser, $invoker) = $this->getParserForFilterBodyNodes(); + $parser = $this->getParserForFilterBodyNodes(); - $invoker->invoke($parser, $input); + $parser->filterBodyNodes($input); } public function getFilterBodyNodesDataThrowsException() @@ -64,16 +64,20 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase 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); } } -- 1.7.2.5