8000 [Validator] Add tests for `MacAddress` · symfony/symfony@7ce3bb5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ce3bb5

Browse files
tcochnicolas-grekas
authored andcommitted
[Validator] Add tests for MacAddress
1 parent ed7b88c commit 7ce3bb5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ public function testValidMac($mac)
6363
$this->assertNoViolation();
6464
}
6565

66+
/**
67+
* @dataProvider getNotValidMacs
68+
*/
69+
public function testNotValidMac($mac)
70+
{
71+
$this->validator->validate($mac, new MacAddress());
72+
73+
$this->buildViolation('This value is not a valid MAC address.')
74+
->setParameter('{{ value }}', '"'.$mac.'"')
75+
->setCode(MacAddress::INVALID_MAC_ERROR)
76+
->assertRaised();
77+
}
78+
6679
public static function getValidMacs(): array
6780
{
6881
return [
@@ -76,6 +89,17 @@ public static function getValidMacs(): array
7689
];
7790
}
7891

92+
public static function getNotValidMacs(): array
93+
{
94+
return [
95+
['00:00:00:00:00'],
96+
['00:00:00:00:00:0G'],
97+
['GG:GG:GG:GG:GG:GG'],
98+
['GG-GG-GG-GG-GG-GG'],
99+
['GGGG.GGGG.GGGG'],
100+
];
101+
}
102+
79103
public static function getValidLocalUnicastMacs(): array
80104
{
81105
return [

0 commit comments

Comments
 (0)
0