Skip to content

Commit 391f51b

Browse files
Merge branch '7.4' into 8.0
* 7.4: replace PHPUnit annotations with attributes
2 parents 417a1ff + 1bd1a50 commit 391f51b

13 files changed

+46
-37
lines changed

Tests/ClockMockTest.php

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

1212
namespace Symfony\Bridge\PhpUnit\Tests;
1313

14+
use PHPUnit\Framework\Attributes\CoversClass;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bridge\PhpUnit\ClockMock;
1617

@@ -19,6 +20,7 @@
1920
*
2021
* @covers \Symfony\Bridge\PhpUnit\ClockMock
2122
*/
23+
#[CoversClass(ClockMock::class)]
2224
class ClockMockTest extends TestCase
2325
{
2426
public static function setUpBeforeClass(): void

Tests/DeprecationErrorHandler/ConfigurationTest.php

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

1212
namespace Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\Attributes\RequiresPhpunit;
1516
use PHPUnit\Framework\TestCase;
1617
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Configuration;
@@ -194,6 +195,7 @@ public static function provideItCanBeDisabled(): array
194195
/**
195196
* @dataProvider provideItCanBeDisabled
196197
*/
198+
#[DataProvider('provideItCanBeDisabled')]
197199
public function testItCanBeDisabled(string $encodedString, bool $expectedEnabled)
198200
{
199201
$configuration = Configuration::fromUrlEncodedString($encodedString);
@@ -240,6 +242,7 @@ public function testOutputIsNotVerboseInWeakMode()
240242
/**
241243
* @dataProvider provideDataForToleratesForGroup
242244
*/
245+
#[DataProvider('provideDataForToleratesForGroup')]
243246
public function testToleratesForIndividualGroups(string $deprecationsHelper, array $deprecationsPerType, array $expected)
244247
{
245248
$configuration = Configuration::fromUrlEncodedString($deprecationsHelper);

Tests/DeprecationErrorHandler/DeprecationTest.php

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

1212
namespace Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
1617
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
@@ -88,6 +89,7 @@ public function testItRulesOutFilesOutsideVendorsAsIndirect()
8889
/**
8990
* @dataProvider mutedProvider
9091
*/
92+
#[DataProvider('mutedProvider')]
9193
public function testItMutesOnlySpecificErrorMessagesWhenTheCallingCodeIsInPhpunit($muted, $callingClass, $message)
9294
{
9395
$trace = $this->debugBacktrace();
@@ -170,6 +172,7 @@ public static function providerGetTypeDetectsSelf(): array
170172
/**
171173
* @dataProvider providerGetTypeDetectsSelf
172174
*/
175+
#[DataProvider('providerGetTypeDetectsSelf')]
173176
public function testGetTypeDetectsSelf(string $expectedType, string $message, string $traceClass, string $file)
174177
{
175178
$trace = [
@@ -233,6 +236,7 @@ public static function providerGetTypeUsesRightTrace(): array
233236
/**
234237
* @dataProvider providerGetTypeUsesRightTrace
235238
*/
239+
#[DataProvider('providerGetTypeUsesRightTrace')]
236240
public function testGetTypeUsesRightTrace(string $expectedType, string $message, array $trace)
237241
{
238242
$deprecation = new Deprecation(

Tests/ExpectDeprecationTraitTest.php

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

1212
namespace Symfony\Bridge\PhpUnit\Tests;
1313

14+
use PHPUnit\Framework\Attributes\Group;
1415
use PHPUnit\Framework\Attributes\RequiresPhpunit;
16+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
1517
use PHPUnit\Framework\TestCase;
1618
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1719

@@ -22,9 +24,8 @@ final class ExpectDeprecationTraitTest extends TestCase
2224

2325
/**
2426
* Do not remove this test in the next major version.
25-
*
26-
* @group legacy
2727
*/
28+
#[Group('legacy')]
2829
public function testOne()
2930
{
3031
$this->expectDeprecation('foo');
@@ -33,11 +34,9 @@ public function testOne()
3334

3435
/**
3536
* Do not remove this test in the next major version.
36-
*
37-
* @group legacy
38-
*
39-
* @runInSeparateProcess
4037
*/
38+
#[Group('legacy')]
39+
#[RunInSeparateProcess]
4140
public function testOneInIsolation()
4241
{
4342
$this->expectDeprecation('foo');
@@ -46,9 +45,8 @@ public function testOneInIsolation()
4645

4746
/**
4847
* Do not remove this test in the next major version.
49-
*
50-
* @group legacy
5148
*/
49+
#[Group('legacy')]
5250
public function testMany()
5351
{
5452
$this->expectDeprecation('foo');
@@ -60,10 +58,9 @@ public function testMany()
6058
/**
6159
* Do not remove this test in the next major version.
6260
*
63-
* @group legacy
64-
*
6561
* @expectedDeprecation foo
6662
*/
63+
#[Group('legacy')]
6764
public function testOneWithAnnotation()
6865
{
6966
$this->expectDeprecation('bar');
@@ -74,11 +71,10 @@ public function testOneWithAnnotation()
7471
/**
7572
* Do not remove this test in the next major version.
7673
*
77-
* @group legacy
78-
*
7974
* @expectedDeprecation foo
8075
* @expectedDeprecation bar
8176
*/
77+
#[Group('legacy')]
8278
public function testManyWithAnnotation()
8379
{
8480
$this->expectDeprecation('ccc');

Tests/ExpectedDeprecationAnnotationTest.php

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

1212
namespace Symfony\Bridge\PhpUnit\Tests;
1313

14+
use PHPUnit\Framework\Attributes\Group;
1415
use PHPUnit\Framework\Attributes\RequiresPhpunit;
1516
use PHPUnit\Framework\TestCase;
1617

@@ -20,10 +21,9 @@ final class ExpectedDeprecationAnnotationTest extends TestCase
2021
/**
2122
* Do not remove this test in the next major versions.
2223
*
23-
* @group legacy
24-
*
2524
* @expectedDeprecation foo
2625
*/
26+
#[Group('legacy')]
2727
public function testOne()
2828
{
2929
@trigger_error('foo', \E_USER_DEPRECATED);
@@ -32,11 +32,10 @@ public function testOne()
3232
/**
3333
* Do not remove this test in the next major versions.
3434
*
35-
* @group legacy
36-
*
3735
* @expectedDeprecation foo
3836
* @expectedDeprecation bar
3937
*/
38+
#[Group('legacy')]
4039
public function testMany()
4140
{
4241
@trigger_error('foo', \E_USER_DEPRECATED);

Tests/FailTests/ExpectDeprecationTraitTestFail.php

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

1212
namespace Symfony\Bridge\PhpUnit\Tests\FailTests;
1313

14+
use PHPUnit\Framework\Attributes\Group;
1415
use PHPUnit\Framework\Attributes\RequiresPhpunit;
16+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
1517
use PHPUnit\Framework\TestCase;
1618
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1719

@@ -28,9 +30,8 @@ final class ExpectDeprecationTraitTestFail extends TestCase
2830

2931
/**
3032
* Do not remove this test in the next major version.
31-
*
32-
* @group legacy
3333
*/
34+
#[Group('legacy')]
3435
public function testOne()
3536
{
3637
$this->expectDeprecation('foo');
@@ -39,11 +40,9 @@ public function testOne()
3940

4041
/**
4142
* Do not remove this test in the next major version.
42-
*
43-
* @group legacy
44-
*
45-
* @runInSeparateProcess
4643
*/
44+
#[Group('legacy')]
45+
#[RunInSeparateProcess]
4746
public function testOneInIsolation()
4847
{
4948
$this->expectDeprecation('foo');

Tests/FailTests/NoAssertionsTestRisky.php

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

1212
namespace Symfony\Bridge\PhpUnit\Tests\FailTests;
1313

14+
use PHPUnit\Framework\Attributes\Group;
1415
use PHPUnit\Framework\Attributes\RequiresPhpunit;
1516
use PHPUnit\Framework\TestCase;
1617
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
@@ -26,9 +27,8 @@ final class NoAssertionsTestRisky extends TestCase
2627

2728
/**
2829
* Do not remove this test in the next major version.
29-
*
30-
* @group legacy
3130
*/
31+
#[Group('legacy')]
3232
public function testOne()
3333
{
3434
$this->expectNotToPerformAssertions();

Tests/Fixtures/coverage/tests/CoversDefaultClassTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
use PHPUnit\Framework\Attributes\CoversClass;
1213
use PHPUnit\Framework\TestCase;
1314

1415
/**
1516
* @coversDefaultClass \DateTime
1617
*/
18+
#[CoversClass(DateTime::class)]
1719
class CoversDefaultClassTest extends TestCase
1820
{
1921
public function test()

Tests/Fixtures/coverage/tests/CoversNothingTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
use PHPUnit\Framework\Attributes\CoversNothing;
1213
use PHPUnit\Framework\TestCase;
1314

1415
/**
1516
* @coversNothing
1617
*/
18+
#[CoversNothing]
1719
class CoversNothingTest extends TestCase
1820
{
1921
public function test()

Tests/Fixtures/coverage/tests/CoversTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
use PHPUnit\Framework\Attributes\CoversClass;
1213
use PHPUnit\Framework\TestCase;
1314

15+
/**
16+
* @covers \DateTime
17+
*/
18+
#[CoversClass(DateTime::class)]
1419
class CoversTest extends TestCase
1520
{
16-
/**
17-
* @covers \DateTime
18-
*/
1921
public function test()
2022
{
2123
$this->assertTrue(true);

0 commit comments

Comments
 (0)