mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-18 05:16:30 +00:00
fixed tests on PHP 5.2
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
$env = new Twig_Environment();
|
||||
$env->addFilter(new Twig_SimpleFilter('anonymous', function () {}));
|
||||
|
||||
return $env;
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
$env = new Twig_Environment();
|
||||
$env->addFunction(new Twig_SimpleFunction('anonymous', function () {}));
|
||||
|
||||
return $env;
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
$env = new Twig_Environment();
|
||||
$env->addTest(new Twig_SimpleTest('anonymous', function () {}));
|
||||
|
||||
return $env;
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user