mirror of
https://github.com/Respect/Validation.git
synced 2026-03-17 15:50:03 +01:00
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:
parent
ebcf247187
commit
2ee7509c2e
151 changed files with 891 additions and 891 deletions
|
|
@ -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.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue