@@ -24,7 +24,7 @@ class NoSuspiciousCharactersValidatorTest extends ConstraintValidatorTestCase
24
24
{
25
25
protected function createValidator (): NoSuspiciousCharactersValidator
26
26
{
27
- return new NoSuspiciousCharactersValidator ([ ' en ' ] );
27
+ return new NoSuspiciousCharactersValidator ();
28
28
}
29
29
30
30
/**
@@ -44,26 +44,13 @@ public static function provideNonSuspiciousStrings(): iterable
44
44
['restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_SINGLE_SCRIPT ],
45
45
];
46
46
47
- yield 'Empty profile cannot make CHAR_LIMIT fail ' => [
47
+ yield 'RESTRICTION_LEVEL_MINIMAL cannot fail without configured locales ' => [
48
48
'àㄚԱπ৪ ' ,
49
49
[
50
- 'checks ' => NoSuspiciousCharacters::CHECK_CHAR_LIMIT ,
50
+ 'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_MINIMAL ,
51
51
'locales ' => [],
52
52
],
53
53
];
54
-
55
- yield 'Override setAllowedLocales implicit CHAR_LIMIT check ' => [
56
- 'Ա ' ,
57
- ['checks ' => NoSuspiciousCharacters::CHECK_HIDDEN_OVERLAY ],
58
- ];
59
-
60
- yield 'Override setRestrictionLevel implicit RESTRICTION_LEVEL check ' => [
61
- 'à ' ,
62
- [
63
- 'checks ' => 0 ,
64
- 'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_ASCII ,
65
- ],
66
- ];
67
54
}
68
55
69
56
/**
@@ -85,7 +72,7 @@ public static function provideSuspiciousStrings(): iterable
85
72
'à ' ,
86
73
['restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_ASCII ],
87
74
NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
88
- 'Restriction level check failed . ' ,
75
+ 'This value contains characters that are not allowed by the current restriction-level . ' ,
89
76
];
90
77
91
78
yield 'Fails RESTRICTION_LEVEL check because of mixed-script string ' => [
@@ -95,37 +82,37 @@ public static function provideSuspiciousStrings(): iterable
95
82
'locales ' => ['en ' , 'zh_Hant_TW ' ],
96
83
],
97
84
NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
98
- 'Restriction level check failed . ' ,
85
+ 'This value contains characters that are not allowed by the current restriction-level . ' ,
99
86
];
100
87
101
- yield 'Fails RESTRICTION_LEVEL check because of disallowed Armenian script ' => [
88
+ yield 'Fails RESTRICTION_LEVEL check because RESTRICTION_LEVEL_HIGH disallows Armenian script ' => [
102
89
'àԱ ' ,
103
90
[
104
91
'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_HIGH ,
105
92
'locales ' => ['en ' , 'hy_AM ' ],
106
93
],
107
94
NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
108
- 'Restriction level check failed . ' ,
95
+ 'This value contains characters that are not allowed by the current restriction-level . ' ,
109
96
];
110
97
111
- yield 'Fails RESTRICTION_LEVEL check because of disallowed Greek script ' => [
98
+ yield 'Fails RESTRICTION_LEVEL check because RESTRICTION_LEVEL_MODERATE disallows Greek script ' => [
112
99
'àπ ' ,
113
100
[
114
101
'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_MODERATE ,
115
102
'locales ' => ['en ' , 'el_GR ' ],
116
103
],
117
104
NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
118
- 'Restriction level check failed . ' ,
105
+ 'This value contains characters that are not allowed by the current restriction-level . ' ,
119
106
];
120
107
121
- yield 'Fails RESTRICTION_LEVEL check because of Greek script absent from profile ' => [
108
+ yield 'Fails RESTRICTION_LEVEL check because of characters missing from the configured locales’ scripts ' => [
122
109
'àπ ' ,
123
110
[
124
- 'checks ' => NoSuspiciousCharacters::CHECK_RESTRICTION_LEVEL ,
125
111
'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_MINIMAL ,
112
+ 'locales ' => ['en ' ],
126
113
],
127
114
NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
128
- 'Restriction level check failed . ' ,
115
+ 'This value contains characters that are not allowed by the current restriction-level . ' ,
129
116
];
130
117
131
118
yield 'Fails INVISIBLE check because of duplicated non-spacing mark ' => [
@@ -134,16 +121,7 @@ public static function provideSuspiciousStrings(): iterable
134
121
'checks ' => NoSuspiciousCharacters::CHECK_INVISIBLE ,
135
122
],
136
123
NoSuspiciousCharacters::INVISIBLE_ERROR ,
137
- 'Invisible check failed. ' ,
138
- ];
139
-
140
- yield 'Fails CHAR_LIMIT check because of Greek script absent from profile ' => [
141
- 'àπ ' ,
142
- [
143
- 'checks ' => NoSuspiciousCharacters::CHECK_CHAR_LIMIT ,
144
- ],
145
- NoSuspiciousCharacters::CHAR_LIMIT_ERROR ,
146
- 'Char limit check failed. ' ,
124
+ 'Using invisible characters is not allowed. ' ,
147
125
];
148
126
149
127
yield 'Fails MIXED_NUMBERS check because of different numbering systems ' => [
@@ -152,7 +130,7 @@ public static function provideSuspiciousStrings(): iterable
152
130
'checks ' => NoSuspiciousCharacters::CHECK_MIXED_NUMBERS ,
153
131
],
154
132
NoSuspiciousCharacters::MIXED_NUMBERS_ERROR ,
155
- 'Mixed numbers check failed . ' ,
133
+ 'Mixing numbers from different scripts is not allowed . ' ,
156
134
];
157
135
158
136
yield 'Fails HIDDEN_OVERLAY check because of hidden combining character ' => [
@@ -161,14 +139,13 @@ public static function provideSuspiciousStrings(): iterable
161
139
'checks ' => NoSuspiciousCharacters::CHECK_HIDDEN_OVERLAY ,
162
140
],
163
141
NoSuspiciousCharacters::HIDDEN_OVERLAY_ERROR ,
164
- 'Hidden overlay check failed . ' ,
142
+ 'Using hidden overlay characters is not allowed . ' ,
165
143
];
166
144
}
167
145
168
146
public function testConstants ()
169
147
{
170
148
$ this ->assertSame (\Spoofchecker::INVISIBLE , NoSuspiciousCharacters::CHECK_INVISIBLE );
171
- $ this ->assertSame (\Spoofchecker::CHAR_LIMIT , NoSuspiciousCharacters::CHECK_CHAR_LIMIT );
172
149
173
150
$ this ->assertSame (\Spoofchecker::ASCII , NoSuspiciousCharacters::RESTRICTION_LEVEL_ASCII );
174
151
$ this ->assertSame (\Spoofchecker::SINGLE_SCRIPT_RESTRICTIVE , NoSuspiciousCharacters::RESTRICTION_LEVEL_SINGLE_SCRIPT );
0 commit comments