Skip to content

Commit 85bd998

Browse files
Merge branch '7.4' into 8.0
* 7.4: replace PHPUnit annotations with attributes
2 parents ebafbcc + 5de9698 commit 85bd998

19 files changed

+49
-78
lines changed

Tests/Comparator/ComparatorTest.php

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

1212
namespace Symfony\Component\Finder\Tests\Comparator;
1313

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

@@ -24,9 +25,7 @@ public function testInvalidOperator()
2425
new Comparator('some target', 'foo');
2526
}
2627

27-
/**
28-
* @dataProvider provideMatches
29-
*/
28+
#[DataProvider('provideMatches')]
3029
public function testTestSucceeds(string $operator, string $target, string $testedValue)
3130
{
3231
$c = new Comparator($target, $operator);
@@ -53,9 +52,7 @@ public static function provideMatches(): array
5352
];
5453
}
5554

56-
/**
57-
* @dataProvider provideNonMatches
58-
*/
55+
#[DataProvider('provideNonMatches')]
5956
public function testTestFails(string $operator, string $target, string $testedValue)
6057
{
6158
$c = new Comparator($target, $operator);

Tests/Comparator/DateComparatorTest.php

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

1212
namespace Symfony\Component\Finder\Tests\Comparator;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Finder\Comparator\DateComparator;
1617

@@ -33,9 +34,7 @@ public function testConstructor()
3334
}
3435
}
3536

36-
/**
37-
* @dataProvider getTestData
38-
*/
37+
#[DataProvider('getTestData')]
3938
public function testTest($test, $match, $noMatch)
4039
{
4140
$c = new DateComparator($test);

Tests/Comparator/NumberComparatorTest.php

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

1212
namespace Symfony\Component\Finder\Tests\Comparator;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Finder\Comparator\NumberComparator;
1617

1718
class NumberComparatorTest extends TestCase
1819
{
19-
/**
20-
* @dataProvider getConstructorTestData
21-
*/
20+
#[DataProvider('getConstructorTestData')]
2221
public function testConstructor($successes, $failures)
2322
{
2423
foreach ($successes as $s) {
@@ -35,9 +34,7 @@ public function testConstructor($successes, $failures)
3534
}
3635
}
3736

38-
/**
39-
* @dataProvider getTestData
40-
*/
37+
#[DataProvider('getTestData')]
4138
public function testTest($test, $match, $noMatch)
4239
{
4340
$c = new NumberComparator($test);

Tests/FinderOpenBasedirTest.php

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

1212
namespace Symfony\Component\Finder\Tests;
1313

14+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
1415
use Symfony\Component\Finder\Finder;
1516

1617
class FinderOpenBasedirTest extends Iterator\RealIteratorTestCase
1718
{
18-
/**
19-
* @runInSeparateProcess
20-
*/
19+
#[RunInSeparateProcess]
2120
public function testIgnoreVCSIgnoredWithOpenBasedir()
2221
{
2322
$this->markTestIncomplete('Test case needs to be refactored so that PHPUnit can run it');

Tests/FinderTest.php

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

1212
namespace Symfony\Component\Finder\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
15+
use PHPUnit\Framework\ExpectationFailedException;
1416
use Symfony\Component\Finder\Exception\DirectoryNotFoundException;
1517
use Symfony\Component\Finder\Finder;
1618

@@ -297,9 +299,7 @@ public function testNotNameWithArrayParam()
297299
]), $finder->in(self::$tmpDir)->getIterator());
298300
}
299301

300-
/**
301-
* @dataProvider getRegexNameTestData
302-
*/
302+
#[DataProvider('getRegexNameTestData')]
303303
public function testRegexName($regex)
304304
{
305305
$finder = $this->buildFinder();
@@ -1367,9 +1367,7 @@ public function testNoResults()
13671367
$this->assertFalse($finder->hasResults());
13681368
}
13691369

1370-
/**
1371-
* @dataProvider getContainsTestData
1372-
*/
1370+
#[DataProvider('getContainsTestData')]
13731371
public function testContains($matchPatterns, $noMatchPatterns, $expected)
13741372
{
13751373
$finder = $this->buildFinder();
@@ -1498,9 +1496,7 @@ public static function getRegexNameTestData()
14981496
];
14991497
}
15001498

1501-
/**
1502-
* @dataProvider getTestPathData
1503-
*/
1499+
#[DataProvider('getTestPathData')]
15041500
public function testPath($matchPatterns, $noMatchPatterns, array $expected)
15051501
{
15061502
$finder = $this->buildFinder();
@@ -1602,7 +1598,7 @@ public function testAccessDeniedException()
16021598
$this->fail('Finder should throw an exception when opening a non-readable directory.');
16031599
} catch (\Exception $e) {
16041600
$expectedExceptionClass = 'Symfony\\Component\\Finder\\Exception\\AccessDeniedException';
1605-
if ($e instanceof \PHPUnit\Framework\ExpectationFailedException) {
1601+
if ($e instanceof ExpectationFailedException) {
16061602
$this->fail(\sprintf("Expected exception:\n%s\nGot:\n%s\nWith comparison failure:\n%s", $expectedExceptionClass, 'PHPUnit\Framework\ExpectationFailedException', $e->getComparisonFailure()->getExpectedAsString()));
16071603
}
16081604

Tests/GitignoreTest.php

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

1212
namespace Symfony\Component\Finder\Tests;
1313

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

@@ -19,10 +20,8 @@
1920
*/
2021
class GitignoreTest extends TestCase
2122
{
22-
/**
23-
* @dataProvider provider
24-
* @dataProvider providerExtended
25-
*/
23+
#[DataProvider('provider')]
24+
#[DataProvider('providerExtended')]
2625
public function testToRegex(array $gitignoreLines, array $matchingCases, array $nonMatchingCases)
2726
{
2827
$patterns = implode("\n", $gitignoreLines);
@@ -444,9 +443,7 @@ public static function providerExtended(): array
444443
return $cases;
445444
}
446445

447-
/**
448-
* @dataProvider provideNegatedPatternsCases
449-
*/
446+
#[DataProvider('provideNegatedPatternsCases')]
450447
public function testToRegexMatchingNegatedPatterns(array $gitignoreLines, array $matchingCases, array $nonMatchingCases)
451448
{
452449
$patterns = implode("\n", $gitignoreLines);

Tests/Iterator/CustomFilterIteratorTest.php

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

1212
namespace Symfony\Component\Finder\Tests\Iterator;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Symfony\Component\Finder\Iterator\CustomFilterIterator;
1516

1617
class CustomFilterIteratorTest extends IteratorTestCase
@@ -21,9 +22,7 @@ public function testWithInvalidFilter()
2122
new CustomFilterIterator(new Iterator(), ['foo']);
2223
}
2324

24-
/**
25-
* @dataProvider getAcceptData
26-
*/
25+
#[DataProvider('getAcceptData')]
2726
public function testAccept($filters, $expected)
2827
{
2928
$inner = new Iterator(['test.php', 'test.py', 'foo.php']);

Tests/Iterator/DateRangeFilterIteratorTest.php

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

1212
namespace Symfony\Component\Finder\Tests\Iterator;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Symfony\Component\Finder\Comparator\DateComparator;
1516
use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
1617

1718
class DateRangeFilterIteratorTest extends RealIteratorTestCase
1819
{
19-
/**
20-
* @dataProvider getAcceptData
21-
*/
20+
#[DataProvider('getAcceptData')]
2221
public function testAccept($size, $expected)
2322
{
2423
$files = self::$files;

Tests/Iterator/DepthRangeFilterIteratorTest.php

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

1212
namespace Symfony\Component\Finder\Tests\Iterator;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
1516

1617
class DepthRangeFilterIteratorTest extends RealIteratorTestCase
1718
{
18-
/**
19-
* @dataProvider getAcceptData
20-
*/
19+
#[DataProvider('getAcceptData')]
2120
public function testAccept($minDepth, $maxDepth, $expected)
2221
{
2322
$inner = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->toAbsolute(), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);

Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php

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

1212
namespace Symfony\Component\Finder\Tests\Iterator;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
1516
use Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator;
1617

1718
class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
1819
{
19-
/**
20-
* @dataProvider getAcceptData
21-
*/
20+
#[DataProvider('getAcceptData')]
2221
public function testAccept($directories, $expected)
2322
{
2423
$inner = new \RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->toAbsolute(), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);

0 commit comments

Comments
 (0)