Skip to content

Commit 5c24da0

Browse files
committed
replace PHPUnit annotations with attributes
1 parent f41a52e commit 5c24da0

File tree

6 files changed

+16
-29
lines changed

6 files changed

+16
-29
lines changed

Tests/JsonStreamWriterTest.php

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

1212
namespace Symfony\Component\JsonStreamer\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\JsonStreamer\Exception\NotEncodableValueException;
1617
use Symfony\Component\JsonStreamer\JsonStreamWriter;
@@ -272,9 +273,7 @@ public function testWriteObjectWithDollarNamedProperties()
272273
$this->assertWritten('{"$foo":true,"{$foo->bar}":true}', new DummyWithDollarNamedProperties(), Type::object(DummyWithDollarNamedProperties::class));
273274
}
274275

275-
/**
276-
* @dataProvider throwWhenMaxDepthIsReachedDataProvider
277-
*/
276+
#[DataProvider('throwWhenMaxDepthIsReachedDataProvider')]
278277
public function testThrowWhenMaxDepthIsReached(Type $type, mixed $data)
279278
{
280279
$writer = JsonStreamWriter::create(streamWritersDir: $this->streamWritersDir);

Tests/Read/LazyInstantiatorTest.php

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

1212
namespace Symfony\Component\JsonStreamer\Tests\Read;
1313

14+
use PHPUnit\Framework\Attributes\RequiresPhp;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\JsonStreamer\Exception\InvalidArgumentException;
1617
use Symfony\Component\JsonStreamer\Read\LazyInstantiator;
@@ -32,9 +33,7 @@ protected function setUp(): void
3233
}
3334
}
3435

35-
/**
36-
* @requires PHP < 8.4
37-
*/
36+
#[RequiresPhp('<8.4')]
3837
public function testCreateLazyGhostUsingVarExporter()
3938
{
4039
$ghost = (new LazyInstantiator($this->lazyGhostsDir))->instantiate(ClassicDummy::class, function (ClassicDummy $object): void {
@@ -44,9 +43,7 @@ public function testCreateLazyGhostUsingVarExporter()
4443
$this->assertSame(123, $ghost->id);
4544
}
4645

47-
/**
48-
* @requires PHP < 8.4
49-
*/
46+
#[RequiresPhp('<8.4')]
5047
public function testCreateCacheFile()
5148
{
5249
// use DummyForLazyInstantiation class to be sure that the instantiated object is not already in cache.
@@ -55,18 +52,14 @@ public function testCreateCacheFile()
5552
$this->assertCount(1, glob($this->lazyGhostsDir.'/*'));
5653
}
5754

58-
/**
59-
* @requires PHP < 8.4
60-
*/
55+
#[RequiresPhp('<8.4')]
6156
public function testThrowIfLazyGhostDirNotDefined()
6257
{
6358
$this->expectException(InvalidArgumentException::class);
6459
new LazyInstantiator();
6560
}
6661

67-
/**
68-
* @requires PHP 8.4
69-
*/
62+
#[RequiresPhp('8.4')]
7063
public function testCreateLazyGhostUsingPhp()
7164
{
7265
$ghost = (new LazyInstantiator())->instantiate(ClassicDummy::class, function (ClassicDummy $object): void {

Tests/Read/LexerTest.php

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

1212
namespace Symfony\Component\JsonStreamer\Tests\Read;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\JsonStreamer\Exception\InvalidStreamException;
1617
use Symfony\Component\JsonStreamer\Read\Lexer;
@@ -44,9 +45,8 @@ public function testTokenizeOverflowingBuffer()
4445

4546
/**
4647
* Ensures that the lexer is compliant with RFC 8259.
47-
*
48-
* @dataProvider jsonDataProvider
4948
*/
49+
#[DataProvider('jsonDataProvider')]
5050
public function testValidJson(string $name, string $json, bool $valid)
5151
{
5252
$resource = fopen('php://temp', 'w');

Tests/Read/SplitterTest.php

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

1212
namespace Symfony\Component\JsonStreamer\Tests\Read;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\JsonStreamer\Exception\InvalidStreamException;
1617
use Symfony\Component\JsonStreamer\Read\Splitter;
@@ -39,9 +40,7 @@ public function testSplitDict()
3940
$this->assertDictBoundaries(['k' => [5, 4]], '{"k":[10]}');
4041
}
4142

42-
/**
43-
* @dataProvider splitDictInvalidDataProvider
44-
*/
43+
#[DataProvider('splitDictInvalidDataProvider')]
4544
public function testSplitDictInvalidThrowException(string $expectedMessage, string $content)
4645
{
4746
$this->expectException(InvalidStreamException::class);
@@ -74,9 +73,7 @@ public static function splitDictInvalidDataProvider(): iterable
7473
yield ['Expected end, but got ""x"".', '{"a": true} "x"'];
7574
}
7675

77-
/**
78-
* @dataProvider splitListInvalidDataProvider
79-
*/
76+
#[DataProvider('splitListInvalidDataProvider')]
8077
public function testSplitListInvalidThrowException(string $expectedMessage, string $content)
8178
{
8279
$this->expectException(InvalidStreamException::class);

Tests/Read/StreamReaderGeneratorTest.php

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

1212
namespace Symfony\Component\JsonStreamer\Tests\Read;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\JsonStreamer\Exception\UnsupportedException;
1617
use Symfony\Component\JsonStreamer\Mapping\GenericTypePropertyMetadataLoader;
@@ -51,9 +52,7 @@ protected function setUp(): void
5152
}
5253
}
5354

54-
/**
55-
* @dataProvider generatedStreamReaderDataProvider
56-
*/
55+
#[DataProvider('generatedStreamReaderDataProvider')]
5756
public function testGeneratedStreamReader(string $fixture, Type $type)
5857
{
5958
$propertyMetadataLoader = new GenericTypePropertyMetadataLoader(

Tests/Write/StreamWriterGeneratorTest.php

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

1212
namespace Symfony\Component\JsonStreamer\Tests\Write;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\JsonStreamer\Exception\UnsupportedException;
1617
use Symfony\Component\JsonStreamer\Mapping\GenericTypePropertyMetadataLoader;
@@ -54,9 +55,7 @@ protected function setUp(): void
5455
}
5556
}
5657

57-
/**
58-
* @dataProvider generatedStreamWriterDataProvider
59-
*/
58+
#[DataProvider('generatedStreamWriterDataProvider')]
6059
public function testGeneratedStreamWriter(string $fixture, Type $type)
6160
{
6261
$propertyMetadataLoader = new GenericTypePropertyMetadataLoader(

0 commit comments

Comments
 (0)