Skip to content

Commit a6e850a

Browse files
committed
replace PHPUnit annotations with attributes
1 parent 067be86 commit a6e850a

File tree

5 files changed

+24
-51
lines changed

5 files changed

+24
-51
lines changed

Tests/InstantiatorTest.php

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

1212
namespace Symfony\Component\VarExporter\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\VarExporter\Exception\ClassNotFoundException;
1617
use Symfony\Component\VarExporter\Exception\NotInstantiableTypeException;
@@ -25,9 +26,7 @@ public function testNotFoundClass()
2526
Instantiator::instantiate('SomeNotExistingClass');
2627
}
2728

28-
/**
29-
* @dataProvider provideFailingInstantiation
30-
*/
29+
#[DataProvider('provideFailingInstantiation')]
3130
public function testFailingInstantiation(string $class)
3231
{
3332
$this->expectException(NotInstantiableTypeException::class);

Tests/LazyProxyTraitTest.php

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

1212
namespace Symfony\Component\VarExporter\Tests;
1313

14+
use PHPUnit\Framework\Attributes\RequiresPhp;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
1617
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
@@ -31,9 +32,7 @@
3132
use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\TestWakeupClass;
3233
use Symfony\Component\VarExporter\Tests\Fixtures\SimpleObject;
3334

34-
/**
35-
* @requires PHP 8.4
36-
*/
35+
#[RequiresPhp('8.4')]
3736
class LazyProxyTraitTest extends TestCase
3837
{
3938
public function testGetter()
@@ -292,9 +291,7 @@ public function testReinitRegularLazyProxy()
292291
$this->assertSame(234, $object->foo);
293292
}
294293

295-
/**
296-
* @requires PHP 8.3
297-
*/
294+
#[RequiresPhp('8.3')]
298295
public function testReinitReadonlyLazyProxy()
299296
{
300297
$object = $this->createLazyProxy(ReadOnlyClass::class, fn () => new ConcreteReadOnlyClass(123));
@@ -306,9 +303,7 @@ public function testReinitReadonlyLazyProxy()
306303
$this->assertSame(234, $object->foo);
307304
}
308305

309-
/**
310-
* @requires PHP 8.4
311-
*/
306+
#[RequiresPhp('8.4')]
312307
public function testConcretePropertyHooks()
313308
{
314309
$initialized = false;
@@ -335,9 +330,7 @@ public function testConcretePropertyHooks()
335330
$this->assertSame(345, $object->backed);
336331
}
337332

338-
/**
339-
* @requires PHP 8.4
340-
*/
333+
#[RequiresPhp('8.4')]
341334
public function testAbstractPropertyHooks()
342335
{
343336
$initialized = false;
@@ -369,9 +362,7 @@ public function testAbstractPropertyHooks()
369362
$this->assertTrue($initialized);
370363
}
371364

372-
/**
373-
* @requires PHP 8.4
374-
*/
365+
#[RequiresPhp('8.4')]
375366
public function testAsymmetricVisibility()
376367
{
377368
$object = $this->createLazyProxy(AsymmetricVisibility::class, function () {

Tests/LegacyLazyGhostTraitTest.php

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

1212
namespace Symfony\Component\VarExporter\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\Attributes\Group;
1516
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
17+
use PHPUnit\Framework\Attributes\RequiresPhp;
1618
use PHPUnit\Framework\TestCase;
1719
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
1820
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
@@ -140,9 +142,7 @@ public function testSerialize()
140142
$this->assertTrue($clone->isLazyObjectInitialized());
141143
}
142144

143-
/**
144-
* @dataProvider provideMagicClass
145-
*/
145+
#[DataProvider('provideMagicClass')]
146146
public function testMagicClass(MagicClass $instance)
147147
{
148148
$this->assertSame('bar', $instance->foo);
@@ -242,9 +242,7 @@ public function testIndirectModification()
242242
$this->assertSame([123], $proxy->foo);
243243
}
244244

245-
/**
246-
* @requires PHP 8.3
247-
*/
245+
#[RequiresPhp('8.3')]
248246
public function testReadOnlyClass()
249247
{
250248
$proxy = $this->createLazyGhost(ReadOnlyClass::class, fn ($proxy) => $proxy->__construct(123));
@@ -298,9 +296,7 @@ public function testReinitLazyGhost()
298296
$this->assertSame(3, $object->public);
299297
}
300298

301-
/**
302-
* @requires PHP 8.4
303-
*/
299+
#[RequiresPhp('8.4')]
304300
public function testPropertyHooks()
305301
{
306302
$initialized = false;
@@ -323,9 +319,7 @@ public function testPropertyHooks()
323319
$this->assertSame(345, $object->backed);
324320
}
325321

326-
/**
327-
* @requires PHP 8.4
328-
*/
322+
#[RequiresPhp('8.4')]
329323
public function testPropertyHooksWithDefaultValue()
330324
{
331325
$initialized = false;
@@ -351,9 +345,7 @@ public function testPropertyHooksWithDefaultValue()
351345
$this->assertTrue($object->backedBoolWithDefault);
352346
}
353347

354-
/**
355-
* @requires PHP 8.4
356-
*/
348+
#[RequiresPhp('8.4')]
357349
public function testAsymmetricVisibility()
358350
{
359351
$object = $this->createLazyGhost(AsymmetricVisibility::class, function ($instance) {

Tests/ProxyHelperTest.php

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

1212
namespace Symfony\Component\VarExporter\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
15+
use PHPUnit\Framework\Attributes\RequiresPhp;
1416
use PHPUnit\Framework\TestCase;
1517
use Symfony\Component\VarExporter\ProxyHelper;
1618
use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\Hooked;
1719
use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\Php82NullStandaloneReturnType;
1820

19-
/**
20-
* @requires PHP 8.4
21-
*/
21+
#[RequiresPhp('8.4')]
2222
class ProxyHelperTest extends TestCase
2323
{
24-
/**
25-
* @dataProvider provideExportSignature
26-
*/
24+
#[DataProvider('provideExportSignature')]
2725
public function testExportSignature(string $expected, \ReflectionMethod $method)
2826
{
2927
$this->assertSame($expected, ProxyHelper::exportSignature($method));
@@ -208,9 +206,7 @@ class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class);
208206
$this->assertSame($expected, ProxyHelper::generateLazyProxy(null, [new \ReflectionClass(TestForProxyHelperInterface1::class), new \ReflectionClass(TestForProxyHelperInterface2::class)]));
209207
}
210208

211-
/**
212-
* @dataProvider classWithUnserializeMagicMethodProvider
213-
*/
209+
#[DataProvider('classWithUnserializeMagicMethodProvider')]
214210
public function testGenerateLazyProxyForClassWithUnserializeMagicMethod(object $obj, string $expected)
215211
{
216212
$this->assertStringContainsString($expected, ProxyHelper::generateLazyProxy(new \ReflectionClass($obj::class)));
@@ -282,9 +278,7 @@ public function testNullStandaloneReturnType()
282278
);
283279
}
284280

285-
/**
286-
* @requires PHP 8.4
287-
*/
281+
#[RequiresPhp('8.4')]
288282
public function testPropertyHooks()
289283
{
290284
$proxyCode = ProxyHelper::generateLazyProxy(new \ReflectionClass(Hooked::class));

Tests/VarExporterTest.php

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

1212
namespace Symfony\Component\VarExporter\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
1617
use Symfony\Component\VarExporter\Exception\ClassNotFoundException;
@@ -39,9 +40,7 @@ public function testPhpIncompleteClassesAreForbidden()
3940
}
4041
}
4142

42-
/**
43-
* @dataProvider provideFailingSerialization
44-
*/
43+
#[DataProvider('provideFailingSerialization')]
4544
public function testFailingSerialization($value)
4645
{
4746
$this->expectException(NotInstantiableTypeException::class);
@@ -77,9 +76,7 @@ public static function provideFailingSerialization()
7776
yield [$a];
7877
}
7978

80-
/**
81-
* @dataProvider provideExport
82-
*/
79+
#[DataProvider('provideExport')]
8380
public function testExport(string $testName, $value, bool $staticValueExpected = false)
8481
{
8582
$dumpedValue = $this->getDump($value);

0 commit comments

Comments
 (0)