Make data providers static

From PHPUnit 10, all data providers need to be static. This commit will
make migrating from version 9 to 10 a bit easier.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2023-04-02 16:00:37 +02:00
commit 2ee7509c2e
No known key found for this signature in database
GPG key ID: 221E9281655813A6
151 changed files with 891 additions and 891 deletions

View file

@ -27,10 +27,30 @@ use function sprintf;
*/
final class CheckExceptionsTest extends TestCase
{
/**
* @dataProvider provideListOfRuleNames
*
* @test
*/
public function ruleHasAnExceptionWhichHasValidApi(string $ruleName): void
{
$exceptionClass = 'Respect\\Validation\\Exceptions\\' . $ruleName . 'Exception';
self::assertTrue(
class_exists($exceptionClass),
sprintf('Expected exception class to exist: %s.', $ruleName)
);
$reflectionClass = new ReflectionClass($exceptionClass);
self::assertTrue(
$reflectionClass->isSubclassOf(ValidationException::class),
'Every Respect/Validation exception must extend ValidationException.'
);
}
/**
* @return string[][]
*/
public function provideListOfRuleNames(): array
public static function provideListOfRuleNames(): array
{
$rulesDirectory = 'library/Rules';
$rulesDirectoryIterator = new DirectoryIterator($rulesDirectory);
@ -60,24 +80,4 @@ final class CheckExceptionsTest extends TestCase
return $ruleNames;
}
/**
* @dataProvider provideListOfRuleNames
*
* @test
*/
public function ruleHasAnExceptionWhichHasValidApi(string $ruleName): void
{
$exceptionClass = 'Respect\\Validation\\Exceptions\\' . $ruleName . 'Exception';
self::assertTrue(
class_exists($exceptionClass),
sprintf('Expected exception class to exist: %s.', $ruleName)
);
$reflectionClass = new ReflectionClass($exceptionClass);
self::assertTrue(
$reflectionClass->isSubclassOf(ValidationException::class),
'Every Respect/Validation exception must extend ValidationException.'
);
}
}