1111
1212namespace Symfony \Component \Filesystem \Tests ;
1313
14+ use PHPUnit \Framework \Attributes \DataProvider ;
1415use PHPUnit \Framework \TestCase ;
1516use Symfony \Component \Filesystem \Path ;
1617
@@ -164,9 +165,7 @@ public static function provideCanonicalizationTests(): \Generator
164165 yield ['~/../../css/style.css ' , '/css/style.css ' ];
165166 }
166167
167- /**
168- * @dataProvider provideCanonicalizationTests
169- */
168+ #[DataProvider('provideCanonicalizationTests ' )]
170169 public function testCanonicalize (string $ path , string $ canonicalized )
171170 {
172171 $ this ->assertSame ($ canonicalized , Path::canonicalize ($ path ));
@@ -227,9 +226,7 @@ public static function provideGetDirectoryTests(): \Generator
227226 yield ['D:/Folder/Aééé/Subfolder ' , 'D:/Folder/Aééé ' ];
228227 }
229228
230- /**
231- * @dataProvider provideGetDirectoryTests
232- */
229+ #[DataProvider('provideGetDirectoryTests ' )]
233230 public function testGetDirectory (string $ path , string $ directory )
234231 {
235232 $ this ->assertSame ($ directory , Path::getDirectory ($ path ));
@@ -258,9 +255,7 @@ public static function provideGetFilenameWithoutExtensionTests(): \Generator
258255 yield ['/webmozart/symfony/.style.css ' , '.css ' , '.style ' ];
259256 }
260257
261- /**
262- * @dataProvider provideGetFilenameWithoutExtensionTests
263- */
258+ #[DataProvider('provideGetFilenameWithoutExtensionTests ' )]
264259 public function testGetFilenameWithoutExtension (string $ path , ?string $ extension , string $ filename )
265260 {
266261 $ this ->assertSame ($ filename , Path::getFilenameWithoutExtension ($ path , $ extension ));
@@ -283,9 +278,7 @@ public static function provideGetExtensionTests(): \Generator
283278 yield ['/webmozart/symfony/style.ÄÖÜ ' , true , 'äöü ' ];
284279 }
285280
286- /**
287- * @dataProvider provideGetExtensionTests
288- */
281+ #[DataProvider('provideGetExtensionTests ' )]
289282 public function testGetExtension (string $ path , bool $ forceLowerCase , string $ extension )
290283 {
291284 $ this ->assertSame ($ extension , Path::getExtension ($ path , $ forceLowerCase ));
@@ -329,10 +322,9 @@ public static function provideHasExtensionTests(): \Generator
329322 }
330323
331324 /**
332- * @dataProvider provideHasExtensionTests
333- *
334325 * @param string|string[]|null $extension
335326 */
327+ #[DataProvider('provideHasExtensionTests ' )]
336328 public function testHasExtension (bool $ hasExtension , string $ path , $ extension , bool $ ignoreCase )
337329 {
338330 $ this ->assertSame ($ hasExtension , Path::hasExtension ($ path , $ extension , $ ignoreCase ));
@@ -354,9 +346,7 @@ public static function provideChangeExtensionTests(): \Generator
354346 yield ['' , 'css ' , '' ];
355347 }
356348
357- /**
358- * @dataProvider provideChangeExtensionTests
359- */
349+ #[DataProvider('provideChangeExtensionTests ' )]
360350 public function testChangeExtension (string $ path , string $ extension , string $ pathExpected )
361351 {
362352 $ this ->assertSame ($ pathExpected , Path::changeExtension ($ path , $ extension ));
@@ -391,17 +381,13 @@ public static function provideIsAbsolutePathTests(): \Generator
391381 yield ['C:css/style.css ' , false ];
392382 }
393383
394- /**
395- * @dataProvider provideIsAbsolutePathTests
396- */
384+ #[DataProvider('provideIsAbsolutePathTests ' )]
397385 public function testIsAbsolute (string $ path , bool $ isAbsolute )
398386 {
399387 $ this ->assertSame ($ isAbsolute , Path::isAbsolute ($ path ));
400388 }
401389
402- /**
403- * @dataProvider provideIsAbsolutePathTests
404- */
390+ #[DataProvider('provideIsAbsolutePathTests ' )]
405391 public function testIsRelative (string $ path , bool $ isAbsolute )
406392 {
407393 $ this ->assertSame (!$ isAbsolute , Path::isRelative ($ path ));
@@ -433,9 +419,7 @@ public static function provideGetRootTests(): \Generator
433419 yield ['phar://C: ' , 'phar://C:/ ' ];
434420 }
435421
436- /**
437- * @dataProvider provideGetRootTests
438- */
422+ #[DataProvider('provideGetRootTests ' )]
439423 public function testGetRoot (string $ path , string $ root )
440424 {
441425 $ this ->assertSame ($ root , Path::getRoot ($ path ));
@@ -529,9 +513,7 @@ public static function provideMakeAbsoluteTests(): \Generator
529513 yield ['D: \\css \\style.css ' , 'D:/webmozart/symfony ' , 'D:/css/style.css ' ];
530514 }
531515
532- /**
533- * @dataProvider provideMakeAbsoluteTests
534- */
516+ #[DataProvider('provideMakeAbsoluteTests ' )]
535517 public function testMakeAbsolute (string $ relativePath , string $ basePath , string $ absolutePath )
536518 {
537519 $ this ->assertSame ($ absolutePath , Path::makeAbsolute ($ relativePath , $ basePath ));
@@ -579,9 +561,7 @@ public static function provideAbsolutePathsWithDifferentRoots(): \Generator
579561 yield ['phar://C: \\css \\style.css ' , 'C: \\webmozart \\symfony ' ];
580562 }
581563
582- /**
583- * @dataProvider provideAbsolutePathsWithDifferentRoots
584- */
564+ #[DataProvider('provideAbsolutePathsWithDifferentRoots ' )]
585565 public function testMakeAbsoluteDoesNotFailIfDifferentRoot (string $ basePath , string $ absolutePath )
586566 {
587567 // If a path in partition D: is passed, but $basePath is in partition
@@ -682,9 +662,7 @@ public static function provideMakeRelativeTests(): \Generator
682662 yield ['\\webmozart \\symfony \\css \\style.css ' , '/webmozart/symfony ' , 'css/style.css ' ];
683663 }
684664
685- /**
686- * @dataProvider provideMakeRelativeTests
687- */
665+ #[DataProvider('provideMakeRelativeTests ' )]
688666 public function testMakeRelative (string $ absolutePath , string $ basePath , string $ relativePath )
689667 {
690668 $ this ->assertSame ($ relativePath , Path::makeRelative ($ absolutePath , $ basePath ));
@@ -705,9 +683,7 @@ public function testMakeRelativeFailsIfAbsolutePathAndBasePathEmpty()
705683 Path::makeRelative ('/webmozart/symfony/css/style.css ' , '' );
706684 }
707685
708- /**
709- * @dataProvider provideAbsolutePathsWithDifferentRoots
710- */
686+ #[DataProvider('provideAbsolutePathsWithDifferentRoots ' )]
711687 public function testMakeRelativeFailsIfDifferentRoot (string $ absolutePath , string $ basePath )
712688 {
713689 $ this ->expectException (\InvalidArgumentException::class);
@@ -724,9 +700,7 @@ public static function provideIsLocalTests(): \Generator
724700 yield ['' , false ];
725701 }
726702
727- /**
728- * @dataProvider provideIsLocalTests
729- */
703+ #[DataProvider('provideIsLocalTests ' )]
730704 public function testIsLocal (string $ path , bool $ isLocal )
731705 {
732706 $ this ->assertSame ($ isLocal , Path::isLocal ($ path ));
@@ -843,10 +817,9 @@ public static function provideGetLongestCommonBasePathTests(): \Generator
843817 }
844818
845819 /**
846- * @dataProvider provideGetLongestCommonBasePathTests
847- *
848820 * @param string[] $paths
849821 */
822+ #[DataProvider('provideGetLongestCommonBasePathTests ' )]
850823 public function testGetLongestCommonBasePath (array $ paths , ?string $ basePath )
851824 {
852825 $ this ->assertSame ($ basePath , Path::getLongestCommonBasePath (...$ paths ));
@@ -933,9 +906,7 @@ public static function provideIsBasePathTests(): \Generator
933906 yield ['phar://C:/base/path ' , 'phar://D:/base/path ' , false ];
934907 }
935908
936- /**
937- * @dataProvider provideIsBasePathTests
938- */
909+ #[DataProvider('provideIsBasePathTests ' )]
939910 public function testIsBasePath (string $ path , string $ ofPath , bool $ result )
940911 {
941912 $ this ->assertSame ($ result , Path::isBasePath ($ path , $ ofPath ));
@@ -1012,9 +983,7 @@ public static function provideJoinTests(): \Generator
1012983 yield [['phar://C:/ ' , '/path/to/test ' ], 'phar://C:/path/to/test ' ];
1013984 }
1014985
1015- /**
1016- * @dataProvider provideJoinTests
1017- */
986+ #[DataProvider('provideJoinTests ' )]
1018987 public function testJoin (array $ paths , $ result )
1019988 {
1020989 $ this ->assertSame ($ result , Path::join (...$ paths ));
0 commit comments