Fixed all deprecation notices by using

This commit is contained in:
Sam Mousa
2016-07-25 11:46:22 +00:00
committed by Fabien Potencier
parent c535bc0b56
commit 17e0caa91a
15 changed files with 98 additions and 97 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ class Twig_Tests_CompilerTest extends PHPUnit_Framework_TestCase
{
public function testReprNumericValueWithLocale()
{
$compiler = new Twig_Compiler(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
$compiler = new Twig_Compiler(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$locale = setlocale(LC_NUMERIC, 0);
if (false === $locale) {
+20 -19
View File
@@ -51,7 +51,8 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
public function testGlobals()
{
// globals can be added after calling getGlobals
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$twig->addGlobal('foo', 'foo');
$twig->getGlobals();
$twig->addGlobal('foo', 'bar');
@@ -59,7 +60,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
$this->assertEquals('bar', $globals['foo']);
// globals can be modified after a template has been loaded
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$twig->addGlobal('foo', 'foo');
$twig->getGlobals();
$twig->loadTemplate('index');
@@ -68,7 +69,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
$this->assertEquals('bar', $globals['foo']);
// globals can be modified after extensions init
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$twig->addGlobal('foo', 'foo');
$twig->getGlobals();
$twig->getFunctions();
@@ -94,7 +95,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
/* to be uncomment in Twig 2.0
// globals cannot be added after a template has been loaded
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$twig->addGlobal('foo', 'foo');
$twig->getGlobals();
$twig->loadTemplate('index');
@@ -106,7 +107,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
}
// globals cannot be added after extensions init
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$twig->addGlobal('foo', 'foo');
$twig->getGlobals();
$twig->getFunctions();
@@ -118,7 +119,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
}
// globals cannot be added after extensions and a template has been loaded
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$twig->addGlobal('foo', 'foo');
$twig->getGlobals();
$twig->getFunctions();
@@ -131,7 +132,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
}
// test adding globals after a template has been loaded without call to getGlobals
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$twig->loadTemplate('index');
try {
$twig->addGlobal('bar', 'bar');
@@ -144,7 +145,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
public function testCompileSourceInlinesSource()
{
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$source = "<? */*foo*/ ?>\r\nbar\n";
$expected = "/* <? *//* *foo*//* ?>*/\n/* bar*/\n/* */\n";
@@ -187,7 +188,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
$templateName = __FUNCTION__;
$templateContent = __FUNCTION__;
$cache = $this->getMock('Twig_CacheInterface');
$cache = $this->getMockBuilder('Twig_CacheInterface')->getMock();
$loader = $this->getMockLoader($templateName, $templateContent);
$twig = new Twig_Environment($loader, array('cache' => $cache, 'auto_reload' => true, 'debug' => false));
@@ -212,7 +213,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
$templateName = __FUNCTION__;
$templateContent = __FUNCTION__;
$cache = $this->getMock('Twig_CacheInterface');
$cache = $this->getMockBuilder('Twig_CacheInterface')->getMock();
$loader = $this->getMockLoader($templateName, $templateContent);
$twig = new Twig_Environment($loader, array('cache' => $cache, 'auto_reload' => true, 'debug' => false));
@@ -240,7 +241,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
$templateName = __FUNCTION__;
$templateContent = __FUNCTION__;
$cache = $this->getMock('Twig_CacheInterface');
$cache = $this->getMockBuilder('Twig_CacheInterface')->getMock();
$loader = $this->getMockLoader($templateName, $templateContent);
$twig = new Twig_Environment($loader, array('cache' => $cache, 'auto_reload' => true, 'debug' => false));
@@ -263,7 +264,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
public function testAddExtension()
{
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$twig->addExtension(new Twig_Tests_EnvironmentTest_Extension());
$this->assertArrayHasKey('test', $twig->getTags());
@@ -282,7 +283,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
*/
public function testAddExtensionWithDeprecatedGetGlobals()
{
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$twig->addExtension(new Twig_Tests_EnvironmentTest_Extension_WithGlobals());
$this->deprecations = array();
@@ -301,7 +302,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
*/
public function testRemoveExtension()
{
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$twig->addExtension(new Twig_Tests_EnvironmentTest_Extension());
$twig->removeExtension('environment_test');
@@ -317,7 +318,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
public function testAddMockExtension()
{
$extension = $this->getMock('Twig_ExtensionInterface');
$extension = $this->getMockBuilder('Twig_ExtensionInterface')->getMock();
$extension->expects($this->once())
->method('getName')
->will($this->returnValue('mock'));
@@ -333,7 +334,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
public function testInitRuntimeWithAnExtensionUsingInitRuntimeNoDeprecation()
{
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$twig->addExtension(new Twig_Tests_EnvironmentTest_ExtensionWithoutDeprecationInitRuntime());
$twig->initRuntime();
@@ -344,7 +345,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
*/
public function testInitRuntimeWithAnExtensionUsingInitRuntimeDeprecation()
{
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$twig->addExtension(new Twig_Tests_EnvironmentTest_ExtensionWithDeprecationInitRuntime());
$this->deprecations = array();
@@ -370,7 +371,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
*/
public function testOverrideExtension()
{
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$twig->addExtension(new Twig_Tests_EnvironmentTest_ExtensionWithDeprecationInitRuntime());
$this->deprecations = array();
@@ -387,7 +388,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
protected function getMockLoader($templateName, $templateContent)
{
$loader = $this->getMock('Twig_LoaderInterface');
$loader = $this->getMockBuilder('Twig_LoaderInterface')->getMock();
$loader->expects($this->any())
->method('getSource')
->with($templateName)
+16 -16
View File
@@ -17,7 +17,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testCanOnlyAssignToNames($template)
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$parser = new Twig_Parser($env);
$parser->parse($env->tokenize($template, 'index'));
@@ -46,7 +46,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testArrayExpression($template, $expected)
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$stream = $env->tokenize($template, 'index');
$parser = new Twig_Parser($env);
@@ -59,7 +59,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testArraySyntaxError($template)
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$parser = new Twig_Parser($env);
$parser->parse($env->tokenize($template, 'index'));
@@ -154,7 +154,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testStringExpressionDoesNotConcatenateTwoConsecutiveStrings()
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$stream = $env->tokenize('{{ "a" "b" }}', 'index');
$parser = new Twig_Parser($env);
@@ -166,7 +166,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testStringExpression($template, $expected)
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$stream = $env->tokenize($template, 'index');
$parser = new Twig_Parser($env);
@@ -225,7 +225,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testAttributeCallDoesNotSupportNamedArguments()
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$parser = new Twig_Parser($env);
$parser->parse($env->tokenize('{{ foo.bar(name="Foo") }}', 'index'));
@@ -236,7 +236,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testMacroCallDoesNotSupportNamedArguments()
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$parser = new Twig_Parser($env);
$parser->parse($env->tokenize('{% from _self import foo %}{% macro foo() %}{% endmacro %}{{ foo(name="Foo") }}', 'index'));
@@ -248,7 +248,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testMacroDefinitionDoesNotSupportNonNameVariableName()
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$parser = new Twig_Parser($env);
$parser->parse($env->tokenize('{% macro foo("a") %}{% endmacro %}', 'index'));
@@ -261,7 +261,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testMacroDefinitionDoesNotSupportNonConstantDefaultValues($template)
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$parser = new Twig_Parser($env);
$parser->parse($env->tokenize($template, 'index'));
@@ -280,7 +280,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testMacroDefinitionSupportsConstantDefaultValues($template)
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$parser = new Twig_Parser($env);
$parser->parse($env->tokenize($template, 'index'));
@@ -305,7 +305,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testUnknownFunction()
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$parser = new Twig_Parser($env);
$parser->parse($env->tokenize('{{ cycl() }}', 'index'));
@@ -317,7 +317,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testUnknownFunctionWithoutSuggestions()
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$parser = new Twig_Parser($env);
$parser->parse($env->tokenize('{{ foobar() }}', 'index'));
@@ -329,7 +329,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testUnknownFilter()
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$parser = new Twig_Parser($env);
$parser->parse($env->tokenize('{{ 1|lowe }}', 'index'));
@@ -341,7 +341,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testUnknownFilterWithoutSuggestions()
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$parser = new Twig_Parser($env);
$parser->parse($env->tokenize('{{ 1|foobar }}', 'index'));
@@ -353,7 +353,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testUnknownTest()
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$parser = new Twig_Parser($env);
$parser->parse($env->tokenize('{{ 1 is nul }}', 'index'));
@@ -365,7 +365,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
*/
public function testUnknownTestWithoutSuggestions()
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$parser = new Twig_Parser($env);
$parser->parse($env->tokenize('{{ 1 is foobar }}', 'index'));
+12 -12
View File
@@ -16,7 +16,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
*/
public function testRandomFunction($value, $expectedInArray)
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
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($this->getMock('Twig_LoaderInterface')));
$val = twig_random(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertTrue(is_int($val) && $val >= 0 && $val <= $max);
}
}
public function testRandomFunctionReturnsAsIs()
{
$this->assertSame('', twig_random(new Twig_Environment($this->getMock('Twig_LoaderInterface')), ''));
$this->assertSame('', twig_random(new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('charset' => null)), ''));
$this->assertSame('', twig_random(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), ''));
$this->assertSame('', twig_random(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('charset' => null)), ''));
$instance = new stdClass();
$this->assertSame($instance, twig_random(new Twig_Environment($this->getMock('Twig_LoaderInterface')), $instance));
$this->assertSame($instance, twig_random(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), $instance));
}
/**
@@ -81,7 +81,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
*/
public function testRandomFunctionOfEmptyArrayThrowsException()
{
twig_random(new Twig_Environment($this->getMock('Twig_LoaderInterface')), array());
twig_random(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), 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($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$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($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$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($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$twig->getExtension('core')->setEscaper('foo', 'foo_escaper_for_test');
$this->assertEquals('fooUTF-8', twig_escape_filter($twig, 'foo', 'foo'));
@@ -130,12 +130,12 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
*/
public function testUnknownCustomEscaper()
{
twig_escape_filter(new Twig_Environment($this->getMock('Twig_LoaderInterface')), 'foo', 'bar');
twig_escape_filter(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), 'foo', 'bar');
}
public function testTwigFirst()
{
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$this->assertEquals('a', twig_first($twig, 'abc'));
$this->assertEquals(1, twig_first($twig, array(1, 2, 3)));
$this->assertSame('', twig_first($twig, null));
@@ -144,7 +144,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
public function testTwigLast()
{
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$this->assertEquals('c', twig_last($twig, 'abc'));
$this->assertEquals(3, twig_last($twig, array(1, 2, 3)));
$this->assertSame('', twig_last($twig, null));
+20 -20
View File
@@ -14,7 +14,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
{
$template = '{% § %}';
$lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$stream = $lexer->tokenize($template);
// foo\nbar
@@ -102,7 +102,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
{
$template = '{# '.str_repeat('*', 100000).' #}';
$lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$lexer->tokenize($template);
// should not throw an exception
@@ -112,7 +112,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
{
$template = '{% verbatim %}'.str_repeat('*', 100000).'{% endverbatim %}';
$lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$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($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$lexer->tokenize($template);
}
@@ -294,7 +294,7 @@ bar
';
$lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$lexer->tokenize($template);
}
}
+2 -2
View File
@@ -63,11 +63,11 @@ class Twig_Tests_Loader_ChainTest extends PHPUnit_Framework_TestCase
public function testExists()
{
$loader1 = $this->getMock('Twig_Loader_Array', array('exists', 'getSource'), array(), '', false);
$loader1 = $this->getMockBuilder('Twig_Loader_Array')->setMethods(array('exists', 'getSource'))->disableOriginalConstructor()->getMock();
$loader1->expects($this->once())->method('exists')->will($this->returnValue(false));
$loader1->expects($this->never())->method('getSource');
$loader2 = $this->getMock('Twig_LoaderInterface');
$loader2 = $this->getMockBuilder('Twig_LoaderInterface')->getMock();
$loader2->expects($this->once())->method('getSource')->will($this->returnValue('content'));
$loader = new Twig_Loader_Chain();
@@ -25,7 +25,7 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase
public function getTests()
{
$environment = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$environment = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$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($this->getMock('Twig_LoaderInterface'));
$environment = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$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)));
+2 -2
View File
@@ -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($this->getMock('Twig_LoaderInterface'), array('strict_variables' => true));
$env1 = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('strict_variables' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true));
$env1 = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), 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 -1
View File
@@ -25,7 +25,7 @@ class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase
public function getTests()
{
$environment = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$environment = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$environment->addTest(new Twig_SimpleTest('barbar', 'twig_tests_test_barbar', array('is_variadic' => true, 'need_context' => true)));
$tests = array();
+1 -1
View File
@@ -30,7 +30,7 @@ class Twig_Tests_Node_ModuleTest extends Twig_Test_NodeTestCase
public function getTests()
{
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$tests = array();
@@ -12,7 +12,7 @@ class Twig_Tests_NodeVisitor_OptimizerTest extends PHPUnit_Framework_TestCase
{
public function testRenderBlockOptimizer()
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$stream = $env->parse($env->tokenize('{{ block("foo") }}', 'index'));
@@ -24,7 +24,7 @@ class Twig_Tests_NodeVisitor_OptimizerTest extends PHPUnit_Framework_TestCase
public function testRenderParentBlockOptimizer()
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$stream = $env->parse($env->tokenize('{% extends "foo" %}{% block content %}{{ parent() }}{% endblock %}', 'index'));
@@ -40,7 +40,7 @@ class Twig_Tests_NodeVisitor_OptimizerTest extends PHPUnit_Framework_TestCase
return;
}
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
$stream = $env->parse($env->tokenize('{{ block(name|lower) }}', 'index'));
$node = $stream->getNode('body')->getNode(0)->getNode(1);
@@ -54,7 +54,7 @@ class Twig_Tests_NodeVisitor_OptimizerTest extends PHPUnit_Framework_TestCase
*/
public function testForOptimizer($template, $expected)
{
$env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false));
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false));
$stream = $env->parse($env->tokenize($template, 'index'));
+6 -6
View File
@@ -16,7 +16,7 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase
public function testSetMacroThrowsExceptionOnReservedMethods()
{
$parser = $this->getParser();
$parser->setMacro('parent', $this->getMock('Twig_Node_Macro', array(), array(), '', null));
$parser->setMacro('parent', $this->getMockBuilder('Twig_Node_Macro')->disableOriginalConstructor()->getMock());
}
/**
@@ -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($this->getMock('Twig_LoaderInterface')));
$parser = new Twig_Parser(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$parser->parse($stream);
}
@@ -47,7 +47,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($this->getMock('Twig_LoaderInterface')));
$parser = new Twig_Parser(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$parser->parse($stream);
}
@@ -110,7 +110,7 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase
public function testParseIsReentrant()
{
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array(
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array(
'autoescape' => false,
'optimizations' => 0,
));
@@ -136,7 +136,7 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase
// see https://github.com/symfony/symfony/issues/4218
public function testGetVarName()
{
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array(
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array(
'autoescape' => false,
'optimizations' => 0,
));
@@ -153,7 +153,7 @@ EOF
protected function getParser()
{
$parser = new TestParser(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
$parser = new TestParser(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$parser->setParent(new Twig_Node());
$parser->stream = $this->getMockBuilder('Twig_TokenStream')->disableOriginalConstructor()->getMock();
+10 -10
View File
@@ -86,7 +86,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
public function testGetSource()
{
$template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface')), false);
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), false);
$this->assertSame("<? */*bar*/ ?>\n", $template->getSource());
}
@@ -96,7 +96,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
*/
public function testGetAttributeWithSandbox($object, $item, $allowed, $useExt)
{
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$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);
@@ -140,8 +140,8 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
*/
public function testGetAttributeWithTemplateAsObject($useExt)
{
$template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface')), $useExt);
$template1 = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface')), false);
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), $useExt);
$template1 = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), false);
$this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'string'));
$this->assertEquals('some_string', $template->getAttribute($template1, 'string'));
@@ -180,7 +180,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
public function testGetAttributeOnArrayWithConfusableKey($useExt = false)
{
$template = new Twig_TemplateTest(
new Twig_Environment($this->getMock('Twig_LoaderInterface')),
new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()),
$useExt
);
@@ -219,7 +219,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($this->getMock('Twig_LoaderInterface')), $useExt);
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), $useExt);
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
}
@@ -229,7 +229,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($this->getMock('Twig_LoaderInterface'), array('strict_variables' => true)), $useExt);
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true)), $useExt);
if ($defined) {
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
@@ -251,7 +251,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($this->getMock('Twig_LoaderInterface')), $useExt);
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), $useExt);
$this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
}
@@ -261,7 +261,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($this->getMock('Twig_LoaderInterface'), array('strict_variables' => true)), $useExt);
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true)), $useExt);
$this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
}
@@ -271,7 +271,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
*/
public function testGetAttributeCallExceptions($useExt = false)
{
$template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface')), $useExt);
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), $useExt);
$object = new Twig_TemplateMagicMethodExceptionObject();
+1 -1
View File
@@ -146,7 +146,7 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase
protected function setUp()
{
$this->env = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$this->env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
}
public function testHtmlEscapingConvertsSpecialChars()