removed usage of getmockBuilder() when not needed

This commit is contained in:
Fabien Potencier
2019-08-08 11:59:51 +02:00
parent 5aae9ba07a
commit 5861a539e4
20 changed files with 108 additions and 108 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ class CompilerTest extends \PHPUnit\Framework\TestCase
{
public function testReprNumericValueWithLocale()
{
$compiler = new Compiler(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$compiler = new Compiler(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$locale = setlocale(LC_NUMERIC, 0);
if (false === $locale) {
+2 -2
View File
@@ -20,7 +20,7 @@ class ContainerRuntimeLoaderTest extends \PHPUnit\Framework\TestCase
*/
public function testLoad()
{
$container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock();
$container = $this->createMock('Psr\Container\ContainerInterface');
$container->expects($this->once())->method('has')->with('stdClass')->willReturn(true);
$container->expects($this->once())->method('get')->with('stdClass')->willReturn(new \stdClass());
@@ -34,7 +34,7 @@ class ContainerRuntimeLoaderTest extends \PHPUnit\Framework\TestCase
*/
public function testLoadUnknownRuntimeReturnsNull()
{
$container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock();
$container = $this->createMock('Psr\Container\ContainerInterface');
$container->expects($this->once())->method('has')->with('Foo');
$container->expects($this->never())->method('get');
+1 -1
View File
@@ -25,7 +25,7 @@ class CustomExtensionTest extends \PHPUnit\Framework\TestCase
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage($expectedExceptionMessage);
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$env->addExtension($extension);
$env->getUnaryOperators();
}
+17 -17
View File
@@ -89,8 +89,8 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
public function testGlobals()
{
// to be removed in 2.0
$loader = $this->getMockBuilder('\Twig\Tests\EnvironmentTestLoaderInterface')->getMock();
//$loader = $this->getMockBuilder(['\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface'])->getMock();
$loader = $this->createMock('\Twig\Tests\EnvironmentTestLoaderInterface');
//$loader = $this->createMock(['\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface']);
$loader->expects($this->any())->method('getSourceContext')->willReturn(new Source('', ''));
// globals can be added after calling getGlobals
@@ -220,7 +220,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
$templateName = __FUNCTION__;
$templateContent = __FUNCTION__;
$cache = $this->getMockBuilder('\Twig\Cache\CacheInterface')->getMock();
$cache = $this->createMock('\Twig\Cache\CacheInterface');
$loader = $this->getMockLoader($templateName, $templateContent);
$twig = new Environment($loader, ['cache' => $cache, 'auto_reload' => true, 'debug' => false]);
@@ -247,7 +247,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
$templateName = __FUNCTION__;
$templateContent = __FUNCTION__;
$cache = $this->getMockBuilder('\Twig\Cache\CacheInterface')->getMock();
$cache = $this->createMock('\Twig\Cache\CacheInterface');
$loader = $this->getMockLoader($templateName, $templateContent);
$twig = new Environment($loader, ['cache' => $cache, 'auto_reload' => true, 'debug' => false]);
@@ -275,7 +275,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
$templateName = __FUNCTION__;
$templateContent = __FUNCTION__;
$cache = $this->getMockBuilder('\Twig\Cache\CacheInterface')->getMock();
$cache = $this->createMock('\Twig\Cache\CacheInterface');
$loader = $this->getMockLoader($templateName, $templateContent);
$twig = new Environment($loader, ['cache' => $cache, 'auto_reload' => true, 'debug' => false]);
@@ -303,7 +303,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
*/
public function testHasGetExtensionWithDynamicName()
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$ext1 = new EnvironmentTest_Extension_DynamicWithDeprecatedName('ext1');
$ext2 = new EnvironmentTest_Extension_DynamicWithDeprecatedName('ext2');
@@ -321,7 +321,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
public function testHasGetExtensionByClassName()
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$twig->addExtension($ext = new EnvironmentTest_Extension());
$this->assertTrue($twig->hasExtension('Twig\Tests\EnvironmentTest_Extension'));
$this->assertTrue($twig->hasExtension('\Twig\Tests\EnvironmentTest_Extension'));
@@ -335,7 +335,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
public function testAddExtension()
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$twig->addExtension(new EnvironmentTest_Extension());
$this->assertArrayHasKey('test', $twig->getTags());
@@ -360,7 +360,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
*/
public function testAddExtensionWithDeprecatedGetGlobals()
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$twig->addExtension(new EnvironmentTest_Extension_WithGlobals());
$this->deprecations = [];
@@ -379,7 +379,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
*/
public function testRemoveExtension()
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$twig->addExtension(new EnvironmentTest_Extension_WithDeprecatedName());
$twig->removeExtension('environment_test');
@@ -396,7 +396,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
public function testAddMockExtension()
{
// should be replaced by the following in 2.0 (this current code is just to avoid a dep notice)
// $extension = $this->getMockBuilder('\Twig\Extension\AbstractExtension')->getMock();
// $extension = $this->createMock('\Twig\Extension\AbstractExtension');
$extension = eval(<<<EOF
use Twig\Extension\AbstractExtension;
@@ -418,7 +418,7 @@ EOF
public function testInitRuntimeWithAnExtensionUsingInitRuntimeNoDeprecation()
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$twig->addExtension(new EnvironmentTest_ExtensionWithoutDeprecationInitRuntime());
$twig->initRuntime();
@@ -432,7 +432,7 @@ EOF
*/
public function testInitRuntimeWithAnExtensionUsingInitRuntimeDeprecation()
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$twig->addExtension(new EnvironmentTest_ExtensionWithDeprecationInitRuntime());
$this->deprecations = [];
@@ -458,7 +458,7 @@ EOF
*/
public function testOverrideExtension()
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$twig->addExtension(new EnvironmentTest_ExtensionWithDeprecationInitRuntime());
$this->deprecations = [];
@@ -475,7 +475,7 @@ EOF
public function testAddRuntimeLoader()
{
$runtimeLoader = $this->getMockBuilder('\Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock();
$runtimeLoader = $this->createMock('\Twig\RuntimeLoader\RuntimeLoaderInterface');
$runtimeLoader->expects($this->any())->method('load')->willReturn(new EnvironmentTest_Runtime());
$loader = new ArrayLoader([
@@ -502,8 +502,8 @@ EOF
protected function getMockLoader($templateName, $templateContent)
{
// to be removed in 2.0
$loader = $this->getMockBuilder('Twig\Tests\EnvironmentTestLoaderInterface')->getMock();
//$loader = $this->getMockBuilder(['\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface'])->getMock();
$loader = $this->createMock('Twig\Tests\EnvironmentTestLoaderInterface');
//$loader = $this->createMock(['\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface']);
$loader->expects($this->any())
->method('getSourceContext')
->with($templateName)
+16 -16
View File
@@ -28,7 +28,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
{
$this->expectException('\Twig\Error\SyntaxError');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source($template, 'index')));
@@ -57,7 +57,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
*/
public function testArrayExpression($template, $expected)
{
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$stream = $env->tokenize($source = new Source($template, ''));
$parser = new Parser($env);
$expected->setSourceContext($source);
@@ -72,7 +72,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
{
$this->expectException('\Twig\Error\SyntaxError');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source($template, 'index')));
@@ -166,7 +166,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
{
$this->expectException('\Twig\Error\SyntaxError');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
$stream = $env->tokenize(new Source('{{ "a" "b" }}', 'index'));
$parser = new Parser($env);
@@ -178,7 +178,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
*/
public function testStringExpression($template, $expected)
{
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
$stream = $env->tokenize($source = new Source($template, ''));
$parser = new Parser($env);
$expected->setSourceContext($source);
@@ -237,7 +237,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
{
$this->expectException('\Twig\Error\SyntaxError');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source('{{ foo.bar(name="Foo") }}', 'index')));
@@ -247,7 +247,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
{
$this->expectException('\Twig\Error\SyntaxError');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source('{% from _self import foo %}{% macro foo() %}{% endmacro %}{{ foo(name="Foo") }}', 'index')));
@@ -258,7 +258,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('An argument must be a name. Unexpected token "string" of value "a" ("name" expected) in "index" at line 1.');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source('{% macro foo("a") %}{% endmacro %}', 'index')));
@@ -272,7 +272,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('A default value for an argument must be a constant (a boolean, a string, a number, or an array) in "index" at line 1');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source($template, 'index')));
@@ -291,7 +291,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
*/
public function testMacroDefinitionSupportsConstantDefaultValues($template)
{
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source($template, 'index')));
@@ -319,7 +319,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('Unknown "cycl" function. Did you mean "cycle" in "index" at line 1?');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source('{{ cycl() }}', 'index')));
@@ -330,7 +330,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('Unknown "foobar" function in "index" at line 1.');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source('{{ foobar() }}', 'index')));
@@ -341,7 +341,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('Unknown "lowe" filter. Did you mean "lower" in "index" at line 1?');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source('{{ 1|lowe }}', 'index')));
@@ -352,7 +352,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('Unknown "foobar" filter in "index" at line 1.');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source('{{ 1|foobar }}', 'index')));
@@ -363,7 +363,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('Unknown "nul" test. Did you mean "null" in "index" at line 1');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$stream = $env->tokenize(new Source('{{ 1 is nul }}', 'index'));
$parser->parse($stream);
@@ -374,7 +374,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('Unknown "foobar" test in "index" at line 1.');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source('{{ 1 is foobar }}', 'index')));
+13 -13
View File
@@ -20,7 +20,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
*/
public function testRandomFunction(array $expectedInArray, $value1, $value2 = null)
{
$env = new Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$env = new Environment($this->createMock('Twig_LoaderInterface'));
for ($i = 0; $i < 100; ++$i) {
$this->assertTrue(\in_array(twig_random($env, $value1, $value2), $expectedInArray, true)); // assertContains() would not consider the type
}
@@ -80,25 +80,25 @@ class CoreTest extends \PHPUnit\Framework\TestCase
$max = mt_getrandmax();
for ($i = 0; $i < 100; ++$i) {
$val = twig_random(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$val = twig_random(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$this->assertTrue(\is_int($val) && $val >= 0 && $val <= $max);
}
}
public function testRandomFunctionReturnsAsIs()
{
$this->assertSame('', twig_random(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()), ''));
$this->assertSame('', twig_random(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['charset' => null]), ''));
$this->assertSame('', twig_random(new Environment($this->createMock('\Twig\Loader\LoaderInterface')), ''));
$this->assertSame('', twig_random(new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['charset' => null]), ''));
$instance = new \stdClass();
$this->assertSame($instance, twig_random(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()), $instance));
$this->assertSame($instance, twig_random(new Environment($this->createMock('\Twig\Loader\LoaderInterface')), $instance));
}
public function testRandomFunctionOfEmptyArrayThrowsException()
{
$this->expectException('\Twig\Error\RuntimeError');
twig_random(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()), []);
twig_random(new Environment($this->createMock('\Twig\Loader\LoaderInterface')), []);
}
public function testRandomFunctionOnNonUTF8String()
@@ -107,7 +107,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
$this->markTestSkipped('needs iconv or mbstring');
}
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$twig->setCharset('ISO-8859-1');
$text = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8');
@@ -123,7 +123,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
$this->markTestSkipped('needs iconv or mbstring');
}
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$twig->setCharset('ISO-8859-1');
$input = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8');
@@ -137,7 +137,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
*/
public function testCustomEscaper($expected, $string, $strategy)
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$twig->getExtension('\Twig\Extension\CoreExtension')->setEscaper('foo', '\Twig\Tests\Extension\foo_escaper_for_test');
$this->assertSame($expected, twig_escape_filter($twig, $string, $strategy));
@@ -156,7 +156,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
{
$this->expectException('\Twig\Error\RuntimeError');
twig_escape_filter(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()), 'foo', 'bar');
twig_escape_filter(new Environment($this->createMock('\Twig\Loader\LoaderInterface')), 'foo', 'bar');
}
/**
@@ -164,7 +164,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
*/
public function testTwigFirst($expected, $input)
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$this->assertSame($expected, twig_first($twig, $input));
}
@@ -186,7 +186,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
*/
public function testTwigLast($expected, $input)
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$this->assertSame($expected, twig_last($twig, $input));
}
@@ -259,7 +259,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
*/
public function testSliceFilter($expected, $input, $start, $length = null, $preserveKeys = false)
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$this->assertSame($expected, twig_slice($twig, $input, $start, $length, $preserveKeys));
}
+22 -22
View File
@@ -23,7 +23,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
*/
public function testLegacyConstructorSignature()
{
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$stream = $lexer->tokenize('{{ foo }}', 'foo');
$this->assertEquals('foo', $stream->getFilename());
$this->assertEquals('{{ foo }}', $stream->getSource());
@@ -33,7 +33,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
{
$template = '{% § %}';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$stream = $lexer->tokenize(new Source($template, 'index'));
$stream->expect(Token::BLOCK_START_TYPE);
@@ -44,7 +44,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
{
$template = '{{ §() }}';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$stream = $lexer->tokenize(new Source($template, 'index'));
$stream->expect(Token::VAR_START_TYPE);
@@ -61,7 +61,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
protected function countToken($template, $type, $value = null)
{
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$stream = $lexer->tokenize(new Source($template, 'index'));
$count = 0;
@@ -86,7 +86,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
."baz\n"
."}}\n";
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$stream = $lexer->tokenize(new Source($template, 'index'));
// foo\nbar\n
@@ -106,7 +106,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
."baz\n"
."}}\n";
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$stream = $lexer->tokenize(new Source($template, 'index'));
// foo\nbar
@@ -121,7 +121,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
{
$template = '{# '.str_repeat('*', 100000).' #}';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$lexer->tokenize(new Source($template, 'index'));
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
@@ -133,7 +133,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
{
$template = '{% verbatim %}'.str_repeat('*', 100000).'{% endverbatim %}';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$lexer->tokenize(new Source($template, 'index'));
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
@@ -145,7 +145,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
{
$template = '{{ '.str_repeat('x', 100000).' }}';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$lexer->tokenize(new Source($template, 'index'));
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
@@ -157,7 +157,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
{
$template = '{% '.str_repeat('x', 100000).' %}';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$lexer->tokenize(new Source($template, 'index'));
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
@@ -169,7 +169,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
{
$template = '{{ 922337203685477580700 }}';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$stream = $lexer->tokenize(new Source($template, 'index'));
$stream->next();
$node = $stream->next();
@@ -182,7 +182,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
"{{ 'foo \' bar' }}" => 'foo \' bar',
'{{ "foo \" bar" }}' => 'foo " bar',
];
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
foreach ($tests as $template => $expected) {
$stream = $lexer->tokenize(new Source($template, 'index'));
$stream->expect(Token::VAR_START_TYPE);
@@ -198,7 +198,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
{
$template = 'foo {{ "bar #{ baz + 1 }" }}';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$stream = $lexer->tokenize(new Source($template, 'index'));
$stream->expect(Token::TEXT_TYPE, 'foo ');
$stream->expect(Token::VAR_START_TYPE);
@@ -219,7 +219,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
{
$template = '{{ "bar \#{baz+1}" }}';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$stream = $lexer->tokenize(new Source($template, 'index'));
$stream->expect(Token::VAR_START_TYPE);
$stream->expect(Token::STRING_TYPE, 'bar #{baz+1}');
@@ -234,7 +234,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
{
$template = '{{ "bar # baz" }}';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$stream = $lexer->tokenize(new Source($template, 'index'));
$stream->expect(Token::VAR_START_TYPE);
$stream->expect(Token::STRING_TYPE, 'bar # baz');
@@ -252,7 +252,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
$template = '{{ "bar #{x" }}';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$lexer->tokenize(new Source($template, 'index'));
}
@@ -260,7 +260,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
{
$template = '{{ "bar #{ "foo#{bar}" }" }}';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$stream = $lexer->tokenize(new Source($template, 'index'));
$stream->expect(Token::VAR_START_TYPE);
$stream->expect(Token::STRING_TYPE, 'bar ');
@@ -281,7 +281,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
{
$template = '{% foo "bar #{ "foo#{bar}" }" %}';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$stream = $lexer->tokenize(new Source($template, 'index'));
$stream->expect(Token::BLOCK_START_TYPE);
$stream->expect(Token::NAME_TYPE, 'foo');
@@ -303,7 +303,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
{
$template = "{{ 1 and\n0}}";
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$stream = $lexer->tokenize(new Source($template, 'index'));
$stream->expect(Token::VAR_START_TYPE);
$stream->expect(Token::NUMBER_TYPE, 1);
@@ -328,7 +328,7 @@ bar
';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$lexer->tokenize(new Source($template, 'index'));
}
@@ -346,14 +346,14 @@ bar
';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$lexer->tokenize(new Source($template, 'index'));
}
public function testOverridingSyntax()
{
$template = '[# comment #]{# variable #}/# if true #/true/# endif #/';
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()), [
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')), [
'tag_comment' => ['[#', '#]'],
'tag_block' => ['/#', '#/'],
'tag_variable' => ['{#', '#}'],
+3 -3
View File
@@ -107,13 +107,13 @@ class ChainTest extends \PHPUnit\Framework\TestCase
public function testExists()
{
$loader1 = $this->getMockBuilder('Twig\Tests\Loader\ChainTestLoaderWithExistsInterface')->getMock();
$loader1 = $this->createMock('Twig\Tests\Loader\ChainTestLoaderWithExistsInterface');
$loader1->expects($this->once())->method('exists')->willReturn(false);
$loader1->expects($this->never())->method('getSourceContext');
// can be removed in 2.0
$loader2 = $this->getMockBuilder('Twig\Tests\Loader\ChainTestLoaderInterface')->getMock();
//$loader2 = $this->getMockBuilder(['\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface'])->getMock();
$loader2 = $this->createMock('Twig\Tests\Loader\ChainTestLoaderInterface');
//$loader2 = $this->createMock(['\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface']);
$loader2->expects($this->once())->method('getSourceContext')->willReturn(new Source('content', 'index'));
$loader = new ChainLoader();
+1 -1
View File
@@ -60,7 +60,7 @@ if (true) {
EOF
];
$environment = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$environment = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$environment->addFunction(new TwigFunction('foo', 'foo', []));
$expr = new FunctionExpression('foo', new Node(), 1);
+1 -1
View File
@@ -34,7 +34,7 @@ class FilterTest extends NodeTestCase
public function getTests()
{
$environment = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$environment = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$environment->addFilter(new TwigFilter('bar', 'bar', ['needs_environment' => true]));
$environment->addFilter(new TwigFilter('barbar', 'Twig\Tests\Node\Expression\twig_tests_filter_barbar', ['needs_context' => true, 'is_variadic' => true]));
+1 -1
View File
@@ -32,7 +32,7 @@ class FunctionTest extends NodeTestCase
public function getTests()
{
$environment = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$environment = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$environment->addFunction(new TwigFunction('foo', 'foo', []));
$environment->addFunction(new TwigFunction('bar', 'bar', ['needs_environment' => true]));
$environment->addFunction(new TwigFunction('foofoo', 'foofoo', ['needs_context' => true]));
+2 -2
View File
@@ -29,8 +29,8 @@ class NameTest extends NodeTestCase
$node = new NameExpression('foo', 1);
$context = new NameExpression('_context', 1);
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['strict_variables' => true]);
$env1 = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['strict_variables' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['strict_variables' => true]);
$env1 = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['strict_variables' => false]);
if (\PHP_VERSION_ID >= 70000) {
$output = '($context["foo"] ?? $this->getContext($context, "foo"))';
+1 -1
View File
@@ -35,7 +35,7 @@ class TestTest extends NodeTestCase
public function getTests()
{
$environment = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$environment = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$environment->addTest(new TwigTest('barbar', 'Twig\Tests\Node\Expression\twig_tests_test_barbar', ['is_variadic' => true, 'need_context' => true]));
$tests = [];
+2 -2
View File
@@ -44,7 +44,7 @@ class ModuleTest extends NodeTestCase
public function getTests()
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$tests = [];
@@ -201,7 +201,7 @@ EOF
2
);
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['debug' => true]);
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['debug' => true]);
$node = new ModuleNode($body, $extends, $blocks, $macros, $traits, new Node([]), $source);
$tests[] = [$node, <<<EOF
<?php
+1 -1
View File
@@ -23,7 +23,7 @@ class NodeTraverserTest extends \PHPUnit\Framework\TestCase
*/
public function testNodeIsNullWhenTraversing()
{
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$traverser = new NodeTraverser($env, [new IdentityVisitor()]);
$n = new Node([new Node([]), null, new Node([])]);
$this->assertCount(3, $traverser->traverse($n));
+3 -3
View File
@@ -19,7 +19,7 @@ class OptimizerTest extends \PHPUnit\Framework\TestCase
{
public function testRenderBlockOptimizer()
{
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$stream = $env->parse($env->tokenize(new Source('{{ block("foo") }}', 'index')));
@@ -31,7 +31,7 @@ class OptimizerTest extends \PHPUnit\Framework\TestCase
public function testRenderParentBlockOptimizer()
{
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
$stream = $env->parse($env->tokenize(new Source('{% extends "foo" %}{% block content %}{{ parent() }}{% endblock %}', 'index')));
@@ -46,7 +46,7 @@ class OptimizerTest extends \PHPUnit\Framework\TestCase
*/
public function testForOptimizer($template, $expected)
{
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false]);
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false]);
$stream = $env->parse($env->tokenize(new Source($template, 'index')));
+5 -5
View File
@@ -43,7 +43,7 @@ class ParserTest extends \PHPUnit\Framework\TestCase
new Token(Token::BLOCK_END_TYPE, '', 1),
new Token(Token::EOF_TYPE, '', 1),
]);
$parser = new Parser(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$parser = new Parser(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$parser->parse($stream);
}
@@ -58,7 +58,7 @@ class ParserTest extends \PHPUnit\Framework\TestCase
new Token(Token::BLOCK_END_TYPE, '', 1),
new Token(Token::EOF_TYPE, '', 1),
]);
$parser = new Parser(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$parser = new Parser(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$parser->parse($stream);
}
@@ -130,7 +130,7 @@ class ParserTest extends \PHPUnit\Framework\TestCase
public function testParseIsReentrant()
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), [
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), [
'autoescape' => false,
'optimizations' => 0,
]);
@@ -153,7 +153,7 @@ class ParserTest extends \PHPUnit\Framework\TestCase
public function testGetVarName()
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), [
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), [
'autoescape' => false,
'optimizations' => 0,
]);
@@ -175,7 +175,7 @@ EOF
protected function getParser()
{
$parser = new TestParser(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$parser = new TestParser(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$parser->setParent(new Node());
$parser->stream = new TokenStream([]);
+14 -14
View File
@@ -29,7 +29,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
{
$this->expectException('\LogicException');
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$template = new TemplateForTest($twig);
$template->displayBlock('foo', [], ['foo' => [new \stdClass(), 'foo']]);
}
@@ -89,7 +89,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
*/
public function testGetAttributeWithSandbox($object, $item, $allowed)
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$policy = new SecurityPolicy([], [], [/*method*/], [/*prop*/], []);
$twig->addExtension(new SandboxExtension($policy, !$allowed));
$template = new TemplateForTest($twig);
@@ -129,8 +129,8 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
public function testGetAttributeWithTemplateAsObject()
{
// to be removed in 2.0
$twig = new Environment($this->getMockBuilder('Twig\Tests\TemplateTestLoaderInterface')->getMock());
//$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface')->getMock());
$twig = new Environment($this->createMock('Twig\Tests\TemplateTestLoaderInterface'));
//$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface'));
$template = new TemplateForTest($twig, 'index.twig');
$template1 = new TemplateForTest($twig, 'index1.twig');
@@ -177,8 +177,8 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
public function testGetAttributeWithTemplateAsObjectForDeprecations()
{
// to be removed in 2.0
$twig = new Environment($this->getMockBuilder('Twig\Tests\TemplateTestLoaderInterface')->getMock());
//$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface')->getMock());
$twig = new Environment($this->createMock('Twig\Tests\TemplateTestLoaderInterface'));
//$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface'));
$template = new TemplateForTest($twig, 'index.twig');
$template1 = new TemplateForTest($twig, 'index1.twig');
@@ -223,7 +223,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
*/
public function testRenderBlockWithUndefinedBlock()
{
$twig = new Environment($this->getMockBuilder('Twig\Tests\TemplateTestLoaderInterface')->getMock());
$twig = new Environment($this->createMock('Twig\Tests\TemplateTestLoaderInterface'));
$template = new TemplateForTest($twig, 'index.twig');
$template->renderBlock('unknown', []);
@@ -232,7 +232,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
public function testGetAttributeOnArrayWithConfusableKey()
{
$template = new TemplateForTest(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$array = ['Zero', 'One', -1 => 'MinusOne', '' => 'EmptyString', '1.5' => 'FloatButString', '01' => 'IntegerButStringWithLeadingZeros'];
@@ -260,7 +260,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
*/
public function testGetAttribute($defined, $value, $object, $item, $arguments, $type)
{
$template = new TemplateForTest(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
}
@@ -270,7 +270,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
*/
public function testGetAttributeStrict($defined, $value, $object, $item, $arguments, $type, $exceptionMessage = null)
{
$template = new TemplateForTest(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['strict_variables' => true]));
$template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['strict_variables' => true]));
if ($defined) {
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
@@ -288,7 +288,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
*/
public function testGetAttributeDefined($defined, $value, $object, $item, $arguments, $type)
{
$template = new TemplateForTest(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
}
@@ -298,14 +298,14 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
*/
public function testGetAttributeDefinedStrict($defined, $value, $object, $item, $arguments, $type)
{
$template = new TemplateForTest(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['strict_variables' => true]));
$template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['strict_variables' => true]));
$this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
}
public function testGetAttributeCallExceptions()
{
$template = new TemplateForTest(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
$template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
$object = new TemplateMagicMethodExceptionObject();
@@ -449,7 +449,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
$this->expectException('\Twig\Error\RuntimeError');
$getIsObject = new TemplateGetIsMethods();
$template = new TemplateForTest(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['strict_variables' => true]));
$template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['strict_variables' => true]));
// first time should not create a cache for "get"
$this->assertNull($template->getAttribute($getIsObject, 'get'));
// 0 should be in the method cache now, so this should fail
+1 -1
View File
@@ -22,7 +22,7 @@ class DeprecationCollectorTest extends \PHPUnit\Framework\TestCase
*/
public function testCollect()
{
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
$twig->addFunction(new TwigFunction('deprec', [$this, 'deprec'], ['deprecated' => true]));
$collector = new DeprecationCollector($twig);
+1 -1
View File
@@ -153,7 +153,7 @@ class Twig_Test_EscapingTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
$this->env = new \Twig\Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
$this->env = new \Twig\Environment($this->createMock('\Twig\Loader\LoaderInterface'));
}
public function testHtmlEscapingConvertsSpecialChars()