Skip to content

Commit d53229b

Browse files
Merge branch '7.4' into 8.0
* 7.4: replace PHPUnit annotations with attributes
2 parents 2e3d202 + 8a6d940 commit d53229b

25 files changed

+76
-127
lines changed

Test/VarDumperTestTrait.php

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

1212
namespace Symfony\Component\VarDumper\Test;
1313

14+
use PHPUnit\Framework\Attributes\After;
1415
use Symfony\Component\VarDumper\Cloner\VarCloner;
1516
use Symfony\Component\VarDumper\Dumper\CliDumper;
1617

@@ -36,9 +37,7 @@ protected function setUpVarDumper(array $casters, ?int $flags = null): void
3637
$this->varDumperConfig['flags'] = $flags;
3738
}
3839

39-
/**
40-
* @after
41-
*/
40+
#[After]
4241
protected function tearDownVarDumper(): void
4342
{
4443
$this->varDumperConfig['casters'] = [];

Tests/Caster/AddressInfoCasterTest.php

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

1212
namespace Symfony\Component\VarDumper\Tests\Caster;
1313

14+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
1617

17-
/**
18-
* @requires extension sockets
19-
*/
18+
#[RequiresPhpExtension('sockets')]
2019
class AddressInfoCasterTest extends TestCase
2120
{
2221
use VarDumperTestTrait;

Tests/Caster/CasterTest.php

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

1212
namespace Symfony\Component\VarDumper\Tests\Caster;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\VarDumper\Caster\Caster;
1617
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
@@ -32,9 +33,7 @@ class CasterTest extends TestCase
3233
"\0Foo\0private" => 'priv',
3334
];
3435

35-
/**
36-
* @dataProvider provideFilter
37-
*/
36+
#[DataProvider('provideFilter')]
3837
public function testFilter($filter, $expectedDiff, $listedProperties = null)
3938
{
4039
if (null === $listedProperties) {

Tests/Caster/CurlCasterTest.php

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

1212
namespace Symfony\Component\VarDumper\Tests\Caster;
1313

14+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
1617

17-
/**
18-
* @requires extension curl
19-
*/
18+
#[RequiresPhpExtension('curl')]
2019
class CurlCasterTest extends TestCase
2120
{
2221
use VarDumperTestTrait;

Tests/Caster/DateCasterTest.php

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

1212
namespace Symfony\Component\VarDumper\Tests\Caster;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\VarDumper\Caster\Caster;
1617
use Symfony\Component\VarDumper\Caster\DateCaster;
@@ -37,9 +38,7 @@ protected function tearDown(): void
3738
date_default_timezone_set($this->previousTimezone);
3839
}
3940

40-
/**
41-
* @dataProvider provideDateTimes
42-
*/
41+
#[DataProvider('provideDateTimes')]
4342
public function testDumpDateTime($time, $timezone, $xDate, $xTimestamp)
4443
{
4544
$date = new \DateTime($time, new \DateTimeZone($timezone));
@@ -53,9 +52,7 @@ public function testDumpDateTime($time, $timezone, $xDate, $xTimestamp)
5352
$this->assertDumpEquals($xDump, $date);
5453
}
5554

56-
/**
57-
* @dataProvider provideDateTimes
58-
*/
55+
#[DataProvider('provideDateTimes')]
5956
public function testDumpDateTimeImmutable($time, $timezone, $xDate, $xTimestamp)
6057
{
6158
$date = new \DateTimeImmutable($time, new \DateTimeZone($timezone));
@@ -69,9 +66,7 @@ public function testDumpDateTimeImmutable($time, $timezone, $xDate, $xTimestamp)
6966
$this->assertDumpEquals($xDump, $date);
7067
}
7168

72-
/**
73-
* @dataProvider provideDateTimes
74-
*/
69+
#[DataProvider('provideDateTimes')]
7570
public function testCastDateTime($time, $timezone, $xDate, $xTimestamp, $xInfos)
7671
{
7772
$stub = new Stub();
@@ -118,9 +113,7 @@ public static function provideDateTimes()
118113
];
119114
}
120115

121-
/**
122-
* @dataProvider provideNoTimezoneDateTimes
123-
*/
116+
#[DataProvider('provideNoTimezoneDateTimes')]
124117
public function testCastDateTimeNoTimezone($time, $xDate, $xInfos)
125118
{
126119
date_default_timezone_set('UTC');
@@ -200,9 +193,7 @@ public function testCastDateTimeWithAdditionalChildProperty()
200193
$this->assertDumpMatchesFormat($xDump, $dateCast["\0~\0date"]);
201194
}
202195

203-
/**
204-
* @dataProvider provideIntervals
205-
*/
196+
#[DataProvider('provideIntervals')]
206197
public function testDumpInterval($intervalSpec, $ms, $invert, $expected)
207198
{
208199
$interval = $this->createInterval($intervalSpec, $ms, $invert);
@@ -216,9 +207,7 @@ public function testDumpInterval($intervalSpec, $ms, $invert, $expected)
216207
$this->assertDumpMatchesFormat($xDump, $interval);
217208
}
218209

219-
/**
220-
* @dataProvider provideIntervals
221-
*/
210+
#[DataProvider('provideIntervals')]
222211
public function testDumpIntervalExcludingVerbosity($intervalSpec, $ms, $invert, $expected)
223212
{
224213
$interval = $this->createInterval($intervalSpec, $ms, $invert);
@@ -232,9 +221,7 @@ public function testDumpIntervalExcludingVerbosity($intervalSpec, $ms, $invert,
232221
$this->assertDumpEquals($xDump, $interval, Caster::EXCLUDE_VERBOSE);
233222
}
234223

235-
/**
236-
* @dataProvider provideIntervals
237-
*/
224+
#[DataProvider('provideIntervals')]
238225
public function testCastInterval($intervalSpec, $ms, $invert, $xInterval, $xSeconds)
239226
{
240227
$interval = $this->createInterval($intervalSpec, $ms, $invert);
@@ -303,9 +290,7 @@ public static function provideIntervals()
303290
];
304291
}
305292

306-
/**
307-
* @dataProvider provideTimeZones
308-
*/
293+
#[DataProvider('provideTimeZones')]
309294
public function testDumpTimeZone($timezone, $expected)
310295
{
311296
$timezone = new \DateTimeZone($timezone);
@@ -319,9 +304,7 @@ public function testDumpTimeZone($timezone, $expected)
319304
$this->assertDumpMatchesFormat($xDump, $timezone);
320305
}
321306

322-
/**
323-
* @dataProvider provideTimeZones
324-
*/
307+
#[DataProvider('provideTimeZones')]
325308
public function testDumpTimeZoneExcludingVerbosity($timezone, $expected)
326309
{
327310
$timezone = new \DateTimeZone($timezone);
@@ -335,9 +318,7 @@ public function testDumpTimeZoneExcludingVerbosity($timezone, $expected)
335318
$this->assertDumpMatchesFormat($xDump, $timezone, Caster::EXCLUDE_VERBOSE);
336319
}
337320

338-
/**
339-
* @dataProvider provideTimeZones
340-
*/
321+
#[DataProvider('provideTimeZones')]
341322
public function testCastTimeZone($timezone, $xTimezone, $xRegion)
342323
{
343324
$timezone = new \DateTimeZone($timezone);
@@ -396,9 +377,7 @@ public static function provideTimeZones()
396377
];
397378
}
398379

399-
/**
400-
* @dataProvider providePeriods
401-
*/
380+
#[DataProvider('providePeriods')]
402381
public function testDumpPeriod($start, $interval, $end, $options, $expected)
403382
{
404383
$p = new \DatePeriod(new \DateTimeImmutable($start), new \DateInterval($interval), \is_int($end) ? $end : new \DateTime($end), $options);
@@ -412,9 +391,7 @@ public function testDumpPeriod($start, $interval, $end, $options, $expected)
412391
$this->assertDumpMatchesFormat($xDump, $p);
413392
}
414393

415-
/**
416-
* @dataProvider providePeriods
417-
*/
394+
#[DataProvider('providePeriods')]
418395
public function testCastPeriod($start, $interval, $end, $options, $xPeriod, $xDates)
419396
{
420397
$p = new \DatePeriod(new \DateTimeImmutable($start, new \DateTimeZone('UTC')), new \DateInterval($interval), \is_int($end) ? $end : new \DateTimeImmutable($end, new \DateTimeZone('UTC')), $options);

Tests/Caster/DoctrineCasterTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
use Doctrine\ORM\EntityManagerInterface;
1616
use Doctrine\ORM\Mapping\ClassMetadata;
1717
use Doctrine\ORM\PersistentCollection;
18+
use PHPUnit\Framework\Attributes\RequiresMethod;
1819
use PHPUnit\Framework\TestCase;
1920
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
2021

21-
/**
22-
* @requires function \Doctrine\Common\Collections\ArrayCollection::__construct
23-
*/
22+
#[RequiresMethod(ArrayCollection::class, '__construct')]
2423
class DoctrineCasterTest extends TestCase
2524
{
2625
use VarDumperTestTrait;

Tests/Caster/ExceptionCasterTest.php

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

1212
namespace Symfony\Component\VarDumper\Tests\Caster;
1313

14+
use PHPUnit\Framework\Attributes\RequiresMethod;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\ErrorHandler\Exception\FlattenException;
1617
use Symfony\Component\ErrorHandler\Exception\SilencedErrorContext;
@@ -127,9 +128,7 @@ public function testDefaultSettingsOnErrorException()
127128
$this->assertDumpMatchesFormat($expectedDump, $e);
128129
}
129130

130-
/**
131-
* @requires function \Symfony\Component\ErrorHandler\Exception\SilencedErrorContext::__construct
132-
*/
131+
#[RequiresMethod(SilencedErrorContext::class, '__construct')]
133132
public function testCastSilencedErrorContext()
134133
{
135134
$e = $this->getTestSilencedErrorContext();
@@ -356,9 +355,7 @@ public function testAnonymous()
356355
$this->assertDumpMatchesFormat($expectedDump, $e, Caster::EXCLUDE_VERBOSE);
357356
}
358357

359-
/**
360-
* @requires function \Symfony\Component\ErrorHandler\Exception\FlattenException::create
361-
*/
358+
#[RequiresMethod(FlattenException::class, 'create')]
362359
public function testFlattenException()
363360
{
364361
$f = FlattenException::createFromThrowable(new \Exception('Hello'));

Tests/Caster/FFICasterTest.php

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

1212
namespace Symfony\Component\VarDumper\Tests\Caster;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
15+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1416
use PHPUnit\Framework\TestCase;
1517
use Symfony\Component\VarDumper\Caster\FFICaster;
1618
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
1719

1820
/**
1921
* @author Kirill Nesmeyanov <[email protected]>
20-
*
21-
* @requires extension ffi
2222
*/
23+
#[RequiresPhpExtension('ffi')]
2324
class FFICasterTest extends TestCase
2425
{
2526
use VarDumperTestTrait;
@@ -114,9 +115,7 @@ public static function scalarsDataProvider(): array
114115
];
115116
}
116117

117-
/**
118-
* @dataProvider scalarsDataProvider
119-
*/
118+
#[DataProvider('scalarsDataProvider')]
120119
public function testCastScalar(string $type, string $value, int $size, int $align)
121120
{
122121
$this->assertDumpEquals(<<<PHP

Tests/Caster/GmpCasterTest.php

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

1212
namespace Symfony\Component\VarDumper\Tests\Caster;
1313

14+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\VarDumper\Caster\GmpCaster;
1617
use Symfony\Component\VarDumper\Cloner\Stub;
@@ -20,9 +21,7 @@ class GmpCasterTest extends TestCase
2021
{
2122
use VarDumperTestTrait;
2223

23-
/**
24-
* @requires extension gmp
25-
*/
24+
#[RequiresPhpExtension('gmp')]
2625
public function testCastGmp()
2726
{
2827
$gmpString = gmp_init('1234');

Tests/Caster/IntlCasterTest.php

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

1212
namespace Symfony\Component\VarDumper\Tests\Caster;
1313

14+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
1617

17-
/**
18-
* @requires extension intl
19-
*/
18+
#[RequiresPhpExtension('intl')]
2019
class IntlCasterTest extends TestCase
2120
{
2221
use VarDumperTestTrait;

0 commit comments

Comments
 (0)