@@ -56,23 +56,31 @@ public static function provideNonSuspiciousStrings(): iterable
56
56
/**
57
57
* @dataProvider provideSuspiciousStrings
58
58
*/
59
- public function testSuspiciousStrings (string $ string , array $ options , string $ errorCode , string $ errorMessage )
59
+ public function testSuspiciousStrings (string $ string , array $ options , array $ errors )
60
60
{
61
61
$ this ->validator ->validate ($ string , new NoSuspiciousCharacters ($ options ));
62
62
63
- $ this ->buildViolation ($ errorMessage )
64
- ->setCode ($ errorCode )
63
+ $ violations = $ this ->buildViolation (reset ( $ errors ) )
64
+ ->setCode (key ( $ errors ) )
65
65
->setParameter ('{{ value }} ' , '" ' .$ string .'" ' )
66
- ->assertRaised ();
66
+ ;
67
+
68
+ while ($ message = next ($ errors )) {
69
+ $ violations = $ violations ->buildNextViolation ($ message )
70
+ ->setCode (key ($ errors ))
71
+ ->setParameter ('{{ value }} ' , '" ' .$ string .'" ' )
72
+ ;
73
+ }
74
+
75
+ $ violations ->assertRaised ();
67
76
}
68
77
69
78
public static function provideSuspiciousStrings (): iterable
70
79
{
71
80
yield 'Fails RESTRICTION_LEVEL check because of character outside ASCII range ' => [
72
81
'à ' ,
73
82
['restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_ASCII ],
74
- NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
75
- 'This value contains characters that are not allowed by the current restriction-level. ' ,
83
+ [NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR => 'This value contains characters that are not allowed by the current restriction-level. ' ],
76
84
];
77
85
78
86
yield 'Fails RESTRICTION_LEVEL check because of mixed-script string ' => [
@@ -81,8 +89,7 @@ public static function provideSuspiciousStrings(): iterable
81
89
'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_SINGLE_SCRIPT ,
82
90
'locales ' => ['en ' , 'zh_Hant_TW ' ],
83
91
],
84
- NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
85
- 'This value contains characters that are not allowed by the current restriction-level. ' ,
92
+ [NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR => 'This value contains characters that are not allowed by the current restriction-level. ' ],
86
93
];
87
94
88
95
yield 'Fails RESTRICTION_LEVEL check because RESTRICTION_LEVEL_HIGH disallows Armenian script ' => [
@@ -91,8 +98,7 @@ public static function provideSuspiciousStrings(): iterable
91
98
'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_HIGH ,
92
99
'locales ' => ['en ' , 'hy_AM ' ],
93
100
],
94
- NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
95
- 'This value contains characters that are not allowed by the current restriction-level. ' ,
101
+ [NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR => 'This value contains characters that are not allowed by the current restriction-level. ' ],
96
102
];
97
103
98
104
yield 'Fails RESTRICTION_LEVEL check because RESTRICTION_LEVEL_MODERATE disallows Greek script ' => [
@@ -101,8 +107,7 @@ public static function provideSuspiciousStrings(): iterable
101
107
'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_MODERATE ,
102
108
'locales ' => ['en ' , 'el_GR ' ],
103
109
],
104
- NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
105
- 'This value contains characters that are not allowed by the current restriction-level. ' ,
110
+ [NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR => 'This value contains characters that are not allowed by the current restriction-level. ' ],
106
111
];
107
112
108
113
yield 'Fails RESTRICTION_LEVEL check because of characters missing from the configured locales’ scripts ' => [
@@ -111,35 +116,43 @@ public static function provideSuspiciousStrings(): iterable
111
116
'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_MINIMAL ,
112
117
'locales ' => ['en ' ],
113
118
],
114
- NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
115
- 'This value contains characters that are not allowed by the current restriction-level. ' ,
119
+ [NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR => 'This value contains characters that are not allowed by the current restriction-level. ' ],
116
120
];
117
121
118
122
yield 'Fails INVISIBLE check because of duplicated non-spacing mark ' => [
119
123
'à̀ ' ,
120
124
[
121
125
'checks ' => NoSuspiciousCharacters::CHECK_INVISIBLE ,
122
126
],
123
- NoSuspiciousCharacters::INVISIBLE_ERROR ,
124
- 'Using invisible characters is not allowed. ' ,
127
+ [NoSuspiciousCharacters::INVISIBLE_ERROR => 'Using invisible characters is not allowed. ' ],
125
128
];
126
129
127
130
yield 'Fails MIXED_NUMBERS check because of different numbering systems ' => [
128
131
'8৪ ' ,
129
132
[
130
133
'checks ' => NoSuspiciousCharacters::CHECK_MIXED_NUMBERS ,
131
134
],
132
- NoSuspiciousCharacters::MIXED_NUMBERS_ERROR ,
133
- 'Mixing numbers from different scripts is not allowed. ' ,
135
+ [NoSuspiciousCharacters::MIXED_NUMBERS_ERROR => 'Mixing numbers from different scripts is not allowed. ' ],
134
136
];
135
137
136
138
yield 'Fails HIDDEN_OVERLAY check because of hidden combining character ' => [
137
139
'i̇ ' ,
138
140
[
139
141
'checks ' => NoSuspiciousCharacters::CHECK_HIDDEN_OVERLAY ,
140
142
],
141
- NoSuspiciousCharacters::HIDDEN_OVERLAY_ERROR ,
142
- 'Using hidden overlay characters is not allowed. ' ,
143
+ [NoSuspiciousCharacters::HIDDEN_OVERLAY_ERROR => 'Using hidden overlay characters is not allowed. ' ],
144
+ ];
145
+
146
+ yield 'Fails both HIDDEN_OVERLAY and RESTRICTION_LEVEL checks ' => [
147
+ 'i̇ ' ,
148
+ [
149
+ 'checks ' => NoSuspiciousCharacters::CHECK_HIDDEN_OVERLAY ,
150
+ 'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_ASCII ,
151
+ ],
152
+ [
153
+ NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR => 'This value contains characters that are not allowed by the current restriction-level. ' ,
154
+ NoSuspiciousCharacters::HIDDEN_OVERLAY_ERROR => 'Using hidden overlay characters is not allowed. ' ,
155
+ ],
143
156
];
144
157
}
145
158
0 commit comments