Skip to content

Commit bf44ce8

Browse files
committed
Fix deprecated phpunit annotation
1 parent 7f5991d commit bf44ce8

File tree

6 files changed

+34
-46
lines changed

6 files changed

+34
-46
lines changed

Tests/DependencyInjection/Compiler/AddSecurityVotersPassTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ class AddSecurityVotersPassTest extends TestCase
2424
{
2525
use ForwardCompatTestTrait;
2626

27-
/**
28-
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
29-
*/
3027
public function testNoVoters()
3128
{
29+
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
3230
$container = new ContainerBuilder();
3331
$container
3432
->register('security.access.decision_manager', AccessDecisionManager::class)

Tests/DependencyInjection/CompleteConfigurationTest.php

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

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
1617
use Symfony\Bundle\SecurityBundle\SecurityBundle;
1718
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
@@ -22,6 +23,8 @@
2223

2324
abstract class CompleteConfigurationTest extends TestCase
2425
{
26+
use ForwardCompatTestTrait;
27+
2528
abstract protected function getLoader(ContainerBuilder $container);
2629

2730
abstract protected function getFileExtension();
@@ -553,12 +556,10 @@ public function testCustomAccessDecisionManagerService()
553556
$this->assertSame('app.access_decision_manager', (string) $container->getAlias('security.access.decision_manager'), 'The custom access decision manager service is aliased');
554557
}
555558

556-
/**
557-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
558-
* @expectedExceptionMessage Invalid configuration for path "security.access_decision_manager": "strategy" and "service" cannot be used together.
559-
*/
560559
public function testAccessDecisionManagerServiceAndStrategyCannotBeUsedAtTheSameTime()
561560
{
561+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
562+
$this->expectExceptionMessage('Invalid configuration for path "security.access_decision_manager": "strategy" and "service" cannot be used together.');
562563
$this->getContainer('access_decision_manager_service_and_strategy');
563564
}
564565

@@ -573,21 +574,17 @@ public function testAccessDecisionManagerOptionsAreNotOverriddenByImplicitStrate
573574
$this->assertFalse($accessDecisionManagerDefinition->getArgument(3));
574575
}
575576

576-
/**
577-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
578-
* @expectedExceptionMessage Invalid firewall "main": user provider "undefined" not found.
579-
*/
580577
public function testFirewallUndefinedUserProvider()
581578
{
579+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
580+
$this->expectExceptionMessage('Invalid firewall "main": user provider "undefined" not found.');
582581
$this->getContainer('firewall_undefined_provider');
583582
}
584583

585-
/**
586-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
587-
* @expectedExceptionMessage Invalid firewall "main": user provider "undefined" not found.
588-
*/
589584
public function testFirewallListenerUndefinedProvider()
590585
{
586+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
587+
$this->expectExceptionMessage('Invalid firewall "main": user provider "undefined" not found.');
591588
$this->getContainer('listener_undefined_provider');
592589
}
593590

Tests/DependencyInjection/MainConfigurationTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Bundle\SecurityBundle\DependencyInjection\MainConfiguration;
1617
use Symfony\Component\Config\Definition\Processor;
1718

1819
class MainConfigurationTest extends TestCase
1920
{
21+
use ForwardCompatTestTrait;
22+
2023
/**
2124
* The minimal, required config needed to not have any required validation
2225
* issues.
@@ -33,11 +36,9 @@ class MainConfigurationTest extends TestCase
3336
],
3437
];
3538

36-
/**
37-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
38-
*/
3939
public function testNoConfigForProvider()
4040
{
41+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
4142
$config = [
4243
'providers' => [
4344
'stub' => [],
@@ -49,11 +50,9 @@ public function testNoConfigForProvider()
4950
$processor->processConfiguration($configuration, [$config]);
5051
}
5152

52-
/**
53-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
54-
*/
5553
public function testManyConfigForProvider()
5654
{
55+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
5756
$config = [
5857
'providers' => [
5958
'stub' => [

Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Security\Factory;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\GuardAuthenticationFactory;
1617
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
1718
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
@@ -20,6 +21,8 @@
2021

2122
class GuardAuthenticationFactoryTest extends TestCase
2223
{
24+
use ForwardCompatTestTrait;
25+
2326
/**
2427
* @dataProvider getValidConfigurationTests
2528
*/
@@ -37,11 +40,11 @@ public function testAddValidConfiguration(array $inputConfig, array $expectedCon
3740
}
3841

3942
/**
40-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
4143
* @dataProvider getInvalidConfigurationTests
4244
*/
4345
public function testAddInvalidConfiguration(array $inputConfig)
4446
{
47+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
4548
$factory = new GuardAuthenticationFactory();
4649
$nodeDefinition = new ArrayNodeDefinition('guard');
4750
$factory->addConfiguration($nodeDefinition);
@@ -130,11 +133,9 @@ public function testExistingDefaultEntryPointUsed()
130133
$this->assertEquals('some_default_entry_point', $entryPointId);
131134
}
132135

133-
/**
134-
* @expectedException \LogicException
135-
*/
136136
public function testCannotOverrideDefaultEntryPoint()
137137
{
138+
$this->expectException('LogicException');
138139
// any existing default entry point is used
139140
$config = [
140141
'authenticators' => ['authenticator123'],
@@ -143,11 +144,9 @@ public function testCannotOverrideDefaultEntryPoint()
143144
$this->executeCreate($config, 'some_default_entry_point');
144145
}
145146

146-
/**
147-
* @expectedException \LogicException
148-
*/
149147
public function testMultipleAuthenticatorsRequiresEntryPoint()
150148
{
149+
$this->expectException('LogicException');
151150
// any existing default entry point is used
152151
$config = [
153152
'authenticators' => ['authenticator123', 'authenticatorABC'],

Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@
1212
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
1617
use Symfony\Bundle\SecurityBundle\SecurityBundle;
1718
use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider\DummyProvider;
1819
use Symfony\Component\DependencyInjection\ContainerBuilder;
1920

2021
class SecurityExtensionTest extends TestCase
2122
{
22-
/**
23-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
24-
* @expectedExceptionMessage The check_path "/some_area/login_check" for login method "form_login" is not matched by the firewall pattern "/secured_area/.*".
25-
*/
23+
use ForwardCompatTestTrait;
24+
2625
public function testInvalidCheckPath()
2726
{
27+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
28+
$this->expectExceptionMessage('The check_path "/some_area/login_check" for login method "form_login" is not matched by the firewall pattern "/secured_area/.*".');
2829
$container = $this->getRawContainer();
2930

3031
$container->loadFromExtension('security', [
@@ -46,12 +47,10 @@ public function testInvalidCheckPath()
4647
$container->compile();
4748
}
4849

49-
/**
50-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
51-
* @expectedExceptionMessage No authentication listener registered for firewall "some_firewall"
52-
*/
5350
public function testFirewallWithoutAuthenticationListener()
5451
{
52+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
53+
$this->expectExceptionMessage('No authentication listener registered for firewall "some_firewall"');
5554
$container = $this->getRawContainer();
5655

5756
$container->loadFromExtension('security', [
@@ -70,12 +69,10 @@ public function testFirewallWithoutAuthenticationListener()
7069
$container->compile();
7170
}
7271

73-
/**
74-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
75-
* @expectedExceptionMessage Unable to create definition for "security.user.provider.concrete.my_foo" user provider
76-
*/
7772
public function testFirewallWithInvalidUserProvider()
7873
{
74+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
75+
$this->expectExceptionMessage('Unable to create definition for "security.user.provider.concrete.my_foo" user provider');
7976
$container = $this->getRawContainer();
8077

8178
$extension = $container->getExtension('security');
@@ -186,11 +183,11 @@ public function testConfiguresLogoutOnUserChangeForContextListenersCorrectly()
186183

187184
/**
188185
* @group legacy
189-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
190-
* @expectedExceptionMessage Firewalls "some_firewall" and "some_other_firewall" need to have the same value for option "logout_on_user_change" as they are sharing the context "my_context"
191186
*/
192187
public function testThrowsIfLogoutOnUserChangeDifferentForSharedContext()
193188
{
189+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
190+
$this->expectExceptionMessage('Firewalls "some_firewall" and "some_other_firewall" need to have the same value for option "logout_on_user_change" as they are sharing the context "my_context"');
194191
$container = $this->getRawContainer();
195192

196193
$container->loadFromExtension('security', [

Tests/Functional/UserPasswordEncoderCommandTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,10 @@ public function testNonInteractiveEncodePasswordUsesFirstUserClass()
208208
$this->assertContains('Encoder used Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder', $this->passwordEncoderCommandTester->getDisplay());
209209
}
210210

211-
/**
212-
* @expectedException \RuntimeException
213-
* @expectedExceptionMessage There are no configured encoders for the "security" extension.
214-
*/
215211
public function testThrowsExceptionOnNoConfiguredEncoders()
216212
{
213+
$this->expectException('RuntimeException');
214+
$this->expectExceptionMessage('There are no configured encoders for the "security" extension.');
217215
$application = new ConsoleApplication();
218216
$application->add(new UserPasswordEncoderCommand($this->getMockBuilder(EncoderFactoryInterface::class)->getMock(), []));
219217

0 commit comments

Comments
 (0)