mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 19:06:40 +00:00
added some missing tests for functions/filters as static calls
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
Filters as static method calls
|
||||
--TEMPLATE--
|
||||
{{ 'foo'|static_call_string }}
|
||||
{{ 'foo'|static_call_array }}
|
||||
--DATA--
|
||||
return array('foo' => 'foo')
|
||||
--EXPECT--
|
||||
*foo*
|
||||
*foo*
|
||||
@@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
Functions as static method calls
|
||||
--TEMPLATE--
|
||||
{{ static_call_string('foo') }}
|
||||
{{ static_call_array('foo') }}
|
||||
--DATA--
|
||||
return array('foo' => 'foo')
|
||||
--EXPECT--
|
||||
*foo*
|
||||
*foo*
|
||||
@@ -141,6 +141,8 @@ class TwigTestExtension extends Twig_Extension
|
||||
new Twig_SimpleFilter('nl2br', array($this, 'nl2br'), array('pre_escape' => 'html', 'is_safe' => array('html'))),
|
||||
new Twig_SimpleFilter('escape_something', array($this, 'escape_something'), array('is_safe' => array('something'))),
|
||||
new Twig_SimpleFilter('preserves_safety', array($this, 'preserves_safety'), array('preserves_safety' => array('html'))),
|
||||
new Twig_SimpleFilter('static_call_string', 'TwigTestExtension::staticCall'),
|
||||
new Twig_SimpleFilter('static_call_array', array('TwigTestExtension', 'staticCall')),
|
||||
new Twig_SimpleFilter('*_path', array($this, 'dynamic_path')),
|
||||
new Twig_SimpleFilter('*_foo_*_bar', array($this, 'dynamic_foo')),
|
||||
);
|
||||
@@ -152,6 +154,8 @@ class TwigTestExtension extends Twig_Extension
|
||||
new Twig_SimpleFunction('§', array($this, '§Function')),
|
||||
new Twig_SimpleFunction('safe_br', array($this, 'br'), array('is_safe' => array('html'))),
|
||||
new Twig_SimpleFunction('unsafe_br', array($this, 'br')),
|
||||
new Twig_SimpleFunction('static_call_string', 'TwigTestExtension::staticCall'),
|
||||
new Twig_SimpleFunction('static_call_array', array('TwigTestExtension', 'staticCall')),
|
||||
new Twig_SimpleFunction('*_path', array($this, 'dynamic_path')),
|
||||
new Twig_SimpleFunction('*_foo_*_bar', array($this, 'dynamic_foo')),
|
||||
);
|
||||
@@ -212,6 +216,11 @@ class TwigTestExtension extends Twig_Extension
|
||||
return strtoupper($value);
|
||||
}
|
||||
|
||||
public static function staticCall($value)
|
||||
{
|
||||
return "*$value*";
|
||||
}
|
||||
|
||||
public function br()
|
||||
{
|
||||
return '<br />';
|
||||
|
||||
Reference in New Issue
Block a user