From: Fabien Potencier Date: Fri, 4 Jan 2013 21:34:22 +0000 (+0100) Subject: fixed tests on PHP 5.2 X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=84504c3c39dca2bc999d4fba63e57a66013994e3;p=web%2Fkonrad%2Ftwig.git fixed tests on PHP 5.2 --- diff --git a/test/Twig/Tests/Node/Expression/FilterTest.php b/test/Twig/Tests/Node/Expression/FilterTest.php index 5eb776c..a089182 100644 --- a/test/Twig/Tests/Node/Expression/FilterTest.php +++ b/test/Twig/Tests/Node/Expression/FilterTest.php @@ -76,8 +76,10 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase $tests[] = array($node, 'twig_reverse_filter($this->env, "abc", true)'); // filter as an anonymous function - $node = $this->createFilter(new Twig_Node_Expression_Constant('foo', 1), 'anonymous'); - $tests[] = array($node, 'call_user_func_array($this->env->getFilter(\'anonymous\')->getCallable(), array("foo"))'); + if (version_compare(phpversion(), '5.3.0', '>=')) { + $node = $this->createFilter(new Twig_Node_Expression_Constant('foo', 1), 'anonymous'); + $tests[] = array($node, 'call_user_func_array($this->env->getFilter(\'anonymous\')->getCallable(), array("foo"))'); + } return $tests; } @@ -122,9 +124,10 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase protected function getEnvironment() { - $env = parent::getEnvironment(); - $env->addFilter(new Twig_SimpleFilter('anonymous', function () {})); + if (version_compare(phpversion(), '5.3.0', '>=')) { + return include 'PHP53/FilterTest.php'; + } - return $env; + return parent::getEnvironment(); } } diff --git a/test/Twig/Tests/Node/Expression/FunctionTest.php b/test/Twig/Tests/Node/Expression/FunctionTest.php index 0a69621..a4f6768 100644 --- a/test/Twig/Tests/Node/Expression/FunctionTest.php +++ b/test/Twig/Tests/Node/Expression/FunctionTest.php @@ -75,8 +75,10 @@ class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase $tests[] = array($node, 'twig_date_converter($this->env, 0, "America/Chicago")'); // function as an anonymous function - $node = $this->createFunction('anonymous', array(new Twig_Node_Expression_Constant('foo', 1))); - $tests[] = array($node, 'call_user_func_array($this->env->getFunction(\'anonymous\')->getCallable(), array("foo"))'); + if (version_compare(phpversion(), '5.3.0', '>=')) { + $node = $this->createFunction('anonymous', array(new Twig_Node_Expression_Constant('foo', 1))); + $tests[] = array($node, 'call_user_func_array($this->env->getFunction(\'anonymous\')->getCallable(), array("foo"))'); + } return $tests; } @@ -88,9 +90,10 @@ class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase protected function getEnvironment() { - $env = parent::getEnvironment(); - $env->addFunction(new Twig_SimpleFunction('anonymous', function () {})); + if (version_compare(phpversion(), '5.3.0', '>=')) { + return include 'PHP53/FunctionTest.php'; + } - return $env; + return parent::getEnvironment(); } } diff --git a/test/Twig/Tests/Node/Expression/PHP53/FilterTest.php b/test/Twig/Tests/Node/Expression/PHP53/FilterTest.php new file mode 100644 index 0000000..15e3aa9 --- /dev/null +++ b/test/Twig/Tests/Node/Expression/PHP53/FilterTest.php @@ -0,0 +1,6 @@ +addFilter(new Twig_SimpleFilter('anonymous', function () {})); + +return $env; diff --git a/test/Twig/Tests/Node/Expression/PHP53/FunctionTest.php b/test/Twig/Tests/Node/Expression/PHP53/FunctionTest.php new file mode 100644 index 0000000..d2170ed --- /dev/null +++ b/test/Twig/Tests/Node/Expression/PHP53/FunctionTest.php @@ -0,0 +1,6 @@ +addFunction(new Twig_SimpleFunction('anonymous', function () {})); + +return $env; diff --git a/test/Twig/Tests/Node/Expression/PHP53/TestTest.php b/test/Twig/Tests/Node/Expression/PHP53/TestTest.php new file mode 100644 index 0000000..6366286 --- /dev/null +++ b/test/Twig/Tests/Node/Expression/PHP53/TestTest.php @@ -0,0 +1,6 @@ +addTest(new Twig_SimpleTest('anonymous', function () {})); + +return $env; diff --git a/test/Twig/Tests/Node/Expression/TestTest.php b/test/Twig/Tests/Node/Expression/TestTest.php index 988c94e..73de448 100644 --- a/test/Twig/Tests/Node/Expression/TestTest.php +++ b/test/Twig/Tests/Node/Expression/TestTest.php @@ -44,8 +44,10 @@ class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase $tests[] = array($node, '(null === "foo")'); // test as an anonymous function - $node = $this->createTest(new Twig_Node_Expression_Constant('foo', 1), 'anonymous', array(new Twig_Node_Expression_Constant('foo', 1))); - $tests[] = array($node, 'call_user_func_array($this->env->getTest(\'anonymous\')->getCallable(), array("foo", "foo"))'); + if (version_compare(phpversion(), '5.3.0', '>=')) { + $node = $this->createTest(new Twig_Node_Expression_Constant('foo', 1), 'anonymous', array(new Twig_Node_Expression_Constant('foo', 1))); + $tests[] = array($node, 'call_user_func_array($this->env->getTest(\'anonymous\')->getCallable(), array("foo", "foo"))'); + } return $tests; } @@ -57,9 +59,10 @@ class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase protected function getEnvironment() { - $env = parent::getEnvironment(); - $env->addTest(new Twig_SimpleTest('anonymous', function () {})); + if (version_compare(phpversion(), '5.3.0', '>=')) { + return include 'PHP53/TestTest.php'; + } - return $env; + return parent::getEnvironment(); } }