8000 [PhpUnitBridge] Add ExpectUserDeprecationMessageTrait · symfony/symfony@24ff1b6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 24ff1b6

Browse files
committed
[PhpUnitBridge] Add ExpectUserDeprecationMessageTrait
1 parent df033a0 commit 24ff1b6

File tree

11 files changed

+67
-42
lines changed

11 files changed

+67
-42
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\PhpUnit;
13+
14+
use PHPUnit\Runner\Version;
15+
16+
if (version_compare(Version::id(), '11.0.0', '<')) {
17+
trait ExpectUserDeprecationMessageTrait
18+
{
19+
use ExpectDeprecationTrait;
20+
21+
final protected function expectUserDeprecationMessage(string $expectedUserDeprecationMessage): void
22+
{
23+
$this->expectDeprecation($expectedUserDeprecationMessage);
24+
}
25+
}
26+
} else {
27+
trait ExpectUserDeprecationMessageTrait
28+
{
29+
}
30+
}

src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapConfigReaderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\AssetMapper\Tests\ImportMap;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
15+
use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait;
1616
use Symfony\Component\AssetMapper\ImportMap\ImportMapConfigReader;
1717
use Symfony\Component\AssetMapper\ImportMap\ImportMapEntries;
1818
use Symfony\Component\AssetMapper\ImportMap\ImportMapEntry;
@@ -22,7 +22,7 @@
2222

2323
class ImportMapConfigReaderTest extends TestCase
2424
{
25-
use ExpectDeprecationTrait;
25+
use ExpectUserDeprecationMessageTrait;
2626

2727
private Filesystem $filesystem;
2828

@@ -171,7 +171,7 @@ public function testFindRootImportMapEntry()
171171
*/
172172
public function testDeprecatedMethodTriggerDeprecation()
173173
{
174-
$this->expectDeprecation('Since symfony/asset-mapper 7.1: The method "Symfony\Component\AssetMapper\ImportMap\ImportMapConfigReader::splitPackageNameAndFilePath()" is deprecated and will be removed in 8.0. Use ImportMapEntry::splitPackageNameAndFilePath() instead.');
174+
$this->expectUserDeprecationMessage('Since symfony/asset-mapper 7.1: The method "Symfony\Component\AssetMapper\ImportMap\ImportMapConfigReader::splitPackageNameAndFilePath()" is deprecated and will be removed in 8.0. Use ImportMapEntry::splitPackageNameAndFilePath() instead.');
175175
ImportMapConfigReader::splitPackageNameAndFilePath('foo');
176176
}
177177
}

src/Symfony/Component/Cache/Tests/Adapter/CouchbaseBucketAdapterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\Cache\Tests\Adapter;
1313

1414
use Psr\Cache\CacheItemPoolInterface;
15-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
15+
use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait;
1616
use Symfony\Component\Cache\Adapter\AbstractAdapter;
1717
use Symfony\Component\Cache\Adapter\CouchbaseBucketAdapter;
1818

@@ -26,7 +26,7 @@
2626
*/
2727
class CouchbaseBucketAdapterTest extends AdapterTestCase
2828
{
29-
use ExpectDeprecationTrait;
29+
use ExpectUserDeprecationMessageTrait;
3030

3131
protected $skippedTests = [
3232
'testClearPrefix' => 'Couchbase cannot clear by prefix',
@@ -36,7 +36,7 @@ class CouchbaseBucketAdapterTest extends AdapterTestCase
3636

3737
protected function setUp(): void
3838
{
39-
$this->expectDeprecation('Since symfony/cache 7.1: The "Symfony\Component\Cache\Adapter\CouchbaseBucketAdapter" class is deprecated, use "Symfony\Component\Cache\Adapter\CouchbaseCollectionAdapter" instead.');
39+
$this->expectUserDeprecationMessage('Since symfony/cache 7.1: The "Symfony\Component\Cache\Adapter\CouchbaseBucketAdapter" class is deprecated, use "Symfony\Component\Cache\Adapter\CouchbaseCollectionAdapter" instead.');
4040

4141
$this->client = AbstractAdapter::createConnection('couchbase://'.getenv('COUCHBASE_HOST').'/cache',
4242
['username' => getenv('COUCHBASE_USER'), 'password' => getenv('COUCHBASE_PASS')]

src/Symfony/Component/Cache/Tests/Adapter/CouchbaseCollectionAdapterTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,25 @@
1212
namespace Symfony\Component\Cache\Tests\Adapter;
1313

1414
use Psr\Cache\CacheItemPoolInterface;
15-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1615
use Symfony\Component\Cache\Adapter\AbstractAdapter;
1716
use Symfony\Component\Cache\Adapter\CouchbaseCollectionAdapter;
1817

1918
/**
2019
* @requires extension couchbase <4.0.0
2120
* @requires extension couchbase >=3.0.5
2221
*
23-
* @group legacy integration
22+
* @group integration
2423
*
2524
* @author Antonio Jose Cerezo Aranda <aj.cerezo@gmail.com>
2625
*/
2726
class CouchbaseCollectionAdapterTest extends AdapterTestCase
2827
{
29-
use ExpectDeprecationTrait;
30-
3128
protected $skippedTests = [
3229
'testClearPrefix' => 'Couchbase cannot clear by prefix',
3330
];
3431

3532
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
3633
{
37-
$this->expectDeprecation('Since symfony/cache 7.1: The "Symfony\Component\Cache\Adapter\CouchbaseBucketAdapter" class is deprecated, use "Symfony\Component\Cache\Adapter\CouchbaseCollectionAdapter" instead.');
38-
3934
$client = AbstractAdapter::createConnection('couchbase://'.getenv('COUCHBASE_HOST').'/cache',
4035
['username' => getenv('COUCHBASE_USER'), 'password' => getenv('COUCHBASE_PASS')]
4136
);

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php

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

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
15+
use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait;
1616
use Symfony\Component\DependencyInjection\Alias;
1717
use Symfony\Component\DependencyInjection\Compiler\ResolveReferencesToAliasesPass;
1818
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -22,7 +22,7 @@
2222

2323
class ResolveReferencesToAliasesPassTest extends TestCase
2424
{
25-
use ExpectDeprecationTrait;
25+
use ExpectUserDeprecationMessageTrait;
2626

2727
public function testProcess()
2828
{
@@ -92,7 +92,7 @@ public function testResolveFactory()
9292
*/
9393
public function testDeprecationNoticeWhenReferencedByAlias()
9494
{
95-
$this->expectDeprecation('Since foobar 1.2.3.4: 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.');
95+
$this->expectUserDeprecationMessage('Since foobar 1.2.3.4: 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.');
9696
$container = new ContainerBuilder();
9797

9898
$container->register('foo', 'stdClass');
@@ -114,7 +114,7 @@ public function testDeprecationNoticeWhenReferencedByAlias()
114114
*/
115115
public function testDeprecationNoticeWhenReferencedByDefinition()
116116
{
117-
$this->expectDeprecation('Since foobar 1.2.3.4: 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.');
117+
$this->expectUserDeprecationMessage('Since foobar 1.2.3.4: 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.');
118118
$container = new ContainerBuilder();
119119

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

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
require_once __DIR__.'/Fixtures/includes/ProjectExtension.php';
1717

1818
use PHPUnit\Framework\TestCase;
19-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
19+
use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait;
2020
use Symfony\Component\Config\Resource\DirectoryResource;
2121
use Symfony\Component\Config\Resource\FileResource;
2222
use Symfony\Component\Config\Resource\ResourceInterface;
@@ -62,7 +62,7 @@
6262

6363
class ContainerBuilderTest extends TestCase
6464
{
65-
use ExpectDeprecationTrait;
65+
use ExpectUserDeprecationMessageTrait;
6666

6767
public function testDefaultRegisteredDefinitions()
6868
{
@@ -116,7 +116,7 @@ public function testDeprecateParameter()
116116

117117
$builder->deprecateParameter('foo', 'symfony/test', '6.3');
118118

119-
$this->expectDeprecation('Since symfony/test 6.3: The parameter "foo" is deprecated.');
119+
$this->expectUserDeprecationMessage('Since symfony/test 6.3: The parameter "foo" is deprecated.');
120120

121121
$builder->getParameter('foo');
122122
}
@@ -134,7 +134,7 @@ public function testParameterDeprecationIsTrgiggeredWhenCompiled()
134134

135135
$builder->deprecateParameter('bar', 'symfony/test', '6.3');
136136

137-
$this->expectDeprecation('Since symfony/test 6.3: The parameter "bar" is deprecated.');
137+
$this->expectUserDeprecationMessage('Since symfony/test 6.3: The parameter "bar" is deprecated.');
138138

139139
$builder->compile();
140140
}
@@ -1918,7 +1918,7 @@ public function testAutoAliasing()
19181918
*/
19191919
public function testDirectlyAccessingDeprecatedPublicService()
19201920
{
1921-
$this->expectDeprecation('Since foo/bar 3.8: Accessing the "Symfony\Component\DependencyInjection\Tests\A" service directly from the container is deprecated, use dependency injection instead.');
1921+
$this->expectUserDeprecationMessage('Since foo/bar 3.8: Accessing the "Symfony\Component\DependencyInjection\Tests\A" service directly from the container is deprecated, use dependency injection instead.');
19221922

19231923
$container = new ContainerBuilder();
19241924
$container

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

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

1414
use PHPUnit\Framework\TestCase;
1515
use Psr\Container\ContainerInterface;
16-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
16+
use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait;
1717
use Symfony\Component\Config\FileLocator;
1818
use Symfony\Component\DependencyInjection\Argument\AbstractArgument;
1919
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
@@ -73,7 +73,7 @@
7373

7474
class PhpDumperTest extends TestCase
7575
{
76-
use ExpectDeprecationTrait;
76+
use ExpectUserDeprecationMessageTrait;
7777

7878
protected static string $fixturesPath;
7979

@@ -482,7 +482,7 @@ public function testDeprecatedParameters()
482482
{
483483
$container = include self::$fixturesPath.'/containers/container_deprecated_parameters.php';
484484

485-
$this->expectDeprecation('Since symfony/test 6.3: The parameter "foo_class" is deprecated.');
485+
$this->expectUserDeprecationMessage('Since symfony/test 6.3: The parameter "foo_class" is deprecated.');
486486
$container->compile();
487487

488488
$dumper = new PhpDumper($container);
@@ -499,7 +499,7 @@ public function testDeprecatedParametersAsFiles()
499499
{
500500
$container = include self::$fixturesPath.'/containers/container_deprecated_parameters.php';
501501

502-
$this->expectDeprecation('Since symfony/test 6.3: The parameter "foo_class" is deprecated.');
502+
$this->expectUserDeprecationMessage('Since symfony/test 6.3: The parameter "foo_class" is deprecated.');
503503
$container->compile();
504504

505505
$dumper = new PhpDumper($container);
@@ -1699,7 +1699,7 @@ public function testDumpServiceWithAbstractArgument()
16991699
*/
17001700
public function testDirectlyAccessingDeprecatedPublicService()
17011701
{
1702-
$this->expectDeprecation('Since foo/bar 3.8: Accessing the "bar" service directly from the container is deprecated, use dependency injection instead.');
1702+
$this->expectUserDeprecationMessage('Since foo/bar 3.8: Accessing the "bar" service directly from the container is deprecated, use dependency injection instead.');
17031703

17041704
$container = new ContainerBuilder();
17051705
$container

src/Symfony/Component/DependencyInjection/Tests/ParameterBag/FrozenParameterBagTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
namespace Symfony\Component\DependencyInjection\Tests\ParameterBag;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
15+
use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait;
1616
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
1717

1818
class FrozenParameterBagTest extends TestCase
1919
{
20-
use ExpectDeprecationTrait;
20+
use ExpectUserDeprecationMessageTrait;
2121

2222
public function testConstructor()
2323
{
@@ -76,7 +76,7 @@ public function testGetDeprecated()
7676
['foo' => ['symfony/test', '6.3', 'The parameter "%s" is deprecated.', 'foo']]
7777
);
7878

79-
$this->expectDeprecation('Since symfony/test 6.3: The parameter "foo" is deprecated.');
79+
$this->expectUserDeprecationMessage('Since symfony/test 6.3: The parameter "foo" is deprecated.');
8080

8181
$bag->get('foo');
8282
}

src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php

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

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
15+
use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait;
1616
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1717
use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException;
1818
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
@@ -21,7 +21,7 @@
2121

2222
class ParameterBagTest 10000 extends TestCase
2323
{
24-
use ExpectDeprecationTrait;
24+
use ExpectUserDeprecationMessageTrait;
2525

2626
public function testConstructor()
2727
{
@@ -149,7 +149,7 @@ public function testDeprecate()
149149

150150
$bag->deprecate('foo', 'symfony/test', '6.3');
151151

152-
$this->expectDeprecation('Since symfony/test 6.3: The parameter "foo" is deprecated.');
152+
$this->expectUserDeprecationMessage('Since symfony/test 6.3: The parameter "foo" is deprecated.');
153153

154154
$bag->get('foo');
155155
}
@@ -165,7 +165,7 @@ public function testDeprecateWithMessage()
165165

166166
$bag->deprecate('foo', 'symfony/test', '6.3', 'The parameter "%s" is deprecated, use "new_foo" instead.');
167167

168-
$this->expectDeprecation('Since symfony/test 6.3: The parameter "foo" is deprecated, use "new_foo" instead.');
168+
$this->expectUserDeprecationMessage('Since symfony/test 6.3: The parameter "foo" is deprecated, use "new_foo" instead.');
169169

170170
$bag->get('foo');
171171
}
@@ -181,7 +181,7 @@ public function testDeprecationIsTriggeredWhenResolved()
181181

182182
$bag->deprecate('bar', 'symfony/test', '6.3');
183183

184-
$this->expectDeprecation('Since symfony/test 6.3: The parameter "bar" is deprecated.');
184+
$this->expectUserDeprecationMessage('Since symfony/test 6.3: The parameter "bar" is deprecated.');
185185

186186
$bag->resolve();
187187
}

src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

14-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
14+
use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait;
1515
use < D7AE span class=pl-v>Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
1616

1717
class UrlTypeTest extends TextTypeTest
1818
{
19-
use ExpectDeprecationTrait;
19+
use ExpectUserDeprecationMessageTrait;
2020

2121
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\UrlType';
2222

@@ -25,7 +25,7 @@ class UrlTypeTest extends TextTypeTest
2525
*/
2626
public function testSubmitAddsDefaultProtocolIfNoneIsIncluded()
2727
{
28-
$this->expectDeprecation('Since symfony/form 7.1: Not configuring the "default_protocol" option when using the UrlType is deprecated. It will default to "null" in 8.0.');
28+
$this->expectUserDeprecationMessage('Since symfony/form 7.1: Not configuring the "default_protocol" option when using the UrlType is deprecated. It will default to "null" in 8.0.');
2929
$form = $this->factory->create(static::TESTED_TYPE, 'name');
3030

3131
$form->submit('www.domain.com');

src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\Routing\Tests\Generator\Dumper;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
15+
use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait;
1616
use Symfony\Component\Routing\Exception\RouteCircularReferenceException;
1717
use Symfony\Component\Routing\Exception\RouteNotFoundException;
1818
use Symfony\Component\Routing\Generator\CompiledUrlGenerator;
@@ -24,7 +24,7 @@
2424

2525
class CompiledUrlGeneratorDumperTest extends TestCase
2626
{
27-
use ExpectDeprecationTrait;
27+
use ExpectUserDeprecationMessageTrait;
2828

2929
private RouteCollection $routeCollection;
3030
private CompiledUrlGeneratorDumper $generatorDumper;
@@ -346,7 +346,7 @@ public function testIndirectCircularReferenceShouldThrowAnException()
346346
*/
347347
public function testDeprecatedAlias()
348348
{
349-
$this->expectDeprecation('Since foo/bar 1.0.0: The "b" route alias is deprecated. You should stop using it, as it will be removed in the future.');
349+
$this->expectUserDeprecationMessage('Since foo/bar 1.0.0: The "b" route alias is deprecated. You should stop using it, as it will be removed in the future.');
350350

351351
$this->routeCollection->add('a', new Route('/foo'));
352352
$this->routeCollection->addAlias('b', 'a')
@@ -364,7 +364,7 @@ public function testDeprecatedAlias()
364364
*/
365365
public function testDeprecatedAliasWithCustomMessage()
366366
{
367-
$this->expectDeprecation('Since foo/bar 1.0.0: foo b.');
367+
$this->expectUserDeprecationMessage('Since foo/bar 1.0.0: foo b.');
368368

369369
$this->routeCollection->add('a', new Route('/foo'));
370370
$this->routeCollection->addAlias('b', 'a')
@@ -382,7 +382,7 @@ public function testDeprecatedAliasWithCustomMessage()
382382
*/
383383
public function testTargettingADeprecatedAliasShouldTriggerDeprecation()
384384
{
385-
$this->expectDeprecation('Since foo/bar 1.0.0: foo b.');
385+
$this->expectUserDeprecationMessage('Since foo/bar 1.0.0: foo b.');
386386

387387
$this->routeCollection->add('a', new Route('/foo'));
388388
$this->routeCollection->addAlias('b', 'a')

0 commit comments

Comments
 (0)
0