File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
src/Symfony/Component/Validator/Tests/Constraints Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff 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 [
You can’t perform that action at this time.
0 commit comments