mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 11:27:00 +00:00
removed usage of deprecated features, marked some tests as being legacy
This commit is contained in:
@@ -35,7 +35,7 @@ abstract class Twig_Test_NodeTestCase extends PHPUnit_Framework_TestCase
|
||||
|
||||
protected function getEnvironment()
|
||||
{
|
||||
return new Twig_Environment();
|
||||
return new Twig_Environment(new Twig_Loader_Array(array()));
|
||||
}
|
||||
|
||||
protected function getVariableGetter($name, $line = false)
|
||||
|
||||
@@ -13,7 +13,7 @@ class Twig_Tests_CompilerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testReprNumericValueWithLocale()
|
||||
{
|
||||
$compiler = new Twig_Compiler(new Twig_Environment());
|
||||
$compiler = new Twig_Compiler(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
|
||||
$locale = setlocale(LC_NUMERIC, 0);
|
||||
if (false === $locale) {
|
||||
|
||||
@@ -15,7 +15,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
|
||||
* @expectedException LogicException
|
||||
* @expectedExceptionMessage You must set a loader first.
|
||||
*/
|
||||
public function testRenderNoLoader()
|
||||
public function testLegacyRenderNoLoader()
|
||||
{
|
||||
$env = new Twig_Environment();
|
||||
$env->render('test');
|
||||
@@ -182,7 +182,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('Twig_Tests_EnvironmentTest_NodeVisitor', get_class($visitors[2]));
|
||||
}
|
||||
|
||||
public function testRemoveExtension()
|
||||
public function testLegacyRemoveExtension()
|
||||
{
|
||||
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
|
||||
$twig->addExtension(new Twig_Tests_EnvironmentTest_Extension());
|
||||
|
||||
@@ -16,7 +16,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testRandomFunction($value, $expectedInArray)
|
||||
{
|
||||
$env = new Twig_Environment();
|
||||
$env = new Twig_Environment(new Twig_Loader_Array(array()));
|
||||
|
||||
for ($i = 0; $i < 100; ++$i) {
|
||||
$this->assertTrue(in_array(twig_random($env, $value), $expectedInArray, true)); // assertContains() would not consider the type
|
||||
@@ -62,18 +62,18 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
|
||||
$max = mt_getrandmax();
|
||||
|
||||
for ($i = 0; $i < 100; ++$i) {
|
||||
$val = twig_random(new Twig_Environment());
|
||||
$val = twig_random(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$this->assertTrue(is_int($val) && $val >= 0 && $val <= $max);
|
||||
}
|
||||
}
|
||||
|
||||
public function testRandomFunctionReturnsAsIs()
|
||||
{
|
||||
$this->assertSame('', twig_random(new Twig_Environment(), ''));
|
||||
$this->assertSame('', twig_random(new Twig_Environment(null, array('charset' => null)), ''));
|
||||
$this->assertSame('', twig_random(new Twig_Environment(new Twig_Loader_Array(array())), ''));
|
||||
$this->assertSame('', twig_random(new Twig_Environment(new Twig_Loader_Array(array()), array('charset' => null)), ''));
|
||||
|
||||
$instance = new stdClass();
|
||||
$this->assertSame($instance, twig_random(new Twig_Environment(), $instance));
|
||||
$this->assertSame($instance, twig_random(new Twig_Environment(new Twig_Loader_Array(array())), $instance));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testRandomFunctionOfEmptyArrayThrowsException()
|
||||
{
|
||||
twig_random(new Twig_Environment(), array());
|
||||
twig_random(new Twig_Environment(new Twig_Loader_Array(array())), array());
|
||||
}
|
||||
|
||||
public function testRandomFunctionOnNonUTF8String()
|
||||
@@ -90,7 +90,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
|
||||
$this->markTestSkipped('needs iconv or mbstring');
|
||||
}
|
||||
|
||||
$twig = new Twig_Environment();
|
||||
$twig = new Twig_Environment(new Twig_Loader_Array(array()));
|
||||
$twig->setCharset('ISO-8859-1');
|
||||
|
||||
$text = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8');
|
||||
@@ -106,7 +106,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
|
||||
$this->markTestSkipped('needs iconv or mbstring');
|
||||
}
|
||||
|
||||
$twig = new Twig_Environment();
|
||||
$twig = new Twig_Environment(new Twig_Loader_Array(array()));
|
||||
$twig->setCharset('ISO-8859-1');
|
||||
|
||||
$input = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8');
|
||||
@@ -117,7 +117,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testCustomEscaper()
|
||||
{
|
||||
$twig = new Twig_Environment();
|
||||
$twig = new Twig_Environment(new Twig_Loader_Array(array()));
|
||||
$twig->getExtension('core')->setEscaper('foo', 'foo_escaper_for_test');
|
||||
|
||||
$this->assertEquals('fooUTF-8', twig_escape_filter($twig, 'foo', 'foo'));
|
||||
@@ -128,12 +128,12 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testUnknownCustomEscaper()
|
||||
{
|
||||
twig_escape_filter(new Twig_Environment(), 'foo', 'bar');
|
||||
twig_escape_filter(new Twig_Environment(new Twig_Loader_Array(array())), 'foo', 'bar');
|
||||
}
|
||||
|
||||
public function testTwigFirst()
|
||||
{
|
||||
$twig = new Twig_Environment();
|
||||
$twig = new Twig_Environment(new Twig_Loader_Array(array()));
|
||||
$this->assertEquals('a', twig_first($twig, 'abc'));
|
||||
$this->assertEquals(1, twig_first($twig, array(1, 2, 3)));
|
||||
$this->assertSame('', twig_first($twig, null));
|
||||
@@ -142,7 +142,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testTwigLast()
|
||||
{
|
||||
$twig = new Twig_Environment();
|
||||
$twig = new Twig_Environment(new Twig_Loader_Array(array()));
|
||||
$this->assertEquals('c', twig_last($twig, 'abc'));
|
||||
$this->assertEquals(3, twig_last($twig, array(1, 2, 3)));
|
||||
$this->assertSame('', twig_last($twig, null));
|
||||
|
||||
@@ -163,7 +163,7 @@ class Twig_Tests_Extension_SandboxTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testMacrosInASandbox()
|
||||
{
|
||||
$twig = $this->getEnvironment(true, array('autoescape' => true), array('index' => <<<EOF
|
||||
$twig = $this->getEnvironment(true, array('autoescape' => 'html'), array('index' => <<<EOF
|
||||
{%- import _self as macros %}
|
||||
|
||||
{%- macro test(text) %}<p>{{ text }}</p>{% endmacro %}
|
||||
|
||||
@@ -14,7 +14,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$template = '{% § %}';
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$stream = $lexer->tokenize($template);
|
||||
|
||||
$stream->expect(Twig_Token::BLOCK_START_TYPE);
|
||||
@@ -25,7 +25,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$template = '{{ §() }}';
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$stream = $lexer->tokenize($template);
|
||||
|
||||
$stream->expect(Twig_Token::VAR_START_TYPE);
|
||||
@@ -42,7 +42,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
protected function countToken($template, $type, $value = null)
|
||||
{
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$stream = $lexer->tokenize($template);
|
||||
|
||||
$count = 0;
|
||||
@@ -67,7 +67,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
."baz\n"
|
||||
."}}\n";
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$stream = $lexer->tokenize($template);
|
||||
|
||||
// foo\nbar\n
|
||||
@@ -87,7 +87,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
."baz\n"
|
||||
."}}\n";
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$stream = $lexer->tokenize($template);
|
||||
|
||||
// foo\nbar
|
||||
@@ -102,17 +102,17 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$template = '{# '.str_repeat('*', 100000).' #}';
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$lexer->tokenize($template);
|
||||
|
||||
// should not throw an exception
|
||||
}
|
||||
|
||||
public function testLongRaw()
|
||||
public function testLongVerbatim()
|
||||
{
|
||||
$template = '{% verbatim %}'.str_repeat('*', 100000).'{% endverbatim %}';
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$lexer->tokenize($template);
|
||||
|
||||
// should not throw an exception
|
||||
@@ -122,7 +122,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$template = '{{ '.str_repeat('x', 100000).' }}';
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$lexer->tokenize($template);
|
||||
|
||||
// should not throw an exception
|
||||
@@ -132,7 +132,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$template = '{% '.str_repeat('x', 100000).' %}';
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$lexer->tokenize($template);
|
||||
|
||||
// should not throw an exception
|
||||
@@ -142,7 +142,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$template = '{{ 922337203685477580700 }}';
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$stream = $lexer->tokenize($template);
|
||||
$stream->next();
|
||||
$node = $stream->next();
|
||||
@@ -155,7 +155,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
"{{ 'foo \' bar' }}" => 'foo \' bar',
|
||||
'{{ "foo \" bar" }}' => 'foo " bar',
|
||||
);
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
foreach ($tests as $template => $expected) {
|
||||
$stream = $lexer->tokenize($template);
|
||||
$stream->expect(Twig_Token::VAR_START_TYPE);
|
||||
@@ -167,7 +167,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$template = 'foo {{ "bar #{ baz + 1 }" }}';
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$stream = $lexer->tokenize($template);
|
||||
$stream->expect(Twig_Token::TEXT_TYPE, 'foo ');
|
||||
$stream->expect(Twig_Token::VAR_START_TYPE);
|
||||
@@ -184,7 +184,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$template = '{{ "bar \#{baz+1}" }}';
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$stream = $lexer->tokenize($template);
|
||||
$stream->expect(Twig_Token::VAR_START_TYPE);
|
||||
$stream->expect(Twig_Token::STRING_TYPE, 'bar #{baz+1}');
|
||||
@@ -195,7 +195,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$template = '{{ "bar # baz" }}';
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$stream = $lexer->tokenize($template);
|
||||
$stream->expect(Twig_Token::VAR_START_TYPE);
|
||||
$stream->expect(Twig_Token::STRING_TYPE, 'bar # baz');
|
||||
@@ -210,7 +210,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$template = '{{ "bar #{x" }}';
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$lexer->tokenize($template);
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$template = '{{ "bar #{ "foo#{bar}" }" }}';
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$stream = $lexer->tokenize($template);
|
||||
$stream->expect(Twig_Token::VAR_START_TYPE);
|
||||
$stream->expect(Twig_Token::STRING_TYPE, 'bar ');
|
||||
@@ -235,7 +235,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$template = '{% foo "bar #{ "foo#{bar}" }" %}';
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$stream = $lexer->tokenize($template);
|
||||
$stream->expect(Twig_Token::BLOCK_START_TYPE);
|
||||
$stream->expect(Twig_Token::NAME_TYPE, 'foo');
|
||||
@@ -253,7 +253,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$template = "{{ 1 and\n0}}";
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$stream = $lexer->tokenize($template);
|
||||
$stream->expect(Twig_Token::VAR_START_TYPE);
|
||||
$stream->expect(Twig_Token::NUMBER_TYPE, 1);
|
||||
@@ -275,7 +275,7 @@ bar
|
||||
|
||||
';
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$lexer->tokenize($template);
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ bar
|
||||
|
||||
';
|
||||
|
||||
$lexer = new Twig_Lexer(new Twig_Environment());
|
||||
$lexer = new Twig_Lexer(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$lexer->tokenize($template);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase
|
||||
|
||||
public function getTests()
|
||||
{
|
||||
$environment = new Twig_Environment();
|
||||
$environment = new Twig_Environment(new Twig_Loader_Array(array()));
|
||||
$environment->addFilter(new Twig_SimpleFilter('bar', 'bar', array('needs_environment' => true)));
|
||||
$environment->addFilter(new Twig_SimpleFilter('barbar', 'twig_tests_filter_barbar', array('needs_context' => true, 'is_variadic' => true)));
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase
|
||||
|
||||
public function getTests()
|
||||
{
|
||||
$environment = new Twig_Environment();
|
||||
$environment = new Twig_Environment(new Twig_Loader_Array(array()));
|
||||
$environment->addFunction(new Twig_SimpleFunction('foo', 'foo', array()));
|
||||
$environment->addFunction(new Twig_SimpleFunction('bar', 'bar', array('needs_environment' => true)));
|
||||
$environment->addFunction(new Twig_SimpleFunction('foofoo', 'foofoo', array('needs_context' => true)));
|
||||
|
||||
@@ -23,8 +23,8 @@ class Twig_Tests_Node_Expression_NameTest extends Twig_Test_NodeTestCase
|
||||
$node = new Twig_Node_Expression_Name('foo', 1);
|
||||
$context = new Twig_Node_Expression_Name('_context', 1);
|
||||
|
||||
$env = new Twig_Environment(null, array('strict_variables' => true));
|
||||
$env1 = new Twig_Environment(null, array('strict_variables' => false));
|
||||
$env = new Twig_Environment(new Twig_Loader_Array(array()), array('strict_variables' => true));
|
||||
$env1 = new Twig_Environment(new Twig_Loader_Array(array()), array('strict_variables' => false));
|
||||
|
||||
return array(
|
||||
array($node, "// line 1\n".(PHP_VERSION_ID >= 50400 ? '(isset($context["foo"]) ? $context["foo"] : $this->getContext($context, "foo"))' : '$this->getContext($context, "foo")'), $env),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$env = new Twig_Environment();
|
||||
$env = new Twig_Environment(new Twig_Loader_Array(array()));
|
||||
$env->addFilter(new Twig_SimpleFilter('anonymous', function () {}));
|
||||
|
||||
return $env;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$env = new Twig_Environment();
|
||||
$env = new Twig_Environment(new Twig_Loader_Array(array()));
|
||||
$env->addFunction(new Twig_SimpleFunction('anonymous', function () {}));
|
||||
|
||||
return $env;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$env = new Twig_Environment();
|
||||
$env = new Twig_Environment(new Twig_Loader_Array(array()));
|
||||
$env->addTest(new Twig_SimpleTest('anonymous', function () {}));
|
||||
|
||||
return $env;
|
||||
|
||||
@@ -25,7 +25,7 @@ class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase
|
||||
|
||||
public function getTests()
|
||||
{
|
||||
$environment = new Twig_Environment();
|
||||
$environment = new Twig_Environment(new Twig_Loader_Array(array()));
|
||||
$environment->addTest(new Twig_SimpleTest('barbar', 'twig_tests_test_barbar', array('is_variadic' => true, 'need_context' => true)));
|
||||
|
||||
$tests = array();
|
||||
|
||||
@@ -31,7 +31,7 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase
|
||||
new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 1),
|
||||
new Twig_Token(Twig_Token::EOF_TYPE, '', 1),
|
||||
));
|
||||
$parser = new Twig_Parser(new Twig_Environment());
|
||||
$parser = new Twig_Parser(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$parser->parse($stream);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testParseIsReentrant()
|
||||
{
|
||||
$twig = new Twig_Environment(null, array(
|
||||
$twig = new Twig_Environment(new Twig_Loader_Array(array()), array(
|
||||
'autoescape' => false,
|
||||
'optimizations' => 0,
|
||||
));
|
||||
@@ -120,7 +120,7 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase
|
||||
// see https://github.com/symfony/symfony/issues/4218
|
||||
public function testGetVarName()
|
||||
{
|
||||
$twig = new Twig_Environment(null, array(
|
||||
$twig = new Twig_Environment(new Twig_Loader_Array(array()), array(
|
||||
'autoescape' => false,
|
||||
'optimizations' => 0,
|
||||
));
|
||||
@@ -137,7 +137,7 @@ EOF
|
||||
|
||||
protected function getParser()
|
||||
{
|
||||
$parser = new TestParser(new Twig_Environment());
|
||||
$parser = new TestParser(new Twig_Environment(new Twig_Loader_Array(array())));
|
||||
$parser->setParent(new Twig_Node());
|
||||
$parser->stream = $this->getMockBuilder('Twig_TokenStream')->disableOriginalConstructor()->getMock();
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetAttributeWithSandbox($object, $item, $allowed, $useExt)
|
||||
{
|
||||
$twig = new Twig_Environment();
|
||||
$twig = new Twig_Environment(new Twig_Loader_Array(array()));
|
||||
$policy = new Twig_Sandbox_SecurityPolicy(array(), array(), array(/*method*/), array(/*prop*/), array());
|
||||
$twig->addExtension(new Twig_Extension_Sandbox($policy, !$allowed));
|
||||
$template = new Twig_TemplateTest($twig, $useExt);
|
||||
@@ -133,8 +133,8 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetAttributeWithTemplateAsObject($useExt)
|
||||
{
|
||||
$template = new Twig_TemplateTest(new Twig_Environment(), $useExt);
|
||||
$template1 = new Twig_TemplateTest(new Twig_Environment(), false);
|
||||
$template = new Twig_TemplateTest(new Twig_Environment(new Twig_Loader_Array(array())), $useExt);
|
||||
$template1 = new Twig_TemplateTest(new Twig_Environment(new Twig_Loader_Array(array())), false);
|
||||
|
||||
$this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'string'));
|
||||
$this->assertEquals('some_string', $template->getAttribute($template1, 'string'));
|
||||
@@ -173,7 +173,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||
public function testGetAttributeOnArrayWithConfusableKey($useExt = false)
|
||||
{
|
||||
$template = new Twig_TemplateTest(
|
||||
new Twig_Environment(),
|
||||
new Twig_Environment(new Twig_Loader_Array(array())),
|
||||
$useExt
|
||||
);
|
||||
|
||||
@@ -212,7 +212,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetAttribute($defined, $value, $object, $item, $arguments, $type, $useExt = false)
|
||||
{
|
||||
$template = new Twig_TemplateTest(new Twig_Environment(), $useExt);
|
||||
$template = new Twig_TemplateTest(new Twig_Environment(new Twig_Loader_Array(array())), $useExt);
|
||||
|
||||
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
|
||||
}
|
||||
@@ -222,7 +222,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetAttributeStrict($defined, $value, $object, $item, $arguments, $type, $useExt = false, $exceptionMessage = null)
|
||||
{
|
||||
$template = new Twig_TemplateTest(new Twig_Environment(null, array('strict_variables' => true)), $useExt);
|
||||
$template = new Twig_TemplateTest(new Twig_Environment(new Twig_Loader_Array(array()), array('strict_variables' => true)), $useExt);
|
||||
|
||||
if ($defined) {
|
||||
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
|
||||
@@ -244,7 +244,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetAttributeDefined($defined, $value, $object, $item, $arguments, $type, $useExt = false)
|
||||
{
|
||||
$template = new Twig_TemplateTest(new Twig_Environment(), $useExt);
|
||||
$template = new Twig_TemplateTest(new Twig_Environment(new Twig_Loader_Array(array())), $useExt);
|
||||
|
||||
$this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
|
||||
}
|
||||
@@ -254,7 +254,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetAttributeDefinedStrict($defined, $value, $object, $item, $arguments, $type, $useExt = false)
|
||||
{
|
||||
$template = new Twig_TemplateTest(new Twig_Environment(null, array('strict_variables' => true)), $useExt);
|
||||
$template = new Twig_TemplateTest(new Twig_Environment(new Twig_Loader_Array(array()), array('strict_variables' => true)), $useExt);
|
||||
|
||||
$this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
|
||||
}
|
||||
@@ -264,7 +264,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetAttributeCallExceptions($useExt = false)
|
||||
{
|
||||
$template = new Twig_TemplateTest(new Twig_Environment(), $useExt);
|
||||
$template = new Twig_TemplateTest(new Twig_Environment(new Twig_Loader_Array(array())), $useExt);
|
||||
|
||||
$object = new Twig_TemplateMagicMethodExceptionObject();
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->env = new Twig_Environment();
|
||||
$this->env = new Twig_Environment(new Twig_Loader_Array(array()));
|
||||
}
|
||||
|
||||
public function testHtmlEscapingConvertsSpecialChars()
|
||||
|
||||
Reference in New Issue
Block a user