Browse code

removed usage of getmockBuilder() when not needed

Fabien Potencier authored on 08/08/2019 09:59:51
Showing 20 changed files
... ...
@@ -18,7 +18,7 @@ class CompilerTest extends \PHPUnit\Framework\TestCase
18 18
 {
19 19
     public function testReprNumericValueWithLocale()
20 20
     {
21
-        $compiler = new Compiler(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
21
+        $compiler = new Compiler(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
22 22
 
23 23
         $locale = setlocale(LC_NUMERIC, 0);
24 24
         if (false === $locale) {
... ...
@@ -20,7 +20,7 @@ class ContainerRuntimeLoaderTest extends \PHPUnit\Framework\TestCase
20 20
      */
21 21
     public function testLoad()
22 22
     {
23
-        $container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock();
23
+        $container = $this->createMock('Psr\Container\ContainerInterface');
24 24
         $container->expects($this->once())->method('has')->with('stdClass')->willReturn(true);
25 25
         $container->expects($this->once())->method('get')->with('stdClass')->willReturn(new \stdClass());
26 26
 
... ...
@@ -34,7 +34,7 @@ class ContainerRuntimeLoaderTest extends \PHPUnit\Framework\TestCase
34 34
      */
35 35
     public function testLoadUnknownRuntimeReturnsNull()
36 36
     {
37
-        $container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock();
37
+        $container = $this->createMock('Psr\Container\ContainerInterface');
38 38
         $container->expects($this->once())->method('has')->with('Foo');
39 39
         $container->expects($this->never())->method('get');
40 40
 
... ...
@@ -25,7 +25,7 @@ class CustomExtensionTest extends \PHPUnit\Framework\TestCase
25 25
         $this->expectException('InvalidArgumentException');
26 26
         $this->expectExceptionMessage($expectedExceptionMessage);
27 27
 
28
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
28
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
29 29
         $env->addExtension($extension);
30 30
         $env->getUnaryOperators();
31 31
     }
... ...
@@ -89,8 +89,8 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
89 89
     public function testGlobals()
90 90
     {
91 91
         // to be removed in 2.0
92
-        $loader = $this->getMockBuilder('\Twig\Tests\EnvironmentTestLoaderInterface')->getMock();
93
-        //$loader = $this->getMockBuilder(['\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface'])->getMock();
92
+        $loader = $this->createMock('\Twig\Tests\EnvironmentTestLoaderInterface');
93
+        //$loader = $this->createMock(['\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface']);
94 94
         $loader->expects($this->any())->method('getSourceContext')->willReturn(new Source('', ''));
95 95
 
96 96
         // globals can be added after calling getGlobals
... ...
@@ -220,7 +220,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
220 220
         $templateName = __FUNCTION__;
221 221
         $templateContent = __FUNCTION__;
222 222
 
223
-        $cache = $this->getMockBuilder('\Twig\Cache\CacheInterface')->getMock();
223
+        $cache = $this->createMock('\Twig\Cache\CacheInterface');
224 224
         $loader = $this->getMockLoader($templateName, $templateContent);
225 225
         $twig = new Environment($loader, ['cache' => $cache, 'auto_reload' => true, 'debug' => false]);
226 226
 
... ...
@@ -247,7 +247,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
247 247
         $templateName = __FUNCTION__;
248 248
         $templateContent = __FUNCTION__;
249 249
 
250
-        $cache = $this->getMockBuilder('\Twig\Cache\CacheInterface')->getMock();
250
+        $cache = $this->createMock('\Twig\Cache\CacheInterface');
251 251
         $loader = $this->getMockLoader($templateName, $templateContent);
252 252
         $twig = new Environment($loader, ['cache' => $cache, 'auto_reload' => true, 'debug' => false]);
253 253
 
... ...
@@ -275,7 +275,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
275 275
         $templateName = __FUNCTION__;
276 276
         $templateContent = __FUNCTION__;
277 277
 
278
-        $cache = $this->getMockBuilder('\Twig\Cache\CacheInterface')->getMock();
278
+        $cache = $this->createMock('\Twig\Cache\CacheInterface');
279 279
         $loader = $this->getMockLoader($templateName, $templateContent);
280 280
         $twig = new Environment($loader, ['cache' => $cache, 'auto_reload' => true, 'debug' => false]);
281 281
 
... ...
@@ -303,7 +303,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
303 303
      */
304 304
     public function testHasGetExtensionWithDynamicName()
305 305
     {
306
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
306
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
307 307
 
308 308
         $ext1 = new EnvironmentTest_Extension_DynamicWithDeprecatedName('ext1');
309 309
         $ext2 = new EnvironmentTest_Extension_DynamicWithDeprecatedName('ext2');
... ...
@@ -321,7 +321,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
321 321
 
322 322
     public function testHasGetExtensionByClassName()
323 323
     {
324
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
324
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
325 325
         $twig->addExtension($ext = new EnvironmentTest_Extension());
326 326
         $this->assertTrue($twig->hasExtension('Twig\Tests\EnvironmentTest_Extension'));
327 327
         $this->assertTrue($twig->hasExtension('\Twig\Tests\EnvironmentTest_Extension'));
... ...
@@ -335,7 +335,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
335 335
 
336 336
     public function testAddExtension()
337 337
     {
338
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
338
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
339 339
         $twig->addExtension(new EnvironmentTest_Extension());
340 340
 
341 341
         $this->assertArrayHasKey('test', $twig->getTags());
... ...
@@ -360,7 +360,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
360 360
      */
361 361
     public function testAddExtensionWithDeprecatedGetGlobals()
362 362
     {
363
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
363
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
364 364
         $twig->addExtension(new EnvironmentTest_Extension_WithGlobals());
365 365
 
366 366
         $this->deprecations = [];
... ...
@@ -379,7 +379,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
379 379
      */
380 380
     public function testRemoveExtension()
381 381
     {
382
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
382
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
383 383
         $twig->addExtension(new EnvironmentTest_Extension_WithDeprecatedName());
384 384
         $twig->removeExtension('environment_test');
385 385
 
... ...
@@ -396,7 +396,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase
396 396
     public function testAddMockExtension()
397 397
     {
398 398
         // should be replaced by the following in 2.0 (this current code is just to avoid a dep notice)
399
-        // $extension = $this->getMockBuilder('\Twig\Extension\AbstractExtension')->getMock();
399
+        // $extension = $this->createMock('\Twig\Extension\AbstractExtension');
400 400
         $extension = eval(<<<EOF
401 401
 use Twig\Extension\AbstractExtension;
402 402
 
... ...
@@ -418,7 +418,7 @@ EOF
418 418
 
419 419
     public function testInitRuntimeWithAnExtensionUsingInitRuntimeNoDeprecation()
420 420
     {
421
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
421
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
422 422
         $twig->addExtension(new EnvironmentTest_ExtensionWithoutDeprecationInitRuntime());
423 423
         $twig->initRuntime();
424 424
 
... ...
@@ -432,7 +432,7 @@ EOF
432 432
      */
433 433
     public function testInitRuntimeWithAnExtensionUsingInitRuntimeDeprecation()
434 434
     {
435
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
435
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
436 436
         $twig->addExtension(new EnvironmentTest_ExtensionWithDeprecationInitRuntime());
437 437
 
438 438
         $this->deprecations = [];
... ...
@@ -458,7 +458,7 @@ EOF
458 458
      */
459 459
     public function testOverrideExtension()
460 460
     {
461
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
461
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
462 462
         $twig->addExtension(new EnvironmentTest_ExtensionWithDeprecationInitRuntime());
463 463
 
464 464
         $this->deprecations = [];
... ...
@@ -475,7 +475,7 @@ EOF
475 475
 
476 476
     public function testAddRuntimeLoader()
477 477
     {
478
-        $runtimeLoader = $this->getMockBuilder('\Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock();
478
+        $runtimeLoader = $this->createMock('\Twig\RuntimeLoader\RuntimeLoaderInterface');
479 479
         $runtimeLoader->expects($this->any())->method('load')->willReturn(new EnvironmentTest_Runtime());
480 480
 
481 481
         $loader = new ArrayLoader([
... ...
@@ -502,8 +502,8 @@ EOF
502 502
     protected function getMockLoader($templateName, $templateContent)
503 503
     {
504 504
         // to be removed in 2.0
505
-        $loader = $this->getMockBuilder('Twig\Tests\EnvironmentTestLoaderInterface')->getMock();
506
-        //$loader = $this->getMockBuilder(['\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface'])->getMock();
505
+        $loader = $this->createMock('Twig\Tests\EnvironmentTestLoaderInterface');
506
+        //$loader = $this->createMock(['\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface']);
507 507
         $loader->expects($this->any())
508 508
           ->method('getSourceContext')
509 509
           ->with($templateName)
... ...
@@ -28,7 +28,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
28 28
     {
29 29
         $this->expectException('\Twig\Error\SyntaxError');
30 30
 
31
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
31
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
32 32
         $parser = new Parser($env);
33 33
 
34 34
         $parser->parse($env->tokenize(new Source($template, 'index')));
... ...
@@ -57,7 +57,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
57 57
      */
58 58
     public function testArrayExpression($template, $expected)
59 59
     {
60
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
60
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
61 61
         $stream = $env->tokenize($source = new Source($template, ''));
62 62
         $parser = new Parser($env);
63 63
         $expected->setSourceContext($source);
... ...
@@ -72,7 +72,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
72 72
     {
73 73
         $this->expectException('\Twig\Error\SyntaxError');
74 74
 
75
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
75
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
76 76
         $parser = new Parser($env);
77 77
 
78 78
         $parser->parse($env->tokenize(new Source($template, 'index')));
... ...
@@ -166,7 +166,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
166 166
     {
167 167
         $this->expectException('\Twig\Error\SyntaxError');
168 168
 
169
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
169
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
170 170
         $stream = $env->tokenize(new Source('{{ "a" "b" }}', 'index'));
171 171
         $parser = new Parser($env);
172 172
 
... ...
@@ -178,7 +178,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
178 178
      */
179 179
     public function testStringExpression($template, $expected)
180 180
     {
181
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
181
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
182 182
         $stream = $env->tokenize($source = new Source($template, ''));
183 183
         $parser = new Parser($env);
184 184
         $expected->setSourceContext($source);
... ...
@@ -237,7 +237,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
237 237
     {
238 238
         $this->expectException('\Twig\Error\SyntaxError');
239 239
 
240
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
240
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
241 241
         $parser = new Parser($env);
242 242
 
243 243
         $parser->parse($env->tokenize(new Source('{{ foo.bar(name="Foo") }}', 'index')));
... ...
@@ -247,7 +247,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
247 247
     {
248 248
         $this->expectException('\Twig\Error\SyntaxError');
249 249
 
250
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
250
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
251 251
         $parser = new Parser($env);
252 252
 
253 253
         $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
258 258
         $this->expectException('\Twig\Error\SyntaxError');
259 259
         $this->expectExceptionMessage('An argument must be a name. Unexpected token "string" of value "a" ("name" expected) in "index" at line 1.');
260 260
 
261
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
261
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
262 262
         $parser = new Parser($env);
263 263
 
264 264
         $parser->parse($env->tokenize(new Source('{% macro foo("a") %}{% endmacro %}', 'index')));
... ...
@@ -272,7 +272,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
272 272
         $this->expectException('\Twig\Error\SyntaxError');
273 273
         $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');
274 274
 
275
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
275
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
276 276
         $parser = new Parser($env);
277 277
 
278 278
         $parser->parse($env->tokenize(new Source($template, 'index')));
... ...
@@ -291,7 +291,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
291 291
      */
292 292
     public function testMacroDefinitionSupportsConstantDefaultValues($template)
293 293
     {
294
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
294
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
295 295
         $parser = new Parser($env);
296 296
 
297 297
         $parser->parse($env->tokenize(new Source($template, 'index')));
... ...
@@ -319,7 +319,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
319 319
         $this->expectException('\Twig\Error\SyntaxError');
320 320
         $this->expectExceptionMessage('Unknown "cycl" function. Did you mean "cycle" in "index" at line 1?');
321 321
 
322
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
322
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
323 323
         $parser = new Parser($env);
324 324
 
325 325
         $parser->parse($env->tokenize(new Source('{{ cycl() }}', 'index')));
... ...
@@ -330,7 +330,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
330 330
         $this->expectException('\Twig\Error\SyntaxError');
331 331
         $this->expectExceptionMessage('Unknown "foobar" function in "index" at line 1.');
332 332
 
333
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
333
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
334 334
         $parser = new Parser($env);
335 335
 
336 336
         $parser->parse($env->tokenize(new Source('{{ foobar() }}', 'index')));
... ...
@@ -341,7 +341,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
341 341
         $this->expectException('\Twig\Error\SyntaxError');
342 342
         $this->expectExceptionMessage('Unknown "lowe" filter. Did you mean "lower" in "index" at line 1?');
343 343
 
344
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
344
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
345 345
         $parser = new Parser($env);
346 346
 
347 347
         $parser->parse($env->tokenize(new Source('{{ 1|lowe }}', 'index')));
... ...
@@ -352,7 +352,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
352 352
         $this->expectException('\Twig\Error\SyntaxError');
353 353
         $this->expectExceptionMessage('Unknown "foobar" filter in "index" at line 1.');
354 354
 
355
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
355
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
356 356
         $parser = new Parser($env);
357 357
 
358 358
         $parser->parse($env->tokenize(new Source('{{ 1|foobar }}', 'index')));
... ...
@@ -363,7 +363,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
363 363
         $this->expectException('\Twig\Error\SyntaxError');
364 364
         $this->expectExceptionMessage('Unknown "nul" test. Did you mean "null" in "index" at line 1');
365 365
 
366
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
366
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
367 367
         $parser = new Parser($env);
368 368
         $stream = $env->tokenize(new Source('{{ 1 is nul }}', 'index'));
369 369
         $parser->parse($stream);
... ...
@@ -374,7 +374,7 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
374 374
         $this->expectException('\Twig\Error\SyntaxError');
375 375
         $this->expectExceptionMessage('Unknown "foobar" test in "index" at line 1.');
376 376
 
377
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
377
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
378 378
         $parser = new Parser($env);
379 379
 
380 380
         $parser->parse($env->tokenize(new Source('{{ 1 is foobar }}', 'index')));
... ...
@@ -20,7 +20,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
20 20
      */
21 21
     public function testRandomFunction(array $expectedInArray, $value1, $value2 = null)
22 22
     {
23
-        $env = new Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
23
+        $env = new Environment($this->createMock('Twig_LoaderInterface'));
24 24
         for ($i = 0; $i < 100; ++$i) {
25 25
             $this->assertTrue(\in_array(twig_random($env, $value1, $value2), $expectedInArray, true)); // assertContains() would not consider the type
26 26
         }
... ...
@@ -80,25 +80,25 @@ class CoreTest extends \PHPUnit\Framework\TestCase
80 80
         $max = mt_getrandmax();
81 81
 
82 82
         for ($i = 0; $i < 100; ++$i) {
83
-            $val = twig_random(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
83
+            $val = twig_random(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
84 84
             $this->assertTrue(\is_int($val) && $val >= 0 && $val <= $max);
85 85
         }
86 86
     }
87 87
 
88 88
     public function testRandomFunctionReturnsAsIs()
89 89
     {
90
-        $this->assertSame('', twig_random(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()), ''));
91
-        $this->assertSame('', twig_random(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['charset' => null]), ''));
90
+        $this->assertSame('', twig_random(new Environment($this->createMock('\Twig\Loader\LoaderInterface')), ''));
91
+        $this->assertSame('', twig_random(new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['charset' => null]), ''));
92 92
 
93 93
         $instance = new \stdClass();
94
-        $this->assertSame($instance, twig_random(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()), $instance));
94
+        $this->assertSame($instance, twig_random(new Environment($this->createMock('\Twig\Loader\LoaderInterface')), $instance));
95 95
     }
96 96
 
97 97
     public function testRandomFunctionOfEmptyArrayThrowsException()
98 98
     {
99 99
         $this->expectException('\Twig\Error\RuntimeError');
100 100
 
101
-        twig_random(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()), []);
101
+        twig_random(new Environment($this->createMock('\Twig\Loader\LoaderInterface')), []);
102 102
     }
103 103
 
104 104
     public function testRandomFunctionOnNonUTF8String()
... ...
@@ -107,7 +107,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
107 107
             $this->markTestSkipped('needs iconv or mbstring');
108 108
         }
109 109
 
110
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
110
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
111 111
         $twig->setCharset('ISO-8859-1');
112 112
 
113 113
         $text = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8');
... ...
@@ -123,7 +123,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
123 123
             $this->markTestSkipped('needs iconv or mbstring');
124 124
         }
125 125
 
126
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
126
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
127 127
         $twig->setCharset('ISO-8859-1');
128 128
 
129 129
         $input = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8');
... ...
@@ -137,7 +137,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
137 137
      */
138 138
     public function testCustomEscaper($expected, $string, $strategy)
139 139
     {
140
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
140
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
141 141
         $twig->getExtension('\Twig\Extension\CoreExtension')->setEscaper('foo', '\Twig\Tests\Extension\foo_escaper_for_test');
142 142
 
143 143
         $this->assertSame($expected, twig_escape_filter($twig, $string, $strategy));
... ...
@@ -156,7 +156,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
156 156
     {
157 157
         $this->expectException('\Twig\Error\RuntimeError');
158 158
 
159
-        twig_escape_filter(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()), 'foo', 'bar');
159
+        twig_escape_filter(new Environment($this->createMock('\Twig\Loader\LoaderInterface')), 'foo', 'bar');
160 160
     }
161 161
 
162 162
     /**
... ...
@@ -164,7 +164,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
164 164
      */
165 165
     public function testTwigFirst($expected, $input)
166 166
     {
167
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
167
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
168 168
         $this->assertSame($expected, twig_first($twig, $input));
169 169
     }
170 170
 
... ...
@@ -186,7 +186,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
186 186
      */
187 187
     public function testTwigLast($expected, $input)
188 188
     {
189
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
189
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
190 190
         $this->assertSame($expected, twig_last($twig, $input));
191 191
     }
192 192
 
... ...
@@ -259,7 +259,7 @@ class CoreTest extends \PHPUnit\Framework\TestCase
259 259
      */
260 260
     public function testSliceFilter($expected, $input, $start, $length = null, $preserveKeys = false)
261 261
     {
262
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
262
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
263 263
         $this->assertSame($expected, twig_slice($twig, $input, $start, $length, $preserveKeys));
264 264
     }
265 265
 
... ...
@@ -23,7 +23,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
23 23
      */
24 24
     public function testLegacyConstructorSignature()
25 25
     {
26
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
26
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
27 27
         $stream = $lexer->tokenize('{{ foo }}', 'foo');
28 28
         $this->assertEquals('foo', $stream->getFilename());
29 29
         $this->assertEquals('{{ foo }}', $stream->getSource());
... ...
@@ -33,7 +33,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
33 33
     {
34 34
         $template = '{% § %}';
35 35
 
36
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
36
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
37 37
         $stream = $lexer->tokenize(new Source($template, 'index'));
38 38
 
39 39
         $stream->expect(Token::BLOCK_START_TYPE);
... ...
@@ -44,7 +44,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
44 44
     {
45 45
         $template = '{{ §() }}';
46 46
 
47
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
47
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
48 48
         $stream = $lexer->tokenize(new Source($template, 'index'));
49 49
 
50 50
         $stream->expect(Token::VAR_START_TYPE);
... ...
@@ -61,7 +61,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
61 61
 
62 62
     protected function countToken($template, $type, $value = null)
63 63
     {
64
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
64
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
65 65
         $stream = $lexer->tokenize(new Source($template, 'index'));
66 66
 
67 67
         $count = 0;
... ...
@@ -86,7 +86,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
86 86
             ."baz\n"
87 87
             ."}}\n";
88 88
 
89
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
89
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
90 90
         $stream = $lexer->tokenize(new Source($template, 'index'));
91 91
 
92 92
         // foo\nbar\n
... ...
@@ -106,7 +106,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
106 106
             ."baz\n"
107 107
             ."}}\n";
108 108
 
109
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
109
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
110 110
         $stream = $lexer->tokenize(new Source($template, 'index'));
111 111
 
112 112
         // foo\nbar
... ...
@@ -121,7 +121,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
121 121
     {
122 122
         $template = '{# '.str_repeat('*', 100000).' #}';
123 123
 
124
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
124
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
125 125
         $lexer->tokenize(new Source($template, 'index'));
126 126
 
127 127
         // 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
133 133
     {
134 134
         $template = '{% verbatim %}'.str_repeat('*', 100000).'{% endverbatim %}';
135 135
 
136
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
136
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
137 137
         $lexer->tokenize(new Source($template, 'index'));
138 138
 
139 139
         // 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
145 145
     {
146 146
         $template = '{{ '.str_repeat('x', 100000).' }}';
147 147
 
148
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
148
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
149 149
         $lexer->tokenize(new Source($template, 'index'));
150 150
 
151 151
         // 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
157 157
     {
158 158
         $template = '{% '.str_repeat('x', 100000).' %}';
159 159
 
160
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
160
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
161 161
         $lexer->tokenize(new Source($template, 'index'));
162 162
 
163 163
         // 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
169 169
     {
170 170
         $template = '{{ 922337203685477580700 }}';
171 171
 
172
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
172
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
173 173
         $stream = $lexer->tokenize(new Source($template, 'index'));
174 174
         $stream->next();
175 175
         $node = $stream->next();
... ...
@@ -182,7 +182,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
182 182
             "{{ 'foo \' bar' }}" => 'foo \' bar',
183 183
             '{{ "foo \" bar" }}' => 'foo " bar',
184 184
         ];
185
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
185
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
186 186
         foreach ($tests as $template => $expected) {
187 187
             $stream = $lexer->tokenize(new Source($template, 'index'));
188 188
             $stream->expect(Token::VAR_START_TYPE);
... ...
@@ -198,7 +198,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
198 198
     {
199 199
         $template = 'foo {{ "bar #{ baz + 1 }" }}';
200 200
 
201
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
201
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
202 202
         $stream = $lexer->tokenize(new Source($template, 'index'));
203 203
         $stream->expect(Token::TEXT_TYPE, 'foo ');
204 204
         $stream->expect(Token::VAR_START_TYPE);
... ...
@@ -219,7 +219,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
219 219
     {
220 220
         $template = '{{ "bar \#{baz+1}" }}';
221 221
 
222
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
222
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
223 223
         $stream = $lexer->tokenize(new Source($template, 'index'));
224 224
         $stream->expect(Token::VAR_START_TYPE);
225 225
         $stream->expect(Token::STRING_TYPE, 'bar #{baz+1}');
... ...
@@ -234,7 +234,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
234 234
     {
235 235
         $template = '{{ "bar # baz" }}';
236 236
 
237
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
237
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
238 238
         $stream = $lexer->tokenize(new Source($template, 'index'));
239 239
         $stream->expect(Token::VAR_START_TYPE);
240 240
         $stream->expect(Token::STRING_TYPE, 'bar # baz');
... ...
@@ -252,7 +252,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
252 252
 
253 253
         $template = '{{ "bar #{x" }}';
254 254
 
255
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
255
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
256 256
         $lexer->tokenize(new Source($template, 'index'));
257 257
     }
258 258
 
... ...
@@ -260,7 +260,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
260 260
     {
261 261
         $template = '{{ "bar #{ "foo#{bar}" }" }}';
262 262
 
263
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
263
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
264 264
         $stream = $lexer->tokenize(new Source($template, 'index'));
265 265
         $stream->expect(Token::VAR_START_TYPE);
266 266
         $stream->expect(Token::STRING_TYPE, 'bar ');
... ...
@@ -281,7 +281,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
281 281
     {
282 282
         $template = '{% foo "bar #{ "foo#{bar}" }" %}';
283 283
 
284
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
284
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
285 285
         $stream = $lexer->tokenize(new Source($template, 'index'));
286 286
         $stream->expect(Token::BLOCK_START_TYPE);
287 287
         $stream->expect(Token::NAME_TYPE, 'foo');
... ...
@@ -303,7 +303,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase
303 303
     {
304 304
         $template = "{{ 1 and\n0}}";
305 305
 
306
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
306
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
307 307
         $stream = $lexer->tokenize(new Source($template, 'index'));
308 308
         $stream->expect(Token::VAR_START_TYPE);
309 309
         $stream->expect(Token::NUMBER_TYPE, 1);
... ...
@@ -328,7 +328,7 @@ bar
328 328
 
329 329
 ';
330 330
 
331
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
331
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
332 332
         $lexer->tokenize(new Source($template, 'index'));
333 333
     }
334 334
 
... ...
@@ -346,14 +346,14 @@ bar
346 346
 
347 347
 ';
348 348
 
349
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
349
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
350 350
         $lexer->tokenize(new Source($template, 'index'));
351 351
     }
352 352
 
353 353
     public function testOverridingSyntax()
354 354
     {
355 355
         $template = '[# comment #]{# variable #}/# if true #/true/# endif #/';
356
-        $lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()), [
356
+        $lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')), [
357 357
             'tag_comment' => ['[#', '#]'],
358 358
             'tag_block' => ['/#', '#/'],
359 359
             'tag_variable' => ['{#', '#}'],
... ...
@@ -107,13 +107,13 @@ class ChainTest extends \PHPUnit\Framework\TestCase
107 107
 
108 108
     public function testExists()
109 109
     {
110
-        $loader1 = $this->getMockBuilder('Twig\Tests\Loader\ChainTestLoaderWithExistsInterface')->getMock();
110
+        $loader1 = $this->createMock('Twig\Tests\Loader\ChainTestLoaderWithExistsInterface');
111 111
         $loader1->expects($this->once())->method('exists')->willReturn(false);
112 112
         $loader1->expects($this->never())->method('getSourceContext');
113 113
 
114 114
         // can be removed in 2.0
115
-        $loader2 = $this->getMockBuilder('Twig\Tests\Loader\ChainTestLoaderInterface')->getMock();
116
-        //$loader2 = $this->getMockBuilder(['\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface'])->getMock();
115
+        $loader2 = $this->createMock('Twig\Tests\Loader\ChainTestLoaderInterface');
116
+        //$loader2 = $this->createMock(['\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface']);
117 117
         $loader2->expects($this->once())->method('getSourceContext')->willReturn(new Source('content', 'index'));
118 118
 
119 119
         $loader = new ChainLoader();
... ...
@@ -60,7 +60,7 @@ if (true) {
60 60
 EOF
61 61
         ];
62 62
 
63
-        $environment = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
63
+        $environment = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
64 64
         $environment->addFunction(new TwigFunction('foo', 'foo', []));
65 65
 
66 66
         $expr = new FunctionExpression('foo', new Node(), 1);
... ...
@@ -34,7 +34,7 @@ class FilterTest extends NodeTestCase
34 34
 
35 35
     public function getTests()
36 36
     {
37
-        $environment = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
37
+        $environment = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
38 38
         $environment->addFilter(new TwigFilter('bar', 'bar', ['needs_environment' => true]));
39 39
         $environment->addFilter(new TwigFilter('barbar', 'Twig\Tests\Node\Expression\twig_tests_filter_barbar', ['needs_context' => true, 'is_variadic' => true]));
40 40
 
... ...
@@ -32,7 +32,7 @@ class FunctionTest extends NodeTestCase
32 32
 
33 33
     public function getTests()
34 34
     {
35
-        $environment = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
35
+        $environment = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
36 36
         $environment->addFunction(new TwigFunction('foo', 'foo', []));
37 37
         $environment->addFunction(new TwigFunction('bar', 'bar', ['needs_environment' => true]));
38 38
         $environment->addFunction(new TwigFunction('foofoo', 'foofoo', ['needs_context' => true]));
... ...
@@ -29,8 +29,8 @@ class NameTest extends NodeTestCase
29 29
         $node = new NameExpression('foo', 1);
30 30
         $context = new NameExpression('_context', 1);
31 31
 
32
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['strict_variables' => true]);
33
-        $env1 = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['strict_variables' => false]);
32
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['strict_variables' => true]);
33
+        $env1 = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['strict_variables' => false]);
34 34
 
35 35
         if (\PHP_VERSION_ID >= 70000) {
36 36
             $output = '($context["foo"] ?? $this->getContext($context, "foo"))';
... ...
@@ -35,7 +35,7 @@ class TestTest extends NodeTestCase
35 35
 
36 36
     public function getTests()
37 37
     {
38
-        $environment = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
38
+        $environment = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
39 39
         $environment->addTest(new TwigTest('barbar', 'Twig\Tests\Node\Expression\twig_tests_test_barbar', ['is_variadic' => true, 'need_context' => true]));
40 40
 
41 41
         $tests = [];
... ...
@@ -44,7 +44,7 @@ class ModuleTest extends NodeTestCase
44 44
 
45 45
     public function getTests()
46 46
     {
47
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
47
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
48 48
 
49 49
         $tests = [];
50 50
 
... ...
@@ -201,7 +201,7 @@ EOF
201 201
                         2
202 202
                     );
203 203
 
204
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['debug' => true]);
204
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['debug' => true]);
205 205
         $node = new ModuleNode($body, $extends, $blocks, $macros, $traits, new Node([]), $source);
206 206
         $tests[] = [$node, <<<EOF
207 207
 <?php
... ...
@@ -23,7 +23,7 @@ class NodeTraverserTest extends \PHPUnit\Framework\TestCase
23 23
      */
24 24
     public function testNodeIsNullWhenTraversing()
25 25
     {
26
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
26
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
27 27
         $traverser = new NodeTraverser($env, [new IdentityVisitor()]);
28 28
         $n = new Node([new Node([]), null, new Node([])]);
29 29
         $this->assertCount(3, $traverser->traverse($n));
... ...
@@ -19,7 +19,7 @@ class OptimizerTest extends \PHPUnit\Framework\TestCase
19 19
 {
20 20
     public function testRenderBlockOptimizer()
21 21
     {
22
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
22
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
23 23
 
24 24
         $stream = $env->parse($env->tokenize(new Source('{{ block("foo") }}', 'index')));
25 25
 
... ...
@@ -31,7 +31,7 @@ class OptimizerTest extends \PHPUnit\Framework\TestCase
31 31
 
32 32
     public function testRenderParentBlockOptimizer()
33 33
     {
34
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
34
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
35 35
 
36 36
         $stream = $env->parse($env->tokenize(new Source('{% extends "foo" %}{% block content %}{{ parent() }}{% endblock %}', 'index')));
37 37
 
... ...
@@ -46,7 +46,7 @@ class OptimizerTest extends \PHPUnit\Framework\TestCase
46 46
      */
47 47
     public function testForOptimizer($template, $expected)
48 48
     {
49
-        $env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false]);
49
+        $env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false]);
50 50
 
51 51
         $stream = $env->parse($env->tokenize(new Source($template, 'index')));
52 52
 
... ...
@@ -43,7 +43,7 @@ class ParserTest extends \PHPUnit\Framework\TestCase
43 43
             new Token(Token::BLOCK_END_TYPE, '', 1),
44 44
             new Token(Token::EOF_TYPE, '', 1),
45 45
         ]);
46
-        $parser = new Parser(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
46
+        $parser = new Parser(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
47 47
         $parser->parse($stream);
48 48
     }
49 49
 
... ...
@@ -58,7 +58,7 @@ class ParserTest extends \PHPUnit\Framework\TestCase
58 58
             new Token(Token::BLOCK_END_TYPE, '', 1),
59 59
             new Token(Token::EOF_TYPE, '', 1),
60 60
         ]);
61
-        $parser = new Parser(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
61
+        $parser = new Parser(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
62 62
         $parser->parse($stream);
63 63
     }
64 64
 
... ...
@@ -130,7 +130,7 @@ class ParserTest extends \PHPUnit\Framework\TestCase
130 130
 
131 131
     public function testParseIsReentrant()
132 132
     {
133
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), [
133
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), [
134 134
             'autoescape' => false,
135 135
             'optimizations' => 0,
136 136
         ]);
... ...
@@ -153,7 +153,7 @@ class ParserTest extends \PHPUnit\Framework\TestCase
153 153
 
154 154
     public function testGetVarName()
155 155
     {
156
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), [
156
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), [
157 157
             'autoescape' => false,
158 158
             'optimizations' => 0,
159 159
         ]);
... ...
@@ -175,7 +175,7 @@ EOF
175 175
 
176 176
     protected function getParser()
177 177
     {
178
-        $parser = new TestParser(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
178
+        $parser = new TestParser(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
179 179
         $parser->setParent(new Node());
180 180
         $parser->stream = new TokenStream([]);
181 181
 
... ...
@@ -29,7 +29,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
29 29
     {
30 30
         $this->expectException('\LogicException');
31 31
 
32
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
32
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
33 33
         $template = new TemplateForTest($twig);
34 34
         $template->displayBlock('foo', [], ['foo' => [new \stdClass(), 'foo']]);
35 35
     }
... ...
@@ -89,7 +89,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
89 89
      */
90 90
     public function testGetAttributeWithSandbox($object, $item, $allowed)
91 91
     {
92
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
92
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
93 93
         $policy = new SecurityPolicy([], [], [/*method*/], [/*prop*/], []);
94 94
         $twig->addExtension(new SandboxExtension($policy, !$allowed));
95 95
         $template = new TemplateForTest($twig);
... ...
@@ -129,8 +129,8 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
129 129
     public function testGetAttributeWithTemplateAsObject()
130 130
     {
131 131
         // to be removed in 2.0
132
-        $twig = new Environment($this->getMockBuilder('Twig\Tests\TemplateTestLoaderInterface')->getMock());
133
-        //$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface')->getMock());
132
+        $twig = new Environment($this->createMock('Twig\Tests\TemplateTestLoaderInterface'));
133
+        //$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface'));
134 134
 
135 135
         $template = new TemplateForTest($twig, 'index.twig');
136 136
         $template1 = new TemplateForTest($twig, 'index1.twig');
... ...
@@ -177,8 +177,8 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
177 177
     public function testGetAttributeWithTemplateAsObjectForDeprecations()
178 178
     {
179 179
         // to be removed in 2.0
180
-        $twig = new Environment($this->getMockBuilder('Twig\Tests\TemplateTestLoaderInterface')->getMock());
181
-        //$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface')->getMock());
180
+        $twig = new Environment($this->createMock('Twig\Tests\TemplateTestLoaderInterface'));
181
+        //$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface'));
182 182
 
183 183
         $template = new TemplateForTest($twig, 'index.twig');
184 184
         $template1 = new TemplateForTest($twig, 'index1.twig');
... ...
@@ -223,7 +223,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
223 223
      */
224 224
     public function testRenderBlockWithUndefinedBlock()
225 225
     {
226
-        $twig = new Environment($this->getMockBuilder('Twig\Tests\TemplateTestLoaderInterface')->getMock());
226
+        $twig = new Environment($this->createMock('Twig\Tests\TemplateTestLoaderInterface'));
227 227
 
228 228
         $template = new TemplateForTest($twig, 'index.twig');
229 229
         $template->renderBlock('unknown', []);
... ...
@@ -232,7 +232,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
232 232
 
233 233
     public function testGetAttributeOnArrayWithConfusableKey()
234 234
     {
235
-        $template = new TemplateForTest(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
235
+        $template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
236 236
 
237 237
         $array = ['Zero', 'One', -1 => 'MinusOne', '' => 'EmptyString', '1.5' => 'FloatButString', '01' => 'IntegerButStringWithLeadingZeros'];
238 238
 
... ...
@@ -260,7 +260,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
260 260
      */
261 261
     public function testGetAttribute($defined, $value, $object, $item, $arguments, $type)
262 262
     {
263
-        $template = new TemplateForTest(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
263
+        $template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
264 264
 
265 265
         $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
266 266
     }
... ...
@@ -270,7 +270,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
270 270
      */
271 271
     public function testGetAttributeStrict($defined, $value, $object, $item, $arguments, $type, $exceptionMessage = null)
272 272
     {
273
-        $template = new TemplateForTest(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['strict_variables' => true]));
273
+        $template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['strict_variables' => true]));
274 274
 
275 275
         if ($defined) {
276 276
             $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
... ...
@@ -288,7 +288,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
288 288
      */
289 289
     public function testGetAttributeDefined($defined, $value, $object, $item, $arguments, $type)
290 290
     {
291
-        $template = new TemplateForTest(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
291
+        $template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
292 292
 
293 293
         $this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
294 294
     }
... ...
@@ -298,14 +298,14 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
298 298
      */
299 299
     public function testGetAttributeDefinedStrict($defined, $value, $object, $item, $arguments, $type)
300 300
     {
301
-        $template = new TemplateForTest(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['strict_variables' => true]));
301
+        $template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['strict_variables' => true]));
302 302
 
303 303
         $this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
304 304
     }
305 305
 
306 306
     public function testGetAttributeCallExceptions()
307 307
     {
308
-        $template = new TemplateForTest(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
308
+        $template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
309 309
 
310 310
         $object = new TemplateMagicMethodExceptionObject();
311 311
 
... ...
@@ -449,7 +449,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
449 449
         $this->expectException('\Twig\Error\RuntimeError');
450 450
 
451 451
         $getIsObject = new TemplateGetIsMethods();
452
-        $template = new TemplateForTest(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['strict_variables' => true]));
452
+        $template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['strict_variables' => true]));
453 453
         // first time should not create a cache for "get"
454 454
         $this->assertNull($template->getAttribute($getIsObject, 'get'));
455 455
         // 0 should be in the method cache now, so this should fail
... ...
@@ -22,7 +22,7 @@ class DeprecationCollectorTest extends \PHPUnit\Framework\TestCase
22 22
      */
23 23
     public function testCollect()
24 24
     {
25
-        $twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
25
+        $twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
26 26
         $twig->addFunction(new TwigFunction('deprec', [$this, 'deprec'], ['deprecated' => true]));
27 27
 
28 28
         $collector = new DeprecationCollector($twig);
... ...
@@ -153,7 +153,7 @@ class Twig_Test_EscapingTest extends \PHPUnit\Framework\TestCase
153 153
 
154 154
     protected function setUp()
155 155
     {
156
-        $this->env = new \Twig\Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock());
156
+        $this->env = new \Twig\Environment($this->createMock('\Twig\Loader\LoaderInterface'));
157 157
     }
158 158
 
159 159
     public function testHtmlEscapingConvertsSpecialChars()