diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CssColorValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CssColorValidatorTest.php index 95b0b6f29ea34..5c7904a8001af 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CssColorValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CssColorValidatorTest.php @@ -418,11 +418,22 @@ public function getInvalidHSLA(): array return [['hsla(1000, 1000%, 20000%, 999)'], ['hsla(-100, -10%, -2%, 999)'], ['hsla(a, b, c, d)'], ['hsla(a, b%, c%, d)'], ['hsla( 9 99% , 99 9% , 9 %']]; } - public function testUnknownFormatsOnValidateTriggerException() + /** + * @dataProvider getInvalidFormats + */ + public function testUnknownFormatAsStringThrowsException($formats) { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The "formats" parameter value is not valid. It must contain one or more of the following values: "hex_long, hex_long_with_alpha, hex_short, hex_short_with_alpha, basic_named_colors, extended_named_colors, system_colors, keywords, rgb, rgba, hsl, hsla".'); - $constraint = new CssColor('Unknown Format'); - $this->validator->validate('#F4B907', $constraint); + + new CssColor($formats); + } + + public static function getInvalidFormats(): array + { + return [ + 'as string' => ['Unknown Format'], + 'as array' => [['Unknown Format']], + ]; } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTestCase.php index cd16f8b4b0682..23d8a96ca267f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTestCase.php @@ -230,11 +230,9 @@ public function testMaxSizeNotExceeded($bytesWritten, $limit) public function testInvalidMaxSize() { $this->expectException(ConstraintDefinitionException::class); - $constraint = new File([ + new File([ 'maxSize' => '1abc', ]); - - $this->validator->validate($this->path, $constraint); } public static function provideBinaryFormatTests()