Skip to content

Commit 138d411

Browse files
committed
replace PHPUnit annotations with attributes
1 parent ef95056 commit 138d411

File tree

4 files changed

+16
-36
lines changed

4 files changed

+16
-36
lines changed

Tests/JsonCrawlerTest.php

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

1212
namespace Symfony\Component\JsonPath\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\JsonPath\Exception\InvalidArgumentException;
1617
use Symfony\Component\JsonPath\Exception\InvalidJsonStringInputException;
@@ -568,9 +569,7 @@ public function testStarAsKey()
568569
$this->assertSame(['a' => 1, 'b' => 2], $result[0]);
569570
}
570571

571-
/**
572-
* @dataProvider provideUnicodeEscapeSequencesProvider
573-
*/
572+
#[DataProvider('provideUnicodeEscapeSequencesProvider')]
574573
public function testUnicodeEscapeSequences(string $jsonPath, array $expected)
575574
{
576575
$this->assertSame($expected, self::getUnicodeDocumentCrawler()->find($jsonPath));
@@ -622,9 +621,7 @@ public static function provideUnicodeEscapeSequencesProvider(): array
622621
];
623622
}
624623

625-
/**
626-
* @dataProvider provideSingleQuotedStringProvider
627-
*/
624+
#[DataProvider('provideSingleQuotedStringProvider')]
628625
public function testSingleQuotedStrings(string $jsonPath, array $expected)
629626
{
630627
$this->assertSame($expected, self::getUnicodeDocumentCrawler()->find($jsonPath));
@@ -676,9 +673,7 @@ public static function provideSingleQuotedStringProvider(): array
676673
];
677674
}
678675

679-
/**
680-
* @dataProvider provideFilterWithUnicodeProvider
681-
*/
676+
#[DataProvider('provideFilterWithUnicodeProvider')]
682677
public function testFilterWithUnicodeStrings(string $jsonPath, int $expectedCount, string $expectedCountry)
683678
{
684679
$result = self::getUnicodeDocumentCrawler()->find($jsonPath);
@@ -721,9 +716,7 @@ public static function provideFilterWithUnicodeProvider(): array
721716
];
722717
}
723718

724-
/**
725-
* @dataProvider provideComplexUnicodePath
726-
*/
719+
#[DataProvider('provideComplexUnicodePath')]
727720
public function testComplexUnicodePaths(string $jsonPath, array $expected)
728721
{
729722
$complexJson = [

Tests/JsonPathComplianceTestSuiteTest.php

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

1212
namespace Symfony\Component\JsonPath\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\JsonPath\Exception\JsonCrawlerException;
1617
use Symfony\Component\JsonPath\JsonCrawler;
@@ -139,9 +140,7 @@ final class JsonPathComplianceTestSuiteTest extends TestCase
139140
'filter, group terms, left',
140141
];
141142

142-
/**
143-
* @dataProvider complianceCaseProvider
144-
*/
143+
#[DataProvider('complianceCaseProvider')]
145144
public function testComplianceTestCase(string $selector, array $document, array $expectedResults, bool $invalidSelector)
146145
{
147146
$jsonCrawler = new JsonCrawler(json_encode($document));

Tests/JsonPathTest.php

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

1212
namespace Symfony\Component\JsonPath\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\JsonPath\JsonPath;
1617

@@ -63,9 +64,7 @@ public function testLast()
6364
$this->assertSame('$["users"][-1]', (string) $path);
6465
}
6566

66-
/**
67-
* @dataProvider provideKeysToEscape
68-
*/
67+
#[DataProvider('provideKeysToEscape')]
6968
public function testEscapedKey(string $key, string $expectedPath)
7069
{
7170
$path = new JsonPath();

Tests/Tokenizer/JsonPathTokenizerTest.php

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

1212
namespace Symfony\Component\JsonPath\Tests\Tokenizer;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\JsonPath\Exception\InvalidJsonPathException;
1617
use Symfony\Component\JsonPath\JsonPath;
@@ -19,9 +20,7 @@
1920

2021
class JsonPathTokenizerTest extends TestCase
2122
{
22-
/**
23-
* @dataProvider simplePathProvider
24-
*/
23+
#[DataProvider('simplePathProvider')]
2524
public function testSimplePath(string $path, array $expectedTokens)
2625
{
2726
$jsonPath = new JsonPath($path);
@@ -62,9 +61,7 @@ public static function simplePathProvider(): array
6261
];
6362
}
6463

65-
/**
66-
* @dataProvider bracketNotationProvider
67-
*/
64+
#[DataProvider('bracketNotationProvider')]
6865
public function testBracketNotation(string $path, array $expectedTokens)
6966
{
7067
$jsonPath = new JsonPath($path);
@@ -102,9 +99,7 @@ public static function bracketNotationProvider(): array
10299
];
103100
}
104101

105-
/**
106-
* @dataProvider filterExpressionProvider
107-
*/
102+
#[DataProvider('filterExpressionProvider')]
108103
public function testFilterExpressions(string $path, array $expectedTokens)
109104
{
110105
$jsonPath = new JsonPath($path);
@@ -147,9 +142,7 @@ public static function filterExpressionProvider(): array
147142
];
148143
}
149144

150-
/**
151-
* @dataProvider complexPathProvider
152-
*/
145+
#[DataProvider('complexPathProvider')]
153146
public function testComplexPaths(string $path, array $expectedTokens)
154147
{
155148
$jsonPath = new JsonPath($path);
@@ -310,9 +303,7 @@ public function testTokenizeThrowsExceptionForConsecutiveDotsWithoutRecursive()
310303
JsonPathTokenizer::tokenize(new JsonPath('$.store...name'));
311304
}
312305

313-
/**
314-
* @dataProvider provideValidUtf8Chars
315-
*/
306+
#[DataProvider('provideValidUtf8Chars')]
316307
public function testUtf8ValidChars(string $propertyName)
317308
{
318309
$jsonPath = new JsonPath(\sprintf('$.%s', $propertyName));
@@ -337,9 +328,7 @@ public static function provideValidUtf8Chars(): array
337328
];
338329
}
339330

340-
/**
341-
* @dataProvider provideInvalidUtf8PropertyName
342-
*/
331+
#[DataProvider('provideInvalidUtf8PropertyName')]
343332
public function testUtf8InvalidPropertyName(string $propertyName)
344333
{
345334
$this->expectException(InvalidJsonPathException::class);

0 commit comments

Comments
 (0)