Skip to content

Commit 6d50473

Browse files
Merge branch '4.3' into 4.4
* 4.3: Fix tests Fix deprecated phpunit annotation
2 parents edb38e1 + 7649a00 commit 6d50473

21 files changed

+110
-154
lines changed

Tests/Command/TranslationDebugCommandTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,9 @@ public function testDebugCustomDirectory()
117117
$this->assertRegExp('/unused/', $tester->getDisplay());
118118
}
119119

120-
/**
121-
* @expectedException \InvalidArgumentException
122-
*/
123120
public function testDebugInvalidDirectory()
124121
{
122+
$this->expectException('InvalidArgumentException');
125123
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
126124
$kernel->expects($this->once())
127125
->method('getBundle')

Tests/Command/YamlLintCommandTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,9 @@ public function testLintIncorrectFile()
6161
$this->assertContains('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay()));
6262
}
6363

64-
/**
65-
* @expectedException \RuntimeException
66-
*/
6764
public function testLintFileNotReadable()
6865
{
66+
$this->expectException('RuntimeException');
6967
$tester = $this->createCommandTester();
7068
$filename = $this->createFile('');
7169
unlink($filename);

Tests/Controller/AbstractControllerTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,10 @@ public function testGetParameter()
6666
$this->assertSame('bar', $controller->getParameter('foo'));
6767
}
6868

69-
/**
70-
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
71-
* @expectedExceptionMessage TestAbstractController::getParameter()" method is missing a parameter bag
72-
*/
7369
public function testMissingParameterBag()
7470
{
71+
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException');
72+
$this->expectExceptionMessage('TestAbstractController::getParameter()" method is missing a parameter bag');
7573
$container = new Container();
7674

7775
$controller = $this->createController();

Tests/Controller/ControllerTraitTest.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
1313

1414
use Fig\Link\Link;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Bundle\FrameworkBundle\Controller\ControllerTrait;
1617
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
1718
use Symfony\Component\DependencyInjection\Container;
@@ -32,6 +33,8 @@
3233

3334
abstract class ControllerTraitTest extends TestCase
3435
{
36+
use ForwardCompatTestTrait;
37+
3538
abstract protected function createController();
3639

3740
public function testForward()
@@ -88,12 +91,10 @@ public function testGetUserWithEmptyTokenStorage()
8891
$this->assertNull($controller->getUser());
8992
}
9093

91-
/**
92-
* @expectedException \LogicException
93-
* @expectedExceptionMessage The SecurityBundle is not registered in your application.
94-
*/
9594
public function testGetUserWithEmptyContainer()
9695
{
96+
$this->expectException('LogicException');
97+
$this->expectExceptionMessage('The SecurityBundle is not registered in your application.');
9798
$controller = $this->createController();
9899
$controller->setContainer(new Container());
99100

@@ -275,11 +276,9 @@ public function testFileFromPathWithCustomizedFileName()
275276
$this->assertContains('test.php', $response->headers->get('content-disposition'));
276277
}
277278

278-
/**
279-
* @expectedException \Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException
280-
*/
281279
public function testFileWhichDoesNotExist()
282280
{
281+
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
283282
$controller = $this->createController();
284283

285284
/* @var BinaryFileResponse $response */
@@ -300,11 +299,9 @@ public function testIsGranted()
300299
$this->assertTrue($controller->isGranted('foo'));
301300
}
302301

303-
/**
304-
* @expectedException \Symfony\Component\Security\Core\Exception\AccessDeniedException
305-
*/
306302
public function testdenyAccessUnlessGranted()
307303
{
304+
$this->expectException('Symfony\Component\Security\Core\Exception\AccessDeniedException');
308305
$authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock();
309306
$authorizationChecker->expects($this->once())->method('isGranted')->willReturn(false);
310307

Tests/Controller/TemplateControllerTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
1313

14+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1415
use Symfony\Bundle\FrameworkBundle\Controller\TemplateController;
1516
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
1617
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
@@ -20,6 +21,8 @@
2021
*/
2122
class TemplateControllerTest extends TestCase
2223
{
24+
use ForwardCompatTestTrait;
25+
2326
public function testTwig()
2427
{
2528
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock();
@@ -45,12 +48,10 @@ public function testTemplating()
4548
$this->assertEquals('bar', $controller('mytemplate')->getContent());
4649
}
4750

48-
/**
49-
* @expectedException \LogicException
50-
* @expectedExceptionMessage You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.
51-
*/
5251
public function testNoTwigNorTemplating()
5352
{
53+
$this->expectException('LogicException');
54+
$this->expectExceptionMessage('You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.');
5455
$controller = new TemplateController();
5556

5657
$controller->templateAction('mytemplate')->getContent();

Tests/DependencyInjection/Compiler/CachePoolPassTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,10 @@ public function testWithNameAttribute()
114114
$this->assertSame('+naTpPa4Sm', $cachePool->getArgument(1));
115115
}
116116

117-
/**
118-
* @expectedException \InvalidArgumentException
119-
* @expectedExceptionMessage Invalid "cache.pool" tag for service "app.cache_pool": accepted attributes are
120-
*/
121117
public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes()
122118
{
119+
$this->expectException('InvalidArgumentException');
120+
$this->expectExceptionMessage('Invalid "cache.pool" tag for service "app.cache_pool": accepted attributes are');
123121
$container = new ContainerBuilder();
124122
$container->setParameter('kernel.container_class', 'app');
125123
$container->setParameter('kernel.project_dir', 'foo');

Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPrunerPass;
1617
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
1718
use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
@@ -24,6 +25,8 @@
2425
*/
2526
class CachePoolPrunerPassTest extends TestCase
2627
{
28+
use ForwardCompatTestTrait;
29+
2730
public function testCompilerPassReplacesCommandArgument()
2831
{
2932
$container = new ContainerBuilder();
@@ -59,12 +62,10 @@ public function testCompilePassIsIgnoredIfCommandDoesNotExist()
5962
$this->assertCount($aliasesBefore, $container->getAliases());
6063
}
6164

62-
/**
63-
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
64-
* @expectedExceptionMessage Class "Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\NotFound" used for service "pool.not-found" cannot be found.
65-
*/
6665
public function testCompilerPassThrowsOnInvalidDefinitionClass()
6766
{
67+
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
68+
$this->expectExceptionMessage('Class "Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\NotFound" used for service "pool.not-found" cannot be found.');
6869
$container = new ContainerBuilder();
6970
$container->register('console.command.cache_pool_prune')->addArgument([]);
7071
$container->register('pool.not-found', NotFound::class)->addTag('cache.pool');

Tests/DependencyInjection/Compiler/ProfilerPassTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,25 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718

1819
class ProfilerPassTest extends TestCase
1920
{
21+
use ForwardCompatTestTrait;
22+
2023
/**
2124
* Tests that collectors that specify a template but no "id" will throw
2225
* an exception (both are needed if the template is specified).
2326
*
2427
* Thus, a fully-valid tag looks something like this:
2528
*
2629
* <tag name="data_collector" template="YourBundle:Collector:templatename" id="your_collector_name" />
27-
*
28-
* @expectedException \InvalidArgumentException
2930
*/
3031
public function testTemplateNoIdThrowsException()
3132
{
33+
$this->expectException('InvalidArgumentException');
3234
$builder = new ContainerBuilder();
3335
$builder->register('profiler', 'ProfilerClass');
3436
$builder->register('my_collector_service')

Tests/DependencyInjection/Compiler/WorkflowGuardListenerPassTest.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,10 @@ public function testNoExeptionIfAllDependenciesArePresent()
5555
$this->assertFalse($this->container->hasParameter('workflow.has_guard_listeners'));
5656
}
5757

58-
/**
59-
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
60-
* @expectedExceptionMessage The "security.token_storage" service is needed to be able to use the workflow guard listener.
61-
*/
6258
public function testExceptionIfTheTokenStorageServiceIsNotPresent()
6359
{
60+
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
61+
$this->expectExceptionMessage('The "security.token_storage" service is needed to be able to use the workflow guard listener.');
6462
$this->container->setParameter('workflow.has_guard_listeners', true);
6563
$this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class);
6664
$this->container->register('security.authentication.trust_resolver', AuthenticationTrustResolverInterface::class);
@@ -69,12 +67,10 @@ public function testExceptionIfTheTokenStorageServiceIsNotPresent()
6967
$this->compilerPass->process($this->container);
7068
}
7169

72-
/**
73-
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
74-
* @expectedExceptionMessage The "security.authorization_checker" service is needed to be able to use the workflow guard listener.
75-
*/
7670
public function testExceptionIfTheAuthorizationCheckerServiceIsNotPresent()
7771
{
72+
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
73+
$this->expectExceptionMessage('The "security.authorization_checker" service is needed to be able to use the workflow guard listener.');
7874
$this->container->setParameter('workflow.has_guard_listeners', true);
7975
$this->container->register('security.token_storage', TokenStorageInterface::class);
8076
$this->container->register('security.authentication.trust_resolver', AuthenticationTrustResolverInterface::class);
@@ -83,12 +79,10 @@ public function testExceptionIfTheAuthorizationCheckerServiceIsNotPresent()
8379
$this->compilerPass->process($this->container);
8480
}
8581

86-
/**
87-
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
88-
* @expectedExceptionMessage The "security.authentication.trust_resolver" service is needed to be able to use the workflow guard listener.
89-
*/
9082
public function testExceptionIfTheAuthenticationTrustResolverServiceIsNotPresent()
9183
{
84+
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
85+
$this->expectExceptionMessage('The "security.authentication.trust_resolver" service is needed to be able to use the workflow guard listener.');
9286
$this->container->setParameter('workflow.has_guard_listeners', true);
9387
$this->container->register('security.token_storage', TokenStorageInterface::class);
9488
$this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class);
@@ -97,12 +91,10 @@ public function testExceptionIfTheAuthenticationTrustResolverServiceIsNotPresent
9791
$this->compilerPass->process($this->container);
9892
}
9993

100-
/**
101-
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
102-
* @expectedExceptionMessage The "security.role_hierarchy" service is needed to be able to use the workflow guard listener.
103-
*/
10494
public function testExceptionIfTheRoleHierarchyServiceIsNotPresent()
10595
{
96+
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
97+
$this->expectExceptionMessage('The "security.role_hierarchy" service is needed to be able to use the workflow guard listener.');
10698
$this->container->setParameter('workflow.has_guard_listeners', true);
10799
$this->container->register('security.token_storage', TokenStorageInterface::class);
108100
$this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class);

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ public function getTestValidSessionName()
6666

6767
/**
6868
* @dataProvider getTestInvalidSessionName
69-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
7069
*/
7170
public function testInvalidSessionName($sessionName)
7271
{
72+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
7373
$processor = new Processor();
7474
$processor->processConfiguration(
7575
new Configuration(true),

0 commit comments

Comments
 (0)