Upgrade tests to PhpUnit 10 (#5252)
This commit is contained in:
@@ -27,7 +27,7 @@ class ColorChoicesValidatorTest extends ConstraintValidatorTestCase
|
||||
return new ColorChoicesValidator();
|
||||
}
|
||||
|
||||
public function getValidColors()
|
||||
public static function getValidColors()
|
||||
{
|
||||
yield ['#000000'];
|
||||
yield ['#fff000'];
|
||||
@@ -49,16 +49,15 @@ class ColorChoicesValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider getValidColors
|
||||
* @param string $color
|
||||
*/
|
||||
public function testConstraintWithValidColor($color): void
|
||||
public function testConstraintWithValidColor(?string $color): void
|
||||
{
|
||||
$constraint = new ColorChoices();
|
||||
$this->validator->validate($color, $constraint);
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getInvalidColors()
|
||||
public static function getInvalidColors()
|
||||
{
|
||||
yield ['sdf_sdf|#000000', null, 'sdf_sdf', '#000000'];
|
||||
yield ['sdfghjklöß.|#aaabbb', null, 'sdfghjklöß.', '#aaabbb'];
|
||||
|
||||
@@ -27,7 +27,7 @@ class DateTimeFormatValidatorTest extends ConstraintValidatorTestCase
|
||||
return new DateTimeFormatValidator();
|
||||
}
|
||||
|
||||
public function getValidData()
|
||||
public static function getValidData()
|
||||
{
|
||||
return [
|
||||
['10:00'],
|
||||
@@ -48,16 +48,15 @@ class DateTimeFormatValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider getValidData
|
||||
* @param string $input
|
||||
*/
|
||||
public function testConstraintWithValidData($input): void
|
||||
public function testConstraintWithValidData(?string $input): void
|
||||
{
|
||||
$constraint = new DateTimeFormat();
|
||||
$this->validator->validate($input, $constraint);
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getInvalidData()
|
||||
public static function getInvalidData()
|
||||
{
|
||||
return [
|
||||
['13-13'],
|
||||
@@ -70,9 +69,8 @@ class DateTimeFormatValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidData
|
||||
* @param mixed $input
|
||||
*/
|
||||
public function testValidationError($input): void
|
||||
public function testValidationError(?string $input): void
|
||||
{
|
||||
$constraint = new DateTimeFormat();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class DurationValidatorTest extends ConstraintValidatorTestCase
|
||||
/**
|
||||
* @return array<array<string|int|null>>
|
||||
*/
|
||||
public function getValidData(): array
|
||||
public static function getValidData(): array
|
||||
{
|
||||
return [
|
||||
['2h'],
|
||||
@@ -81,7 +81,7 @@ class DurationValidatorTest extends ConstraintValidatorTestCase
|
||||
/**
|
||||
* @return array<array<string>>
|
||||
*/
|
||||
public function getInvalidData(): array
|
||||
public static function getInvalidData(): array
|
||||
{
|
||||
return [
|
||||
['13-13'],
|
||||
|
||||
@@ -27,7 +27,7 @@ class HexColorValidatorTest extends ConstraintValidatorTestCase
|
||||
return new HexColorValidator();
|
||||
}
|
||||
|
||||
public function getValidColors()
|
||||
public static function getValidColors()
|
||||
{
|
||||
yield ['#000'];
|
||||
yield ['#aaa'];
|
||||
@@ -48,16 +48,15 @@ class HexColorValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider getValidColors
|
||||
* @param string $color
|
||||
*/
|
||||
public function testConstraintWithValidColor($color): void
|
||||
public function testConstraintWithValidColor(?string $color): void
|
||||
{
|
||||
$constraint = new HexColor();
|
||||
$this->validator->validate($color, $constraint);
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getInvalidColors()
|
||||
public static function getInvalidColors()
|
||||
{
|
||||
yield ['string'];
|
||||
yield ['000'];
|
||||
@@ -77,18 +76,17 @@ class HexColorValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidColors
|
||||
* @param mixed $color
|
||||
*/
|
||||
public function testValidationError($color, $parameterType = null): void
|
||||
public function testValidationError(mixed $color, ?string $parameterType = null): void
|
||||
{
|
||||
$constraint = new HexColor();
|
||||
|
||||
$this->validator->validate($color, $constraint);
|
||||
|
||||
if ($parameterType !== null) {
|
||||
$expectedFormat = $parameterType;
|
||||
if (\is_string($color)) {
|
||||
$expectedFormat = '"' . $color . '"';
|
||||
} else {
|
||||
$expectedFormat = \is_string($color) ? '"' . $color . '"' : $color;
|
||||
$expectedFormat = $parameterType ?? '';
|
||||
}
|
||||
|
||||
$this->buildViolation('The given value is not a valid hexadecimal color.')
|
||||
|
||||
@@ -34,7 +34,7 @@ class RoleNameValidatorTest extends ConstraintValidatorTestCase
|
||||
/**
|
||||
* @return array<array<int, string>>
|
||||
*/
|
||||
public function getValidRoleNames(): array
|
||||
public static function getValidRoleNames(): array
|
||||
{
|
||||
return [
|
||||
['FOOBAR'],
|
||||
@@ -54,7 +54,6 @@ class RoleNameValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider getValidRoleNames
|
||||
* @param string $role
|
||||
*/
|
||||
public function testConstraintWithValidRole(string $role): void
|
||||
{
|
||||
@@ -76,7 +75,7 @@ class RoleNameValidatorTest extends ConstraintValidatorTestCase
|
||||
/**
|
||||
* @return array<array<string|int>>
|
||||
*/
|
||||
public function getInvalidRoleNames(): array
|
||||
public static function getInvalidRoleNames(): array
|
||||
{
|
||||
return [
|
||||
['foo'],
|
||||
|
||||
@@ -32,7 +32,7 @@ class RoleValidatorTest extends ConstraintValidatorTestCase
|
||||
return new RoleValidator($roleService);
|
||||
}
|
||||
|
||||
public function getValidRoles()
|
||||
public static function getValidRoles()
|
||||
{
|
||||
return [
|
||||
[User::ROLE_USER],
|
||||
@@ -51,9 +51,8 @@ class RoleValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider getValidRoles
|
||||
* @param string $role
|
||||
*/
|
||||
public function testConstraintWithValidRole($role): void
|
||||
public function testConstraintWithValidRole(string $role): void
|
||||
{
|
||||
$constraint = new Role();
|
||||
$this->validator->validate($role, $constraint);
|
||||
@@ -70,7 +69,7 @@ class RoleValidatorTest extends ConstraintValidatorTestCase
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidRoles()
|
||||
public static function getInvalidRoles()
|
||||
{
|
||||
return [
|
||||
['foo'],
|
||||
@@ -84,9 +83,8 @@ class RoleValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidRoles
|
||||
* @param mixed $role
|
||||
*/
|
||||
public function testValidationError($role): void
|
||||
public function testValidationError(mixed $role): void
|
||||
{
|
||||
$constraint = new Role([
|
||||
'message' => 'myMessage',
|
||||
|
||||
@@ -52,7 +52,7 @@ class TimeFormatValidatorTest extends ConstraintValidatorTestCase
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidTimes()
|
||||
public static function getValidTimes()
|
||||
{
|
||||
return [
|
||||
[''],
|
||||
@@ -79,7 +79,7 @@ class TimeFormatValidatorTest extends ConstraintValidatorTestCase
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidTimes()
|
||||
public static function getInvalidTimes()
|
||||
{
|
||||
return [
|
||||
['a'],
|
||||
|
||||
@@ -143,7 +143,7 @@ class TimesheetBasicValidatorTest extends ConstraintValidatorTestCase
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getProjectStartEndTestData()
|
||||
public static function getProjectStartEndTestData()
|
||||
{
|
||||
yield [new \DateTime(), new \DateTime(), [
|
||||
['begin_date', TimesheetBasic::PROJECT_NOT_STARTED, 'The project has not started at that time.'],
|
||||
|
||||
@@ -195,7 +195,7 @@ class TimesheetBudgetUsedValidatorTest extends ConstraintValidatorTestCase
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getViolationTestData()
|
||||
public static function getViolationTestData()
|
||||
{
|
||||
return [
|
||||
// activity: violations ----------------------------------------------------------------------
|
||||
|
||||
@@ -171,7 +171,7 @@ class TimesheetLockdownValidatorTest extends ConstraintValidatorTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function getTestData()
|
||||
public static function getTestData()
|
||||
{
|
||||
// changing before last dockdown period is not allowed
|
||||
yield [false, false, '-5 days', '+5 days', true];
|
||||
@@ -219,7 +219,7 @@ class TimesheetLockdownValidatorTest extends ConstraintValidatorTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function getConfigTestData()
|
||||
public static function getConfigTestData()
|
||||
{
|
||||
yield [false, false, null, null, null, false];
|
||||
yield [false, false, '+5 days', null, null, false];
|
||||
|
||||
@@ -94,7 +94,7 @@ class TimesheetRestartValidatorTest extends ConstraintValidatorTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function getTestData()
|
||||
public static function getTestData()
|
||||
{
|
||||
yield [false, 'end_date', 'default'];
|
||||
yield [true, null, 'default'];
|
||||
|
||||
Reference in New Issue
Block a user