fixed tests on PHP 5.2
authorFabien Potencier <fabien.potencier@gmail.com>
Fri, 4 Jan 2013 21:34:22 +0000 (22:34 +0100)
committerFabien Potencier <fabien.potencier@gmail.com>
Fri, 4 Jan 2013 21:34:22 +0000 (22:34 +0100)
test/Twig/Tests/Node/Expression/FilterTest.php
test/Twig/Tests/Node/Expression/FunctionTest.php
test/Twig/Tests/Node/Expression/PHP53/FilterTest.php [new file with mode: 0644]
test/Twig/Tests/Node/Expression/PHP53/FunctionTest.php [new file with mode: 0644]
test/Twig/Tests/Node/Expression/PHP53/TestTest.php [new file with mode: 0644]
test/Twig/Tests/Node/Expression/TestTest.php

index 5eb776c..a089182 100644 (file)
@@ -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();
     }
 }
index 0a69621..a4f6768 100644 (file)
@@ -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 (file)
index 0000000..15e3aa9
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+
+$env = new Twig_Environment();
+$env->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 (file)
index 0000000..d2170ed
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+
+$env = new Twig_Environment();
+$env->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 (file)
index 0000000..6366286
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+
+$env = new Twig_Environment();
+$env->addTest(new Twig_SimpleTest('anonymous', function () {}));
+
+return $env;
index 988c94e..73de448 100644 (file)
@@ -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();
     }
 }