Skip to content

Commit d93befd

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: fix typo remove the WriteConfig class DX: PHP CS Fixer - keep Annotation,NamedArgumentConstructor,Target annotations as single group do not install FrameworkBundle 6.4 [Tests] Add `array` return type for provider methods [Tests] Move expectException closer to the place of the expectation to avoid false positives
2 parents be241e2 + fccfb9f commit d93befd

File tree

9 files changed

+47
-26
lines changed

9 files changed

+47
-26
lines changed

Tests/Command/TranslationDebugCommandTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,16 @@ public function testDebugCustomDirectory()
118118

119119
public function testDebugInvalidDirectory()
120120
{
121-
$this->expectException(\InvalidArgumentException::class);
122121
$kernel = $this->createMock(KernelInterface::class);
123122
$kernel->expects($this->once())
124123
->method('getBundle')
125124
->with($this->equalTo('dir'))
126125
->willThrowException(new \InvalidArgumentException());
127126

128127
$tester = $this->createCommandTester([], [], $kernel);
128+
129+
$this->expectException(\InvalidArgumentException::class);
130+
129131
$tester->execute(['locale' => 'en', 'bundle' => 'dir']);
130132
}
131133

Tests/Command/YamlLintCommandTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ public function testLintIncorrectFile()
6060

6161
public function testLintFileNotReadable()
6262
{
63-
$this->expectException(\RuntimeException::class);
6463
$tester = $this->createCommandTester();
6564
$filename = $this->createFile('');
6665
unlink($filename);
6766

67+
$this->expectException(\RuntimeException::class);
68+
6869
$tester->execute(['filename' => $filename], ['decorated' => false]);
6970
}
7071

Tests/Controller/AbstractControllerTest.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,14 @@ public function testGetParameter()
9292

9393
public function testMissingParameterBag()
9494
{
95-
$this->expectException(ServiceNotFoundException::class);
96-
$this->expectExceptionMessage('TestAbstractController::getParameter()" method is missing a parameter bag');
9795
$container = new Container();
9896

9997
$controller = $this->createController();
10098
$controller->setContainer($container);
10199

100+
$this->expectException(ServiceNotFoundException::class);
101+
$this->expectExceptionMessage('TestAbstractController::getParameter()" method is missing a parameter bag');
102+
102103
$controller->getParameter('foo');
103104
}
104105

@@ -146,12 +147,12 @@ public function testGetUserWithEmptyTokenStorage()
146147

147148
public function testGetUserWithEmptyContainer()
148149
{
149-
$this->expectException(\LogicException::class);
150-
$this->expectExceptionMessage('The SecurityBundle is not registered in your application.');
151-
152150
$controller = $this->createController();
153151
$controller->setContainer(new Container());
154152

153+
$this->expectException(\LogicException::class);
154+
$this->expectExceptionMessage('The SecurityBundle is not registered in your application.');
155+
155156
$controller->getUser();
156157
}
157158

@@ -327,10 +328,10 @@ public function testFileFromPathWithCustomizedFileName()
327328

328329
public function testFileWhichDoesNotExist()
329330
{
330-
$this->expectException(FileNotFoundException::class);
331-
332331
$controller = $this->createController();
333332

333+
$this->expectException(FileNotFoundException::class);
334+
334335
$controller->file('some-file.txt', 'test.php');
335336
}
336337

@@ -350,8 +351,6 @@ public function testIsGranted()
350351

351352
public function testdenyAccessUnlessGranted()
352353
{
353-
$this->expectException(AccessDeniedException::class);
354-
355354
$authorizationChecker = $this->createMock(AuthorizationCheckerInterface::class);
356355
$authorizationChecker->expects($this->once())->method('isGranted')->willReturn(false);
357356

@@ -361,6 +360,8 @@ public function testdenyAccessUnlessGranted()
361360
$controller = $this->createController();
362361
$controller->setContainer($container);
363362

363+
$this->expectException(AccessDeniedException::class);
364+
364365
$controller->denyAccessUnlessGranted('foo');
365366
}
366367

Tests/Controller/TemplateControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testNoTwigInvokeMethod()
4747
$controller = new TemplateController();
4848

4949
$this->expectException(\LogicException::class);
50-
$this->expectExceptionMessage('You cannot use the TemplateController if the Twig Bundle is not available.');
50+
$this->expectExceptionMessage('You cannot use the TemplateController if the Twig Bundle is not available. Try running "composer require symfony/twig-bundle".');
5151

5252
$controller('mytemplate')->getContent();
5353
}

Tests/DependencyInjection/Compiler/ProfilerPassTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ class ProfilerPassTest extends TestCase
3434
*/
3535
public function testTemplateNoIdThrowsException()
3636
{
37-
$this->expectException(\InvalidArgumentException::class);
3837
$builder = new ContainerBuilder();
3938
$builder->register('profiler', 'ProfilerClass');
4039
$builder->register('my_collector_service')
4140
->addTag('data_collector', ['template' => 'foo']);
4241

4342
$profilerPass = new ProfilerPass();
43+
44+
$this->expectException(\InvalidArgumentException::class);
45+
4446
$profilerPass->process($builder);
4547
}
4648

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ public function getTestValidSessionName()
6161
*/
6262
public function testInvalidSessionName($sessionName)
6363
{
64-
$this->expectException(InvalidConfigurationException::class);
6564
$processor = new Processor();
65+
66+
$this->expectException(InvalidConfigurationException::class);
67+
6668
$processor->processConfiguration(
6769
new Configuration(true),
6870
[[
@@ -177,11 +179,12 @@ public static function provideValidAssetsPackageNameConfigurationTests(): array
177179
*/
178180
public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMessage)
179181
{
182+
$processor = new Processor();
183+
$configuration = new Configuration(true);
184+
180185
$this->expectException(InvalidConfigurationException::class);
181186
$this->expectExceptionMessage($expectedMessage);
182187

183-
$processor = new Processor();
184-
$configuration = new Configuration(true);
185188
$processor->processConfiguration($configuration, [
186189
[
187190
'http_method_override' => false,

Tests/DependencyInjection/FrameworkExtensionTestCase.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,9 +628,11 @@ public function testRouter()
628628

629629
public function testRouterRequiresResourceOption()
630630
{
631-
$this->expectException(InvalidConfigurationException::class);
632631
$container = $this->createContainer();
633632
$loader = new FrameworkExtension();
633+
634+
$this->expectException(InvalidConfigurationException::class);
635+
634636
$loader->load([['http_method_override' => false, 'handle_all_throwables' => true, 'php_errors' => ['log' => true], 'router' => true]], $container);
635637
}
636638

Tests/Functional/RouterDebugCommandTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ public function testSearchMultipleRoutesWithoutInteraction()
8181

8282
public function testSearchWithThrow()
8383
{
84+
$tester = $this->createCommandTester();
85+
8486
$this->expectException(\InvalidArgumentException::class);
8587
$this->expectExceptionMessage('The route "gerard" does not exist.');
86-
$tester = $this->createCommandTester();
88+
8789
$tester->execute(['name' => 'gerard'], ['interactive' => true]);
8890
}
8991

Tests/Routing/RouterTest.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -299,25 +299,29 @@ public function testPatternPlaceholdersWithSfContainer()
299299

300300
public function testEnvPlaceholders()
301301
{
302-
$this->expectException(RuntimeException::class);
303-
$this->expectExceptionMessage('Using "%env(FOO)%" is not allowed in routing configuration.');
304302
$routes = new RouteCollection();
305303

306304
$routes->add('foo', new Route('/%env(FOO)%'));
307305

308306
$router = new Router($this->getPsr11ServiceContainer($routes), 'foo', [], null, $this->getParameterBag());
307+
308+
$this->expectException(RuntimeException::class);
309+
$this->expectExceptionMessage('Using "%env(FOO)%" is not allowed in routing configuration.');
310+
309311
$router->getRouteCollection();
310312
}
311313

312314
public function testEnvPlaceholdersWithSfContainer()
313315
{
314-
$this->expectException(RuntimeException::class);
315-
$this->expectExceptionMessage('Using "%env(FOO)%" is not allowed in routing configuration.');
316316
$routes = new RouteCollection();
317317

318318
$routes->add('foo', new Route('/%env(FOO)%'));
319319

320320
$router = new Router($this->getServiceContainer($routes), 'foo');
321+
322+
$this->expectException(RuntimeException::class);
323+
$this->expectExceptionMessage('Using "%env(FOO)%" is not allowed in routing configuration.');
324+
321325
$router->getRouteCollection();
322326
}
323327

@@ -381,22 +385,22 @@ public function testHostPlaceholdersWithSfContainer()
381385

382386
public function testExceptionOnNonExistentParameterWithSfContainer()
383387
{
384-
$this->expectException(ParameterNotFoundException::class);
385-
$this->expectExceptionMessage('You have requested a non-existent parameter "nope".');
386388
$routes = new RouteCollection();
387389

388390
$routes->add('foo', new Route('/%nope%'));
389391

390392
$sc = $this->getServiceContainer($routes);
391393

392394
$router = new Router($sc, 'foo');
395+
396+
$this->expectException(ParameterNotFoundException::class);
397+
$this->expectExceptionMessage('You have requested a non-existent parameter "nope".');
398+
393399
$router->getRouteCollection()->get('foo');
394400
}
395401

396402
public function testExceptionOnNonStringParameter()
397403
{
398-
$this->expectException(RuntimeException::class);
399-
$this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type "stdClass".');
400404
$routes = new RouteCollection();
401405

402406
$routes->add('foo', new Route('/%object%'));
@@ -405,6 +409,10 @@ public function testExceptionOnNonStringParameter()
405409
$parameters = $this->getParameterBag(['object' => new \stdClass()]);
406410

407411
$router = new Router($sc, 'foo', [], null, $parameters);
412+
413+
$this->expectException(RuntimeException::class);
414+
$this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type "stdClass".');
415+
408416
$router->getRouteCollection()->get('foo');
409417
}
410418

0 commit comments

Comments
 (0)