8000 minor #53176 Fix and add test (OskarStark) · symfony/symfony@1eab442 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1eab442

Browse files
committed
minor #53176 Fix and add test (OskarStark)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- Fix and add test | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | -- | License | MIT The exception is not raised on `validate` but on instantiating the constraint. I also added a test for an unknown format in an array. Commits ------- 2358719 Fix and add test
2 parents e2b7fd6 + 2358719 commit 1eab442

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/Symfony/Component/Validator/Tests/Constraints/CssColorValidatorTest.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,22 @@ public function getInvalidHSLA(): array
418418
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 %']];
419419
}
420420

421-
public function testUnknownFormatsOnValidateTriggerException()
421+
/**
422+
* @dataProvider getInvalidFormats
423+
*/
424+
public function testUnknownFormatAsStringThrowsException($formats)
422425
{
423426
$this->expectException(\InvalidArgumentException::class);
424427
$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".');
425-
$constraint = new CssColor('Unknown Format');
426-
$this->validator->validate('#F4B907', $constraint);
428+
429+
new CssColor($formats);
430+
}
431+
432+
public static function getInvalidFormats(): array
433+
{
434+
return [
435+
'as string' => ['Unknown Format'],
436+
'as array' => [['Unknown Format']],
437+
];
427438
}
428439
}

src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTestCase.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,9 @@ public function testMaxSizeNotExceeded($bytesWritten, $limit)
230230
public function testInvalidMaxSize()
231231
{
232232
$this->expectException(ConstraintDefinitionException::class);
233-
$constraint = new File([
233+
new File([
234234
'maxSize' => '1abc',
235235
]);
236-
237-
$this->validator->validate($this->path, $constraint);
238236
}
239237

240238
public static function provideBinaryFormatTests()

0 commit comments

Comments
 (0)
0