Skip to content

Commit f2173eb

Browse files
committed
feature #36034 [PhpUnitBridge] Deprecate @expectedDeprecation annotation (hkdobrev)
This PR was squashed before being merged into the 5.1-dev branch. Discussion ---------- [PhpUnitBridge] Deprecate @expectedDeprecation annotation | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | yes<!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | N/A | License | MIT | Doc PR | N/A Addresses https://github.com/orgs/symfony/projects/1#card-32934769 as a follow-up to #35192. Deprecating `@expectedDeprecation` annotation on tests in favour of the `expectDeprecation()` method similar to other PHPUnit deprecations of annotations in favour of methods. Commits ------- 36a57cc7c2 [PhpUnitBridge] Deprecate @expectedDeprecation annotation
2 parents 8245b6b + 49fe657 commit f2173eb

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Tests/Compiler/ResolveReferencesToAliasesPassTest.php

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

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1516
use Symfony\Component\DependencyInjection\Alias;
1617
use Symfony\Component\DependencyInjection\Compiler\ResolveReferencesToAliasesPass;
1718
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -20,6 +21,8 @@
2021

2122
class ResolveReferencesToAliasesPassTest extends TestCase
2223
{
24+
use ExpectDeprecationTrait;
25+
2326
public function testProcess()
2427
{
2528
$container = new ContainerBuilder();
@@ -83,10 +86,10 @@ public function testResolveFactory()
8386

8487
/**
8588
* @group legacy
86-
* @expectedDeprecation The "deprecated_foo_alias" service alias is deprecated. You should stop using it, as it will be removed in the future. It is being referenced by the "alias" alias.
8789
*/
8890
public function testDeprecationNoticeWhenReferencedByAlias()
8991
{
92+
$this->expectDeprecation('The "deprecated_foo_alias" service alias is deprecated. You should stop using it, as it will be removed in the future. It is being referenced by the "alias" alias.');
9093
$container = new ContainerBuilder();
9194

9295
$container->register('foo', 'stdClass');
@@ -103,10 +106,10 @@ public function testDeprecationNoticeWhenReferencedByAlias()
103106

104107
/**
105108
* @group legacy
106-
* @expectedDeprecation The "foo_aliased" service alias is deprecated. You should stop using it, as it will be removed in the future. It is being referenced by the "definition" service.
107109
*/
108110
public function testDeprecationNoticeWhenReferencedByDefinition()
109111
{
112+
$this->expectDeprecation('The "foo_aliased" service alias is deprecated. You should stop using it, as it will be removed in the future. It is being referenced by the "definition" service.');
110113
$container = new ContainerBuilder();
111114

112115
$container->register('foo', 'stdClass');

Tests/Dumper/PhpDumperTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Psr\Container\ContainerInterface;
16+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1617
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
1718
use Symfony\Component\Config\FileLocator;
1819
use Symfony\Component\DependencyInjection\Argument\AbstractArgument;
@@ -49,6 +50,8 @@
4950

5051
class PhpDumperTest extends TestCase
5152
{
53+
use ExpectDeprecationTrait;
54+
5255
protected static $fixturesPath;
5356

5457
public static function setUpBeforeClass(): void
@@ -410,10 +413,10 @@ public function testAliases()
410413

411414
/**
412415
* @group legacy
413-
* @expectedDeprecation The "alias_for_foo_deprecated" service alias is deprecated. You should stop using it, as it will be removed in the future.
414416
*/
415417
public function testAliasesDeprecation()
416418
{
419+
$this->expectDeprecation('The "alias_for_foo_deprecated" service alias is deprecated. You should stop using it, as it will be removed in the future.');
417420
$container = include self::$fixturesPath.'/containers/container_alias_deprecation.php';
418421
$container->compile();
419422
$dumper = new PhpDumper($container);
@@ -1192,10 +1195,10 @@ public function testAdawsonContainer()
11921195
* This test checks the trigger of a deprecation note and should not be removed in major releases.
11931196
*
11941197
* @group legacy
1195-
* @expectedDeprecation The "foo" service is deprecated. You should stop using it, as it will be removed in the future.
11961198
*/
11971199
public function testPrivateServiceTriggersDeprecation()
11981200
{
1201+
$this->expectDeprecation('The "foo" service is deprecated. You should stop using it, as it will be removed in the future.');
11991202
$container = new ContainerBuilder();
12001203
$container->register('foo', 'stdClass')
12011204
->setPublic(false)
@@ -1344,11 +1347,11 @@ public function testWither()
13441347

13451348
/**
13461349
* @group legacy
1347-
* @expectedDeprecation The "deprecated1" service alias is deprecated. You should stop using it, as it will be removed in the future.
1348-
* @expectedDeprecation The "deprecated2" service alias is deprecated. You should stop using it, as it will be removed in the future.
13491350
*/
13501351
public function testMultipleDeprecatedAliasesWorking()
13511352
{
1353+
$this->expectDeprecation('The "deprecated1" service alias is deprecated. You should stop using it, as it will be removed in the future.');
1354+
$this->expectDeprecation('The "deprecated2" service alias is deprecated. You should stop using it, as it will be removed in the future.');
13521355
$container = new ContainerBuilder();
13531356
$container->setDefinition('bar', new Definition('stdClass'))->setPublic(true);
13541357
$container->setAlias('deprecated1', 'bar')->setPublic(true)->setDeprecated('%alias_id% is deprecated');

0 commit comments

Comments
 (0)