Skip to content

Commit 1790e23

Browse files
committed
replace PHPUnit annotations with attributes
1 parent a9f583b commit 1790e23

File tree

9 files changed

+92
-235
lines changed

9 files changed

+92
-235
lines changed

Tests/AbstractAsciiTestCase.php

Lines changed: 57 additions & 168 deletions
Large diffs are not rendered by default.

Tests/AbstractUnicodeTestCase.php

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

1212
namespace Symfony\Component\String\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
15+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1416
use Symfony\Component\String\Exception\InvalidArgumentException;
1517

1618
abstract class AbstractUnicodeTestCase extends AbstractAsciiTestCase
@@ -50,11 +52,8 @@ public function testAsciiClosureRule()
5052
$this->assertSame('Dieser Wert sollte grOEsser oder gleich', (string) $s->ascii([$rule]));
5153
}
5254

53-
/**
54-
* @dataProvider provideLocaleLower
55-
*
56-
* @requires extension intl
57-
*/
55+
#[DataProvider('provideLocaleLower')]
56+
#[RequiresPhpExtension('intl')]
5857
public function testLocaleLower(string $locale, string $expected, string $origin)
5958
{
6059
$instance = static::createFromString($origin)->localeLower($locale);
@@ -64,11 +63,8 @@ public function testLocaleLower(string $locale, string $expected, string $origin
6463
$this->assertSame($expected, (string) $instance);
6564
}
6665

67-
/**
68-
* @dataProvider provideLocaleUpper
69-
*
70-
* @requires extension intl
71-
*/
66+
#[DataProvider('provideLocaleUpper')]
67+
#[RequiresPhpExtension('intl')]
7268
public function testLocaleUpper(string $locale, string $expected, string $origin)
7369
{
7470
$instance = static::createFromString($origin)->localeUpper($locale);
@@ -78,11 +74,8 @@ public function testLocaleUpper(string $locale, string $expected, string $origin
7874
$this->assertSame($expected, (string) $instance);
7975
}
8076

81-
/**
82-
* @dataProvider provideLocaleTitle
83-
*
84-
* @requires extension intl
85-
*/
77+
#[DataProvider('provideLocaleTitle')]
78+
#[RequiresPhpExtension('intl')]
8679
public function testLocaleTitle(string $locale, string $expected, string $origin)
8780
{
8881
$instance = static::createFromString($origin)->localeTitle($locale);
@@ -117,9 +110,7 @@ public static function provideBytesAt(): array
117110
);
118111
}
119112

120-
/**
121-
* @dataProvider provideCodePointsAt
122-
*/
113+
#[DataProvider('provideCodePointsAt')]
123114
public function testCodePointsAt(array $expected, string $string, int $offset, ?int $form = null)
124115
{
125116
if (2 !== grapheme_strlen('च्छे') && 'नमस्ते' === $string) {

Tests/FunctionsTest.php

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

1212
namespace Symfony\Component\String\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\String\AbstractString;
1617
use Symfony\Component\String\ByteString;
@@ -22,9 +23,7 @@
2223

2324
final class FunctionsTest extends TestCase
2425
{
25-
/**
26-
* @dataProvider provideSStrings
27-
*/
26+
#[DataProvider('provideSStrings')]
2827
public function testS(AbstractString $expected, ?string $input)
2928
{
3029
$this->assertEquals($expected, s($input));
@@ -42,9 +41,7 @@ public static function provideSStrings(): array
4241
];
4342
}
4443

45-
/**
46-
* @dataProvider provideUStrings
47-
*/
44+
#[DataProvider('provideUStrings')]
4845
public function testU(UnicodeString $expected, ?string $input)
4946
{
5047
$this->assertEquals($expected, u($input));
@@ -60,9 +57,7 @@ public static function provideUStrings(): array
6057
];
6158
}
6259

63-
/**
64-
* @dataProvider provideBStrings
65-
*/
60+
#[DataProvider('provideBStrings')]
6661
public function testB(ByteString $expected, ?string $input)
6762
{
6863
$this->assertEquals($expected, b($input));

Tests/Inflector/EnglishInflectorTest.php

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

1212
namespace Symfony\Component\String\Tests\Inflector;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\String\Inflector\EnglishInflector;
1617

@@ -333,17 +334,13 @@ public static function pluralizeProvider()
333334
];
334335
}
335336

336-
/**
337-
* @dataProvider singularizeProvider
338-
*/
337+
#[DataProvider('singularizeProvider')]
339338
public function testSingularize(string $plural, $singular)
340339
{
341340
$this->assertSame(\is_array($singular) ? $singular : [$singular], (new EnglishInflector())->singularize($plural));
342341
}
343342

344-
/**
345-
* @dataProvider pluralizeProvider
346-
*/
343+
#[DataProvider('pluralizeProvider')]
347344
public function testPluralize(string $singular, $plural)
348345
{
349346
$this->assertSame(\is_array($plural) ? $plural : [$plural], (new EnglishInflector())->pluralize($singular));

Tests/Inflector/FrenchInflectorTest.php

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

1212
namespace Symfony\Component\String\Tests\Inflector;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\String\Inflector\FrenchInflector;
1617

@@ -127,19 +128,15 @@ public static function pluralizeProvider()
127128
];
128129
}
129130

130-
/**
131-
* @dataProvider pluralizeProvider
132-
*/
131+
#[DataProvider('pluralizeProvider')]
133132
public function testSingularize(string $singular, string $plural)
134133
{
135134
$this->assertSame([$singular], (new FrenchInflector())->singularize($plural));
136135
// test casing: if the first letter was uppercase, it should remain so
137136
$this->assertSame([ucfirst($singular)], (new FrenchInflector())->singularize(ucfirst($plural)));
138137
}
139138

140-
/**
141-
* @dataProvider pluralizeProvider
142-
*/
139+
#[DataProvider('pluralizeProvider')]
143140
public function testPluralize(string $singular, string $plural)
144141
{
145142
$this->assertSame([$plural], (new FrenchInflector())->pluralize($singular));

Tests/Inflector/SpanishInflectorTest.php

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

1212
namespace Symfony\Component\String\Tests\Inflector;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\String\Inflector\SpanishInflector;
1617

@@ -123,9 +124,7 @@ public static function uninflectedProvider(): array
123124
];
124125
}
125126

126-
/**
127-
* @dataProvider singularizeProvider
128-
*/
127+
#[DataProvider('singularizeProvider')]
129128
public function testSingularize(string $plural, $singular)
130129
{
131130
$this->assertSame(
@@ -134,9 +133,7 @@ public function testSingularize(string $plural, $singular)
134133
);
135134
}
136135

137-
/**
138-
* @dataProvider pluralizeProvider
139-
*/
136+
#[DataProvider('pluralizeProvider')]
140137
public function testPluralize(string $singular, $plural)
141138
{
142139
$this->assertSame(
@@ -145,9 +142,7 @@ public function testPluralize(string $singular, $plural)
145142
);
146143
}
147144

148-
/**
149-
* @dataProvider uninflectedProvider
150-
*/
145+
#[DataProvider('uninflectedProvider')]
151146
public function testUninflected(string $word)
152147
{
153148
$this->assertSame(

Tests/LazyStringTest.php

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

1212
namespace Symfony\Component\String\Tests;
1313

14+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\ErrorHandler\ErrorHandler;
1617
use Symfony\Component\String\LazyString;
@@ -29,9 +30,7 @@ public function testLazyString()
2930
$this->assertSame(1, $count);
3031
}
3132

32-
/**
33-
* @runInSeparateProcess
34-
*/
33+
#[RunInSeparateProcess]
3534
public function testReturnTypeError()
3635
{
3736
ErrorHandler::register();

Tests/Slugger/AsciiSluggerTest.php

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

1212
namespace Symfony\Component\String\Tests\Slugger;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
15+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1416
use PHPUnit\Framework\TestCase;
1517
use Symfony\Component\String\Slugger\AsciiSlugger;
1618

1719
class AsciiSluggerTest extends TestCase
1820
{
19-
/**
20-
* @dataProvider provideSlugTests
21-
*/
21+
#[DataProvider('provideSlugTests')]
2222
public function testSlug(string $expected, string $string, string $separator = '-', ?string $locale = null)
2323
{
2424
$slugger = new AsciiSlugger();
@@ -47,11 +47,8 @@ public static function provideSlugTests(): iterable
4747
yield [\function_exists('transliterator_transliterate') ? 'gh' : '', 'ғ', '-', 'uz_fr']; // Ensure we get the parent locale
4848
}
4949

50-
/**
51-
* @dataProvider provideSlugEmojiTests
52-
*
53-
* @requires extension intl
54-
*/
50+
#[RequiresPhpExtension('intl')]
51+
#[DataProvider('provideSlugEmojiTests')]
5552
public function testSlugEmoji(string $expected, string $string, ?string $locale, string|bool $emoji = true)
5653
{
5754
$slugger = new AsciiSlugger();
@@ -107,9 +104,7 @@ public static function provideSlugEmojiTests(): iterable
107104
];
108105
}
109106

110-
/**
111-
* @requires extension intl
112-
*/
107+
#[RequiresPhpExtension('intl')]
113108
public function testSlugEmojiWithSetLocale()
114109
{
115110
if (!setlocale(\LC_ALL, 'C.UTF-8')) {

Tests/SluggerTest.php

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

1212
namespace Symfony\Component\String\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
15+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1416
use PHPUnit\Framework\TestCase;
1517
use Symfony\Component\String\Slugger\AsciiSlugger;
1618

1719
class SluggerTest extends TestCase
1820
{
19-
/**
20-
* @requires extension intl
21-
*
22-
* @dataProvider provideSlug
23-
*/
21+
#[RequiresPhpExtension('intl')]
22+
#[DataProvider('provideSlug')]
2423
public function testSlug(string $string, string $locale, string $expectedSlug)
2524
{
2625
$slugger = new AsciiSlugger($locale);

0 commit comments

Comments
 (0)