... | ... |
@@ -4,6 +4,8 @@ return PhpCsFixer\Config::create() |
4 | 4 |
->setRules([ |
5 | 5 |
'@Symfony' => true, |
6 | 6 |
'@Symfony:risky' => true, |
7 |
+ '@PHPUnit75Migration:risky' => true, |
|
8 |
+ 'php_unit_dedicate_assert' => ['target' => '5.6'], |
|
7 | 9 |
'array_syntax' => ['syntax' => 'short'], |
8 | 10 |
'php_unit_fqcn_annotation' => true, |
9 | 11 |
'no_unreachable_default_argument_value' => false, |
... | ... |
@@ -41,7 +41,7 @@ class FilesystemTest extends \PHPUnit\Framework\TestCase |
41 | 41 |
|
42 | 42 |
$dir = \dirname($key); |
43 | 43 |
@mkdir($dir, 0777, true); |
44 |
- $this->assertTrue(is_dir($dir)); |
|
44 |
+ $this->assertDirectoryExists($dir); |
|
45 | 45 |
$this->assertFalse(class_exists($this->classname, false)); |
46 | 46 |
|
47 | 47 |
$content = $this->generateSource(); |
... | ... |
@@ -78,12 +78,11 @@ class FilesystemTest extends \PHPUnit\Framework\TestCase |
78 | 78 |
$this->assertSame(file_get_contents($key), $content); |
79 | 79 |
} |
80 | 80 |
|
81 |
- /** |
|
82 |
- * @expectedException \RuntimeException |
|
83 |
- * @expectedExceptionMessage Unable to create the cache directory |
|
84 |
- */ |
|
85 | 81 |
public function testWriteFailMkdir() |
86 | 82 |
{ |
83 |
+ $this->expectException('\RuntimeException'); |
|
84 |
+ $this->expectExceptionMessage('Unable to create the cache directory'); |
|
85 |
+ |
|
87 | 86 |
if (\defined('PHP_WINDOWS_VERSION_BUILD')) { |
88 | 87 |
$this->markTestSkipped('Read-only directories not possible on Windows.'); |
89 | 88 |
} |
... | ... |
@@ -95,17 +94,16 @@ class FilesystemTest extends \PHPUnit\Framework\TestCase |
95 | 94 |
|
96 | 95 |
// Create read-only root directory. |
97 | 96 |
@mkdir($this->directory, 0555, true); |
98 |
- $this->assertTrue(is_dir($this->directory)); |
|
97 |
+ $this->assertDirectoryExists($this->directory); |
|
99 | 98 |
|
100 | 99 |
$this->cache->write($key, $content); |
101 | 100 |
} |
102 | 101 |
|
103 |
- /** |
|
104 |
- * @expectedException \RuntimeException |
|
105 |
- * @expectedExceptionMessage Unable to write in the cache directory |
|
106 |
- */ |
|
107 | 102 |
public function testWriteFailDirWritable() |
108 | 103 |
{ |
104 |
+ $this->expectException('\RuntimeException'); |
|
105 |
+ $this->expectExceptionMessage('Unable to write in the cache directory'); |
|
106 |
+ |
|
109 | 107 |
if (\defined('PHP_WINDOWS_VERSION_BUILD')) { |
110 | 108 |
$this->markTestSkipped('Read-only directories not possible on Windows.'); |
111 | 109 |
} |
... | ... |
@@ -119,17 +117,16 @@ class FilesystemTest extends \PHPUnit\Framework\TestCase |
119 | 117 |
@mkdir($this->directory, 0777, true); |
120 | 118 |
// Create read-only subdirectory. |
121 | 119 |
@mkdir($this->directory.'/cache', 0555); |
122 |
- $this->assertTrue(is_dir($this->directory.'/cache')); |
|
120 |
+ $this->assertDirectoryExists($this->directory.'/cache'); |
|
123 | 121 |
|
124 | 122 |
$this->cache->write($key, $content); |
125 | 123 |
} |
126 | 124 |
|
127 |
- /** |
|
128 |
- * @expectedException \RuntimeException |
|
129 |
- * @expectedExceptionMessage Failed to write cache file |
|
130 |
- */ |
|
131 | 125 |
public function testWriteFailWriteFile() |
132 | 126 |
{ |
127 |
+ $this->expectException('\RuntimeException'); |
|
128 |
+ $this->expectExceptionMessage('Failed to write cache file'); |
|
129 |
+ |
|
133 | 130 |
$key = $this->directory.'/cache/cachefile.php'; |
134 | 131 |
$content = $this->generateSource(); |
135 | 132 |
|
... | ... |
@@ -137,7 +134,7 @@ class FilesystemTest extends \PHPUnit\Framework\TestCase |
137 | 134 |
|
138 | 135 |
// Create a directory in the place of the cache file. |
139 | 136 |
@mkdir($key, 0777, true); |
140 |
- $this->assertTrue(is_dir($key)); |
|
137 |
+ $this->assertDirectoryExists($key); |
|
141 | 138 |
|
142 | 139 |
$this->cache->write($key, $content); |
143 | 140 |
} |
... | ... |
@@ -148,7 +145,7 @@ class FilesystemTest extends \PHPUnit\Framework\TestCase |
148 | 145 |
|
149 | 146 |
$dir = \dirname($key); |
150 | 147 |
@mkdir($dir, 0777, true); |
151 |
- $this->assertTrue(is_dir($dir)); |
|
148 |
+ $this->assertDirectoryExists($dir); |
|
152 | 149 |
|
153 | 150 |
// Create the file with a specific modification time. |
154 | 151 |
touch($key, 1234567890); |
... | ... |
@@ -31,7 +31,7 @@ class CompilerTest extends \PHPUnit\Framework\TestCase |
31 | 31 |
} |
32 | 32 |
|
33 | 33 |
$this->assertEquals('1.2', $compiler->repr(1.2)->getSource()); |
34 |
- $this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0))); |
|
34 |
+ $this->assertStringContainsString('fr', strtolower(setlocale(LC_NUMERIC, 0))); |
|
35 | 35 |
|
36 | 36 |
setlocale(LC_NUMERIC, $locale); |
37 | 37 |
} |
... | ... |
@@ -22,12 +22,8 @@ class CustomExtensionTest extends \PHPUnit\Framework\TestCase |
22 | 22 |
*/ |
23 | 23 |
public function testGetInvalidOperators(ExtensionInterface $extension, $expectedExceptionMessage) |
24 | 24 |
{ |
25 |
- if (method_exists($this, 'expectException')) { |
|
26 |
- $this->expectException('InvalidArgumentException'); |
|
27 |
- $this->expectExceptionMessage($expectedExceptionMessage); |
|
28 |
- } else { |
|
29 |
- $this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage); |
|
30 |
- } |
|
25 |
+ $this->expectException('InvalidArgumentException'); |
|
26 |
+ $this->expectExceptionMessage($expectedExceptionMessage); |
|
31 | 27 |
|
32 | 28 |
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()); |
33 | 29 |
$env->addExtension($extension); |
... | ... |
@@ -49,16 +49,17 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase |
49 | 49 |
{ |
50 | 50 |
$loader = new ArrayLoader(['foo' => '{{ foo }}']); |
51 | 51 |
$env = new Environment($loader); |
52 |
- $this->assertContains('getTemplateName', $env->compileSource('{{ foo }}', 'foo')); |
|
52 |
+ $this->assertStringContainsString('getTemplateName', $env->compileSource('{{ foo }}', 'foo')); |
|
53 | 53 |
} |
54 | 54 |
|
55 | 55 |
/** |
56 |
- * @expectedException \LogicException |
|
57 |
- * @expectedExceptionMessage You must set a loader first. |
|
58 | 56 |
* @group legacy |
59 | 57 |
*/ |
60 | 58 |
public function testRenderNoLoader() |
61 | 59 |
{ |
60 |
+ $this->expectException('\LogicException'); |
|
61 |
+ $this->expectExceptionMessage('You must set a loader first.'); |
|
62 |
+ |
|
62 | 63 |
$env = new Environment(); |
63 | 64 |
$env->render('test'); |
64 | 65 |
} |
... | ... |
@@ -368,7 +369,7 @@ class EnvironmentTest extends \PHPUnit\Framework\TestCase |
368 | 369 |
$this->assertArrayHasKey('foo_global', $twig->getGlobals()); |
369 | 370 |
|
370 | 371 |
$this->assertCount(1, $this->deprecations); |
371 |
- $this->assertContains('Defining the getGlobals() method in the "Twig\Tests\EnvironmentTest_Extension_WithGlobals" extension ', $this->deprecations[0]); |
|
372 |
+ $this->assertStringContainsString('Defining the getGlobals() method in the "Twig\Tests\EnvironmentTest_Extension_WithGlobals" extension ', $this->deprecations[0]); |
|
372 | 373 |
|
373 | 374 |
restore_error_handler(); |
374 | 375 |
} |
... | ... |
@@ -440,7 +441,7 @@ EOF |
440 | 441 |
$twig->initRuntime(); |
441 | 442 |
|
442 | 443 |
$this->assertCount(1, $this->deprecations); |
443 |
- $this->assertContains('Defining the initRuntime() method in the "Twig\Tests\EnvironmentTest_ExtensionWithDeprecationInitRuntime" extension is deprecated since version 1.23.', $this->deprecations[0]); |
|
444 |
+ $this->assertStringContainsString('Defining the initRuntime() method in the "Twig\Tests\EnvironmentTest_ExtensionWithDeprecationInitRuntime" extension is deprecated since version 1.23.', $this->deprecations[0]); |
|
444 | 445 |
|
445 | 446 |
restore_error_handler(); |
446 | 447 |
} |
... | ... |
@@ -467,7 +468,7 @@ EOF |
467 | 468 |
$twig->addExtension(new EnvironmentTest_Extension_WithDeprecatedName()); |
468 | 469 |
|
469 | 470 |
$this->assertCount(1, $this->deprecations); |
470 |
- $this->assertContains('The possibility to register the same extension twice', $this->deprecations[0]); |
|
471 |
+ $this->assertStringContainsString('The possibility to register the same extension twice', $this->deprecations[0]); |
|
471 | 472 |
|
472 | 473 |
restore_error_handler(); |
473 | 474 |
} |
... | ... |
@@ -25,7 +25,7 @@ class ErrorTest extends \PHPUnit\Framework\TestCase |
25 | 25 |
$error = new Error('foo'); |
26 | 26 |
$error->setSourceContext(new Source('', new \SplFileInfo(__FILE__))); |
27 | 27 |
|
28 |
- $this->assertContains('tests'.\DIRECTORY_SEPARATOR.'ErrorTest.php', $error->getMessage()); |
|
28 |
+ $this->assertStringContainsString('tests'.\DIRECTORY_SEPARATOR.'ErrorTest.php', $error->getMessage()); |
|
29 | 29 |
} |
30 | 30 |
|
31 | 31 |
public function testErrorWithArrayFilename() |
... | ... |
@@ -22,11 +22,12 @@ use Twig\Source; |
22 | 22 |
class ExpressionParserTest extends \PHPUnit\Framework\TestCase |
23 | 23 |
{ |
24 | 24 |
/** |
25 |
- * @expectedException \Twig\Error\SyntaxError |
|
26 | 25 |
* @dataProvider getFailingTestsForAssignment |
27 | 26 |
*/ |
28 | 27 |
public function testCanOnlyAssignToNames($template) |
29 | 28 |
{ |
29 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
30 |
+ |
|
30 | 31 |
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]); |
31 | 32 |
$parser = new Parser($env); |
32 | 33 |
|
... | ... |
@@ -65,11 +66,12 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase |
65 | 66 |
} |
66 | 67 |
|
67 | 68 |
/** |
68 |
- * @expectedException \Twig\Error\SyntaxError |
|
69 | 69 |
* @dataProvider getFailingTestsForArray |
70 | 70 |
*/ |
71 | 71 |
public function testArraySyntaxError($template) |
72 | 72 |
{ |
73 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
74 |
+ |
|
73 | 75 |
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]); |
74 | 76 |
$parser = new Parser($env); |
75 | 77 |
|
... | ... |
@@ -160,11 +162,10 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase |
160 | 162 |
]; |
161 | 163 |
} |
162 | 164 |
|
163 |
- /** |
|
164 |
- * @expectedException \Twig\Error\SyntaxError |
|
165 |
- */ |
|
166 | 165 |
public function testStringExpressionDoesNotConcatenateTwoConsecutiveStrings() |
167 | 166 |
{ |
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 | 170 |
$stream = $env->tokenize(new Source('{{ "a" "b" }}', 'index')); |
170 | 171 |
$parser = new Parser($env); |
... | ... |
@@ -232,34 +233,31 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase |
232 | 233 |
]; |
233 | 234 |
} |
234 | 235 |
|
235 |
- /** |
|
236 |
- * @expectedException \Twig\Error\SyntaxError |
|
237 |
- */ |
|
238 | 236 |
public function testAttributeCallDoesNotSupportNamedArguments() |
239 | 237 |
{ |
238 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
239 |
+ |
|
240 | 240 |
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['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'))); |
244 | 244 |
} |
245 | 245 |
|
246 |
- /** |
|
247 |
- * @expectedException \Twig\Error\SyntaxError |
|
248 |
- */ |
|
249 | 246 |
public function testMacroCallDoesNotSupportNamedArguments() |
250 | 247 |
{ |
248 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
249 |
+ |
|
251 | 250 |
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]); |
252 | 251 |
$parser = new Parser($env); |
253 | 252 |
|
254 | 253 |
$parser->parse($env->tokenize(new Source('{% from _self import foo %}{% macro foo() %}{% endmacro %}{{ foo(name="Foo") }}', 'index'))); |
255 | 254 |
} |
256 | 255 |
|
257 |
- /** |
|
258 |
- * @expectedException \Twig\Error\SyntaxError |
|
259 |
- * @expectedExceptionMessage An argument must be a name. Unexpected token "string" of value "a" ("name" expected) in "index" at line 1. |
|
260 |
- */ |
|
261 | 256 |
public function testMacroDefinitionDoesNotSupportNonNameVariableName() |
262 | 257 |
{ |
258 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
259 |
+ $this->expectExceptionMessage('An argument must be a name. Unexpected token "string" of value "a" ("name" expected) in "index" at line 1.'); |
|
260 |
+ |
|
263 | 261 |
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]); |
264 | 262 |
$parser = new Parser($env); |
265 | 263 |
|
... | ... |
@@ -267,12 +265,13 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase |
267 | 265 |
} |
268 | 266 |
|
269 | 267 |
/** |
270 |
- * @expectedException \Twig\Error\SyntaxError |
|
271 |
- * @expectedExceptionMessage A default value for an argument must be a constant (a boolean, a string, a number, or an array) in "index" at line 1 |
|
272 | 268 |
* @dataProvider getMacroDefinitionDoesNotSupportNonConstantDefaultValues |
273 | 269 |
*/ |
274 | 270 |
public function testMacroDefinitionDoesNotSupportNonConstantDefaultValues($template) |
275 | 271 |
{ |
272 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
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 |
+ |
|
276 | 275 |
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]); |
277 | 276 |
$parser = new Parser($env); |
278 | 277 |
|
... | ... |
@@ -315,72 +314,66 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase |
315 | 314 |
]; |
316 | 315 |
} |
317 | 316 |
|
318 |
- /** |
|
319 |
- * @expectedException \Twig\Error\SyntaxError |
|
320 |
- * @expectedExceptionMessage Unknown "cycl" function. Did you mean "cycle" in "index" at line 1? |
|
321 |
- */ |
|
322 | 317 |
public function testUnknownFunction() |
323 | 318 |
{ |
319 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
320 |
+ $this->expectExceptionMessage('Unknown "cycl" function. Did you mean "cycle" in "index" at line 1?'); |
|
321 |
+ |
|
324 | 322 |
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]); |
325 | 323 |
$parser = new Parser($env); |
326 | 324 |
|
327 | 325 |
$parser->parse($env->tokenize(new Source('{{ cycl() }}', 'index'))); |
328 | 326 |
} |
329 | 327 |
|
330 |
- /** |
|
331 |
- * @expectedException \Twig\Error\SyntaxError |
|
332 |
- * @expectedExceptionMessage Unknown "foobar" function in "index" at line 1. |
|
333 |
- */ |
|
334 | 328 |
public function testUnknownFunctionWithoutSuggestions() |
335 | 329 |
{ |
330 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
331 |
+ $this->expectExceptionMessage('Unknown "foobar" function in "index" at line 1.'); |
|
332 |
+ |
|
336 | 333 |
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]); |
337 | 334 |
$parser = new Parser($env); |
338 | 335 |
|
339 | 336 |
$parser->parse($env->tokenize(new Source('{{ foobar() }}', 'index'))); |
340 | 337 |
} |
341 | 338 |
|
342 |
- /** |
|
343 |
- * @expectedException \Twig\Error\SyntaxError |
|
344 |
- * @expectedExceptionMessage Unknown "lowe" filter. Did you mean "lower" in "index" at line 1? |
|
345 |
- */ |
|
346 | 339 |
public function testUnknownFilter() |
347 | 340 |
{ |
341 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
342 |
+ $this->expectExceptionMessage('Unknown "lowe" filter. Did you mean "lower" in "index" at line 1?'); |
|
343 |
+ |
|
348 | 344 |
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]); |
349 | 345 |
$parser = new Parser($env); |
350 | 346 |
|
351 | 347 |
$parser->parse($env->tokenize(new Source('{{ 1|lowe }}', 'index'))); |
352 | 348 |
} |
353 | 349 |
|
354 |
- /** |
|
355 |
- * @expectedException \Twig\Error\SyntaxError |
|
356 |
- * @expectedExceptionMessage Unknown "foobar" filter in "index" at line 1. |
|
357 |
- */ |
|
358 | 350 |
public function testUnknownFilterWithoutSuggestions() |
359 | 351 |
{ |
352 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
353 |
+ $this->expectExceptionMessage('Unknown "foobar" filter in "index" at line 1.'); |
|
354 |
+ |
|
360 | 355 |
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]); |
361 | 356 |
$parser = new Parser($env); |
362 | 357 |
|
363 | 358 |
$parser->parse($env->tokenize(new Source('{{ 1|foobar }}', 'index'))); |
364 | 359 |
} |
365 | 360 |
|
366 |
- /** |
|
367 |
- * @expectedException \Twig\Error\SyntaxError |
|
368 |
- * @expectedExceptionMessage Unknown "nul" test. Did you mean "null" in "index" at line 1 |
|
369 |
- */ |
|
370 | 361 |
public function testUnknownTest() |
371 | 362 |
{ |
363 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
364 |
+ $this->expectExceptionMessage('Unknown "nul" test. Did you mean "null" in "index" at line 1'); |
|
365 |
+ |
|
372 | 366 |
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]); |
373 | 367 |
$parser = new Parser($env); |
374 | 368 |
$stream = $env->tokenize(new Source('{{ 1 is nul }}', 'index')); |
375 | 369 |
$parser->parse($stream); |
376 | 370 |
} |
377 | 371 |
|
378 |
- /** |
|
379 |
- * @expectedException \Twig\Error\SyntaxError |
|
380 |
- * @expectedExceptionMessage Unknown "foobar" test in "index" at line 1. |
|
381 |
- */ |
|
382 | 372 |
public function testUnknownTestWithoutSuggestions() |
383 | 373 |
{ |
374 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
375 |
+ $this->expectExceptionMessage('Unknown "foobar" test in "index" at line 1.'); |
|
376 |
+ |
|
384 | 377 |
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]); |
385 | 378 |
$parser = new Parser($env); |
386 | 379 |
|
... | ... |
@@ -94,11 +94,10 @@ class CoreTest extends \PHPUnit\Framework\TestCase |
94 | 94 |
$this->assertSame($instance, twig_random(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()), $instance)); |
95 | 95 |
} |
96 | 96 |
|
97 |
- /** |
|
98 |
- * @expectedException \Twig\Error\RuntimeError |
|
99 |
- */ |
|
100 | 97 |
public function testRandomFunctionOfEmptyArrayThrowsException() |
101 | 98 |
{ |
99 |
+ $this->expectException('\Twig\Error\RuntimeError'); |
|
100 |
+ |
|
102 | 101 |
twig_random(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()), []); |
103 | 102 |
} |
104 | 103 |
|
... | ... |
@@ -153,11 +152,10 @@ class CoreTest extends \PHPUnit\Framework\TestCase |
153 | 152 |
]; |
154 | 153 |
} |
155 | 154 |
|
156 |
- /** |
|
157 |
- * @expectedException \Twig\Error\RuntimeError |
|
158 |
- */ |
|
159 | 155 |
public function testUnknownCustomEscaper() |
160 | 156 |
{ |
157 |
+ $this->expectException('\Twig\Error\RuntimeError'); |
|
158 |
+ |
|
161 | 159 |
twig_escape_filter(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()), 'foo', 'bar'); |
162 | 160 |
} |
163 | 161 |
|
... | ... |
@@ -47,12 +47,11 @@ class SandboxTest extends \PHPUnit\Framework\TestCase |
47 | 47 |
]; |
48 | 48 |
} |
49 | 49 |
|
50 |
- /** |
|
51 |
- * @expectedException \Twig\Sandbox\SecurityError |
|
52 |
- * @expectedExceptionMessage Filter "json_encode" is not allowed in "1_child" at line 3. |
|
53 |
- */ |
|
54 | 50 |
public function testSandboxWithInheritance() |
55 | 51 |
{ |
52 |
+ $this->expectException('\Twig\Sandbox\SecurityError'); |
|
53 |
+ $this->expectExceptionMessage('Filter "json_encode" is not allowed in "1_child" at line 3.'); |
|
54 |
+ |
|
56 | 55 |
$twig = $this->getEnvironment(true, [], self::$templates, ['block']); |
57 | 56 |
$twig->load('1_child')->render([]); |
58 | 57 |
} |
... | ... |
@@ -245,12 +245,11 @@ class LexerTest extends \PHPUnit\Framework\TestCase |
245 | 245 |
$this->addToAssertionCount(1); |
246 | 246 |
} |
247 | 247 |
|
248 |
- /** |
|
249 |
- * @expectedException \Twig\Error\SyntaxError |
|
250 |
- * @expectedExceptionMessage Unclosed """ |
|
251 |
- */ |
|
252 | 248 |
public function testStringWithUnterminatedInterpolation() |
253 | 249 |
{ |
250 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
251 |
+ $this->expectExceptionMessage('Unclosed """'); |
|
252 |
+ |
|
254 | 253 |
$template = '{{ "bar #{x" }}'; |
255 | 254 |
|
256 | 255 |
$lexer = new Lexer(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock())); |
... | ... |
@@ -315,12 +314,11 @@ class LexerTest extends \PHPUnit\Framework\TestCase |
315 | 314 |
$this->addToAssertionCount(1); |
316 | 315 |
} |
317 | 316 |
|
318 |
- /** |
|
319 |
- * @expectedException \Twig\Error\SyntaxError |
|
320 |
- * @expectedExceptionMessage Unclosed "variable" in "index" at line 3 |
|
321 |
- */ |
|
322 | 317 |
public function testUnterminatedVariable() |
323 | 318 |
{ |
319 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
320 |
+ $this->expectExceptionMessage('Unclosed "variable" in "index" at line 3'); |
|
321 |
+ |
|
324 | 322 |
$template = ' |
325 | 323 |
|
326 | 324 |
{{ |
... | ... |
@@ -334,12 +332,11 @@ bar |
334 | 332 |
$lexer->tokenize(new Source($template, 'index')); |
335 | 333 |
} |
336 | 334 |
|
337 |
- /** |
|
338 |
- * @expectedException \Twig\Error\SyntaxError |
|
339 |
- * @expectedExceptionMessage Unclosed "block" in "index" at line 3 |
|
340 |
- */ |
|
341 | 335 |
public function testUnterminatedBlock() |
342 | 336 |
{ |
337 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
338 |
+ $this->expectExceptionMessage('Unclosed "block" in "index" at line 3'); |
|
339 |
+ |
|
343 | 340 |
$template = ' |
344 | 341 |
|
345 | 342 |
{% |
... | ... |
@@ -27,20 +27,20 @@ class ArrayTest extends \PHPUnit\Framework\TestCase |
27 | 27 |
|
28 | 28 |
/** |
29 | 29 |
* @group legacy |
30 |
- * @expectedException \Twig\Error\LoaderError |
|
31 | 30 |
*/ |
32 | 31 |
public function testGetSourceWhenTemplateDoesNotExist() |
33 | 32 |
{ |
33 |
+ $this->expectException('\Twig\Error\LoaderError'); |
|
34 |
+ |
|
34 | 35 |
$loader = new ArrayLoader([]); |
35 | 36 |
|
36 | 37 |
$loader->getSource('foo'); |
37 | 38 |
} |
38 | 39 |
|
39 |
- /** |
|
40 |
- * @expectedException \Twig\Error\LoaderError |
|
41 |
- */ |
|
42 | 40 |
public function testGetSourceContextWhenTemplateDoesNotExist() |
43 | 41 |
{ |
42 |
+ $this->expectException('\Twig\Error\LoaderError'); |
|
43 |
+ |
|
44 | 44 |
$loader = new ArrayLoader([]); |
45 | 45 |
|
46 | 46 |
$loader->getSourceContext('foo'); |
... | ... |
@@ -75,11 +75,10 @@ class ArrayTest extends \PHPUnit\Framework\TestCase |
75 | 75 |
$this->assertEquals('foo:__bar', $loader->getCacheKey('foo')); |
76 | 76 |
} |
77 | 77 |
|
78 |
- /** |
|
79 |
- * @expectedException \Twig\Error\LoaderError |
|
80 |
- */ |
|
81 | 78 |
public function testGetCacheKeyWhenTemplateDoesNotExist() |
82 | 79 |
{ |
80 |
+ $this->expectException('\Twig\Error\LoaderError'); |
|
81 |
+ |
|
83 | 82 |
$loader = new ArrayLoader([]); |
84 | 83 |
|
85 | 84 |
$loader->getCacheKey('foo'); |
... | ... |
@@ -99,11 +98,10 @@ class ArrayTest extends \PHPUnit\Framework\TestCase |
99 | 98 |
$this->assertTrue($loader->isFresh('foo', time())); |
100 | 99 |
} |
101 | 100 |
|
102 |
- /** |
|
103 |
- * @expectedException \Twig\Error\LoaderError |
|
104 |
- */ |
|
105 | 101 |
public function testIsFreshWhenTemplateDoesNotExist() |
106 | 102 |
{ |
103 |
+ $this->expectException('\Twig\Error\LoaderError'); |
|
104 |
+ |
|
107 | 105 |
$loader = new ArrayLoader([]); |
108 | 106 |
|
109 | 107 |
$loader->isFresh('foo', time()); |
... | ... |
@@ -56,11 +56,10 @@ class ChainTest extends \PHPUnit\Framework\TestCase |
56 | 56 |
$this->assertNotEquals('baz', $loader->getSourceContext('errors/base.html')->getCode()); |
57 | 57 |
} |
58 | 58 |
|
59 |
- /** |
|
60 |
- * @expectedException \Twig\Error\LoaderError |
|
61 |
- */ |
|
62 | 59 |
public function testGetSourceContextWhenTemplateDoesNotExist() |
63 | 60 |
{ |
61 |
+ $this->expectException('\Twig\Error\LoaderError'); |
|
62 |
+ |
|
64 | 63 |
$loader = new ChainLoader([]); |
65 | 64 |
|
66 | 65 |
$loader->getSourceContext('foo'); |
... | ... |
@@ -68,10 +67,11 @@ class ChainTest extends \PHPUnit\Framework\TestCase |
68 | 67 |
|
69 | 68 |
/** |
70 | 69 |
* @group legacy |
71 |
- * @expectedException \Twig\Error\LoaderError |
|
72 | 70 |
*/ |
73 | 71 |
public function testGetSourceWhenTemplateDoesNotExist() |
74 | 72 |
{ |
73 |
+ $this->expectException('\Twig\Error\LoaderError'); |
|
74 |
+ |
|
75 | 75 |
$loader = new ChainLoader([]); |
76 | 76 |
|
77 | 77 |
$loader->getSource('foo'); |
... | ... |
@@ -88,11 +88,10 @@ class ChainTest extends \PHPUnit\Framework\TestCase |
88 | 88 |
$this->assertEquals('bar:foo', $loader->getCacheKey('bar')); |
89 | 89 |
} |
90 | 90 |
|
91 |
- /** |
|
92 |
- * @expectedException \Twig\Error\LoaderError |
|
93 |
- */ |
|
94 | 91 |
public function testGetCacheKeyWhenTemplateDoesNotExist() |
95 | 92 |
{ |
93 |
+ $this->expectException('\Twig\Error\LoaderError'); |
|
94 |
+ |
|
96 | 95 |
$loader = new ChainLoader([]); |
97 | 96 |
|
98 | 97 |
$loader->getCacheKey('foo'); |
... | ... |
@@ -36,7 +36,7 @@ class FilesystemTest extends \PHPUnit\Framework\TestCase |
36 | 36 |
$loader->getCacheKey($template); |
37 | 37 |
$this->fail(); |
38 | 38 |
} catch (LoaderError $e) { |
39 |
- $this->assertNotContains('Unable to find template', $e->getMessage()); |
|
39 |
+ $this->assertStringNotContainsString('Unable to find template', $e->getMessage()); |
|
40 | 40 |
} |
41 | 41 |
} |
42 | 42 |
|
... | ... |
@@ -156,7 +156,7 @@ class FilesystemTest extends \PHPUnit\Framework\TestCase |
156 | 156 |
$loader->getSourceContext('@named/nowhere.html'); |
157 | 157 |
} catch (\Exception $e) { |
158 | 158 |
$this->assertInstanceOf('\Twig\Error\LoaderError', $e); |
159 |
- $this->assertContains('Unable to find template "@named/nowhere.html"', $e->getMessage()); |
|
159 |
+ $this->assertStringContainsString('Unable to find template "@named/nowhere.html"', $e->getMessage()); |
|
160 | 160 |
} |
161 | 161 |
} |
162 | 162 |
|
... | ... |
@@ -21,52 +21,47 @@ class CallTest extends \PHPUnit\Framework\TestCase |
21 | 21 |
$this->assertEquals(['U', null], $node->getArguments('date', ['format' => 'U', 'timestamp' => null])); |
22 | 22 |
} |
23 | 23 |
|
24 |
- /** |
|
25 |
- * @expectedException \Twig\Error\SyntaxError |
|
26 |
- * @expectedExceptionMessage Positional arguments cannot be used after named arguments for function "date". |
|
27 |
- */ |
|
28 | 24 |
public function testGetArgumentsWhenPositionalArgumentsAfterNamedArguments() |
29 | 25 |
{ |
26 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
27 |
+ $this->expectExceptionMessage('Positional arguments cannot be used after named arguments for function "date".'); |
|
28 |
+ |
|
30 | 29 |
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'date']); |
31 | 30 |
$node->getArguments('date', ['timestamp' => 123456, 'Y-m-d']); |
32 | 31 |
} |
33 | 32 |
|
34 |
- /** |
|
35 |
- * @expectedException \Twig\Error\SyntaxError |
|
36 |
- * @expectedExceptionMessage Argument "format" is defined twice for function "date". |
|
37 |
- */ |
|
38 | 33 |
public function testGetArgumentsWhenArgumentIsDefinedTwice() |
39 | 34 |
{ |
35 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
36 |
+ $this->expectExceptionMessage('Argument "format" is defined twice for function "date".'); |
|
37 |
+ |
|
40 | 38 |
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'date']); |
41 | 39 |
$node->getArguments('date', ['Y-m-d', 'format' => 'U']); |
42 | 40 |
} |
43 | 41 |
|
44 |
- /** |
|
45 |
- * @expectedException \Twig\Error\SyntaxError |
|
46 |
- * @expectedExceptionMessage Unknown argument "unknown" for function "date(format, timestamp)". |
|
47 |
- */ |
|
48 | 42 |
public function testGetArgumentsWithWrongNamedArgumentName() |
49 | 43 |
{ |
44 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
45 |
+ $this->expectExceptionMessage('Unknown argument "unknown" for function "date(format, timestamp)".'); |
|
46 |
+ |
|
50 | 47 |
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'date']); |
51 | 48 |
$node->getArguments('date', ['Y-m-d', 'timestamp' => null, 'unknown' => '']); |
52 | 49 |
} |
53 | 50 |
|
54 |
- /** |
|
55 |
- * @expectedException \Twig\Error\SyntaxError |
|
56 |
- * @expectedExceptionMessage Unknown arguments "unknown1", "unknown2" for function "date(format, timestamp)". |
|
57 |
- */ |
|
58 | 51 |
public function testGetArgumentsWithWrongNamedArgumentNames() |
59 | 52 |
{ |
53 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
54 |
+ $this->expectExceptionMessage('Unknown arguments "unknown1", "unknown2" for function "date(format, timestamp)".'); |
|
55 |
+ |
|
60 | 56 |
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'date']); |
61 | 57 |
$node->getArguments('date', ['Y-m-d', 'timestamp' => null, 'unknown1' => '', 'unknown2' => '']); |
62 | 58 |
} |
63 | 59 |
|
64 |
- /** |
|
65 |
- * @expectedException \Twig\Error\SyntaxError |
|
66 |
- * @expectedExceptionMessage Argument "case_sensitivity" could not be assigned for function "substr_compare(main_str, str, offset, length, case_sensitivity)" because it is mapped to an internal PHP function which cannot determine default value for optional argument "length". |
|
67 |
- */ |
|
68 | 60 |
public function testResolveArgumentsWithMissingValueForOptionalArgument() |
69 | 61 |
{ |
62 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
63 |
+ $this->expectExceptionMessage('Argument "case_sensitivity" could not be assigned for function "substr_compare(main_str, str, offset, length, case_sensitivity)" because it is mapped to an internal PHP function which cannot determine default value for optional argument "length".'); |
|
64 |
+ |
|
70 | 65 |
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'substr_compare']); |
71 | 66 |
$node->getArguments('substr_compare', ['abcd', 'bc', 'offset' => 1, 'case_sensitivity' => true]); |
72 | 67 |
} |
... | ... |
@@ -84,12 +79,11 @@ class CallTest extends \PHPUnit\Framework\TestCase |
84 | 79 |
$this->assertEquals(['arg1'], $node->getArguments(__CLASS__.'::customStaticFunction', ['arg1' => 'arg1'])); |
85 | 80 |
} |
86 | 81 |
|
87 |
- /** |
|
88 |
- * @expectedException \LogicException |
|
89 |
- * @expectedExceptionMessage The last parameter of "Twig\Tests\Node\Expression\CallTest::customFunctionWithArbitraryArguments" for function "foo" must be an array with default value, eg. "array $arg = []". |
|
90 |
- */ |
|
91 | 82 |
public function testResolveArgumentsWithMissingParameterForArbitraryArguments() |
92 | 83 |
{ |
84 |
+ $this->expectException('\LogicException'); |
|
85 |
+ $this->expectExceptionMessage('The last parameter of "Twig\\Tests\\Node\\Expression\\CallTest::customFunctionWithArbitraryArguments" for function "foo" must be an array with default value, eg. "array $arg = []".'); |
|
86 |
+ |
|
93 | 87 |
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'foo', 'is_variadic' => true]); |
94 | 88 |
$node->getArguments([$this, 'customFunctionWithArbitraryArguments'], []); |
95 | 89 |
} |
... | ... |
@@ -106,22 +100,20 @@ class CallTest extends \PHPUnit\Framework\TestCase |
106 | 100 |
{ |
107 | 101 |
} |
108 | 102 |
|
109 |
- /** |
|
110 |
- * @expectedException \LogicException |
|
111 |
- * @expectedExceptionMessageRegExp #^The last parameter of "Twig\\Tests\\Node\\Expression\\custom_Twig_Tests_Node_Expression_CallTest_function" for function "foo" must be an array with default value, eg\. "array \$arg \= \[\]"\.$# |
|
112 |
- */ |
|
113 | 103 |
public function testResolveArgumentsWithMissingParameterForArbitraryArgumentsOnFunction() |
114 | 104 |
{ |
105 |
+ $this->expectException('\LogicException'); |
|
106 |
+ $this->expectExceptionMessageRegExp('#^The last parameter of "Twig\\\\Tests\\\\Node\\\\Expression\\\\custom_Twig_Tests_Node_Expression_CallTest_function" for function "foo" must be an array with default value, eg\\. "array \\$arg \\= \\[\\]"\\.$#'); |
|
107 |
+ |
|
115 | 108 |
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'foo', 'is_variadic' => true]); |
116 | 109 |
$node->getArguments('Twig\Tests\Node\Expression\custom_Twig_Tests_Node_Expression_CallTest_function', []); |
117 | 110 |
} |
118 | 111 |
|
119 |
- /** |
|
120 |
- * @expectedException \LogicException |
|
121 |
- * @expectedExceptionMessageRegExp #^The last parameter of "Twig\\Tests\\Node\\Expression\\CallableTestClass\:\:__invoke" for function "foo" must be an array with default value, eg\. "array \$arg \= \[\]"\.$# |
|
122 |
- */ |
|
123 | 112 |
public function testResolveArgumentsWithMissingParameterForArbitraryArgumentsOnObject() |
124 | 113 |
{ |
114 |
+ $this->expectException('\LogicException'); |
|
115 |
+ $this->expectExceptionMessageRegExp('#^The last parameter of "Twig\\\\Tests\\\\Node\\\\Expression\\\\CallableTestClass\\:\\:__invoke" for function "foo" must be an array with default value, eg\\. "array \\$arg \\= \\[\\]"\\.$#'); |
|
116 |
+ |
|
125 | 117 |
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'foo', 'is_variadic' => true]); |
126 | 118 |
$node->getArguments(new CallableTestClass(), []); |
127 | 119 |
} |
... | ... |
@@ -110,12 +110,11 @@ class FilterTest extends NodeTestCase |
110 | 110 |
return $tests; |
111 | 111 |
} |
112 | 112 |
|
113 |
- /** |
|
114 |
- * @expectedException \Twig\Error\SyntaxError |
|
115 |
- * @expectedExceptionMessage Unknown argument "foobar" for filter "date(format, timezone)" at line 1. |
|
116 |
- */ |
|
117 | 113 |
public function testCompileWithWrongNamedArgumentName() |
118 | 114 |
{ |
115 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
116 |
+ $this->expectExceptionMessage('Unknown argument "foobar" for filter "date(format, timezone)" at line 1.'); |
|
117 |
+ |
|
119 | 118 |
$date = new ConstantExpression(0, 1); |
120 | 119 |
$node = $this->createFilter($date, 'date', [ |
121 | 120 |
'foobar' => new ConstantExpression('America/Chicago', 1), |
... | ... |
@@ -125,12 +124,11 @@ class FilterTest extends NodeTestCase |
125 | 124 |
$compiler->compile($node); |
126 | 125 |
} |
127 | 126 |
|
128 |
- /** |
|
129 |
- * @expectedException \Twig\Error\SyntaxError |
|
130 |
- * @expectedExceptionMessage Value for argument "from" is required for filter "replace" at line 1. |
|
131 |
- */ |
|
132 | 127 |
public function testCompileWithMissingNamedArgument() |
133 | 128 |
{ |
129 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
130 |
+ $this->expectExceptionMessage('Value for argument "from" is required for filter "replace" at line 1.'); |
|
131 |
+ |
|
134 | 132 |
$value = new ConstantExpression(0, 1); |
135 | 133 |
$node = $this->createFilter($value, 'replace', [ |
136 | 134 |
'to' => new ConstantExpression('foo', 1), |
... | ... |
@@ -24,21 +24,19 @@ use Twig\TokenStream; |
24 | 24 |
|
25 | 25 |
class ParserTest extends \PHPUnit\Framework\TestCase |
26 | 26 |
{ |
27 |
- /** |
|
28 |
- * @expectedException \Twig\Error\SyntaxError |
|
29 |
- */ |
|
30 | 27 |
public function testSetMacroThrowsExceptionOnReservedMethods() |
31 | 28 |
{ |
29 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
30 |
+ |
|
32 | 31 |
$parser = $this->getParser(); |
33 | 32 |
$parser->setMacro('parent', new MacroNode('foo', new Node(), new Node(), 1)); |
34 | 33 |
} |
35 | 34 |
|
36 |
- /** |
|
37 |
- * @expectedException \Twig\Error\SyntaxError |
|
38 |
- * @expectedExceptionMessage Unknown "foo" tag. Did you mean "for" at line 1? |
|
39 |
- */ |
|
40 | 35 |
public function testUnknownTag() |
41 | 36 |
{ |
37 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
38 |
+ $this->expectExceptionMessage('Unknown "foo" tag. Did you mean "for" at line 1?'); |
|
39 |
+ |
|
42 | 40 |
$stream = new TokenStream([ |
43 | 41 |
new Token(Token::BLOCK_START_TYPE, '', 1), |
44 | 42 |
new Token(Token::NAME_TYPE, 'foo', 1), |
... | ... |
@@ -49,12 +47,11 @@ class ParserTest extends \PHPUnit\Framework\TestCase |
49 | 47 |
$parser->parse($stream); |
50 | 48 |
} |
51 | 49 |
|
52 |
- /** |
|
53 |
- * @expectedException \Twig\Error\SyntaxError |
|
54 |
- * @expectedExceptionMessage Unknown "foobar" tag at line 1. |
|
55 |
- */ |
|
56 | 50 |
public function testUnknownTagWithoutSuggestions() |
57 | 51 |
{ |
52 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
53 |
+ $this->expectExceptionMessage('Unknown "foobar" tag at line 1.'); |
|
54 |
+ |
|
58 | 55 |
$stream = new TokenStream([ |
59 | 56 |
new Token(Token::BLOCK_START_TYPE, '', 1), |
60 | 57 |
new Token(Token::NAME_TYPE, 'foobar', 1), |
... | ... |
@@ -95,10 +92,11 @@ class ParserTest extends \PHPUnit\Framework\TestCase |
95 | 92 |
|
96 | 93 |
/** |
97 | 94 |
* @dataProvider getFilterBodyNodesDataThrowsException |
98 |
- * @expectedException \Twig\Error\SyntaxError |
|
99 | 95 |
*/ |
100 | 96 |
public function testFilterBodyNodesThrowsException($input) |
101 | 97 |
{ |
98 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
99 |
+ |
|
102 | 100 |
$parser = $this->getParser(); |
103 | 101 |
|
104 | 102 |
$parser->filterBodyNodes($input); |
... | ... |
@@ -25,11 +25,10 @@ use Twig\Template; |
25 | 25 |
|
26 | 26 |
class TemplateTest extends \PHPUnit\Framework\TestCase |
27 | 27 |
{ |
28 |
- /** |
|
29 |
- * @expectedException \LogicException |
|
30 |
- */ |
|
31 | 28 |
public function testDisplayBlocksAcceptTemplateOnlyAsBlocks() |
32 | 29 |
{ |
30 |
+ $this->expectException('\LogicException'); |
|
31 |
+ |
|
33 | 32 |
$twig = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()); |
34 | 33 |
$template = new TemplateForTest($twig); |
35 | 34 |
$template->displayBlock('foo', [], ['foo' => [new \stdClass(), 'foo']]); |
... | ... |
@@ -110,7 +109,7 @@ class TemplateTest extends \PHPUnit\Framework\TestCase |
110 | 109 |
$this->addToAssertionCount(1); |
111 | 110 |
} |
112 | 111 |
|
113 |
- $this->assertContains('is not allowed', $e->getMessage()); |
|
112 |
+ $this->assertStringContainsString('is not allowed', $e->getMessage()); |
|
114 | 113 |
} |
115 | 114 |
} |
116 | 115 |
|
... | ... |
@@ -276,13 +275,9 @@ class TemplateTest extends \PHPUnit\Framework\TestCase |
276 | 275 |
if ($defined) { |
277 | 276 |
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type)); |
278 | 277 |
} else { |
279 |
- if (method_exists($this, 'expectException')) { |
|
280 |
- $this->expectException('\Twig\Error\RuntimeError'); |
|
281 |
- if (null !== $exceptionMessage) { |
|
282 |
- $this->expectExceptionMessage($exceptionMessage); |
|
283 |
- } |
|
284 |
- } else { |
|
285 |
- $this->setExpectedException('\Twig\Error\RuntimeError', $exceptionMessage); |
|
278 |
+ $this->expectException('\Twig\Error\RuntimeError'); |
|
279 |
+ if (null !== $exceptionMessage) { |
|
280 |
+ $this->expectExceptionMessage($exceptionMessage); |
|
286 | 281 |
} |
287 | 282 |
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type)); |
288 | 283 |
} |
... | ... |
@@ -449,11 +444,10 @@ class TemplateTest extends \PHPUnit\Framework\TestCase |
449 | 444 |
return $tests; |
450 | 445 |
} |
451 | 446 |
|
452 |
- /** |
|
453 |
- * @expectedException \Twig\Error\RuntimeError |
|
454 |
- */ |
|
455 | 447 |
public function testGetIsMethods() |
456 | 448 |
{ |
449 |
+ $this->expectException('\Twig\Error\RuntimeError'); |
|
450 |
+ |
|
457 | 451 |
$getIsObject = new TemplateGetIsMethods(); |
458 | 452 |
$template = new TemplateForTest(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['strict_variables' => true])); |
459 | 453 |
// first time should not create a cache for "get" |
... | ... |
@@ -56,12 +56,11 @@ class TokenStreamTest extends \PHPUnit\Framework\TestCase |
56 | 56 |
$this->assertEquals('1, 2, 3, 4, 5, 6, 7', implode(', ', $repr), '->next() advances the pointer and returns the current token'); |
57 | 57 |
} |
58 | 58 |
|
59 |
- /** |
|
60 |
- * @expectedException \Twig\Error\SyntaxError |
|
61 |
- * @expectedExceptionMessage Unexpected end of template |
|
62 |
- */ |
|
63 | 59 |
public function testEndOfTemplateNext() |
64 | 60 |
{ |
61 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
62 |
+ $this->expectExceptionMessage('Unexpected end of template'); |
|
63 |
+ |
|
65 | 64 |
$stream = new TokenStream([ |
66 | 65 |
new Token(Token::BLOCK_START_TYPE, 1, 1), |
67 | 66 |
]); |
... | ... |
@@ -70,12 +69,11 @@ class TokenStreamTest extends \PHPUnit\Framework\TestCase |
70 | 69 |
} |
71 | 70 |
} |
72 | 71 |
|
73 |
- /** |
|
74 |
- * @expectedException \Twig\Error\SyntaxError |
|
75 |
- * @expectedExceptionMessage Unexpected end of template |
|
76 |
- */ |
|
77 | 72 |
public function testEndOfTemplateLook() |
78 | 73 |
{ |
74 |
+ $this->expectException('\Twig\Error\SyntaxError'); |
|
75 |
+ $this->expectExceptionMessage('Unexpected end of template'); |
|
76 |
+ |
|
79 | 77 |
$stream = new TokenStream([ |
80 | 78 |
new Token(Token::BLOCK_START_TYPE, 1, 1), |
81 | 79 |
]); |