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