@@ -40,49 +40,100 @@ public function testNonSuspiciousStrings()
40
40
/**
41
41
* @dataProvider provideSuspiciousStrings
42
42
*/
43
- public function testSuspiciousStrings (string $ string , array $ options )
43
+ public function testSuspiciousStrings (string $ string , array $ options, string $ errorCode , string $ errorMessage )
44
44
{
45
- $ this ->validator ->validate ($ string , new NoSuspiciousCharacters ([ ' message ' => ' myMessage ' ] + $ options ));
45
+ $ this ->validator ->validate ($ string , new NoSuspiciousCharacters ($ options ));
46
46
47
- $ this ->buildViolation ('myMessage ' )
47
+ $ this ->buildViolation ($ errorMessage )
48
+ ->setCode ($ errorCode )
48
49
->setParameter ('{{ value }} ' , '" ' .$ string .'" ' )
49
50
->assertRaised ();
50
51
}
51
52
52
53
public static function provideSuspiciousStrings (): iterable
53
54
{
54
- yield 'Fails restriction level check because of character outside ASCII range ' => ['à ' ,
55
+ yield 'Fails restriction level check because of character outside ASCII range ' => [
56
+ 'à ' ,
55
57
['restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_ASCII ],
58
+ NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
59
+ 'Restriction level check failed. ' ,
60
+ ];
61
+
62
+ yield 'Fails restriction level check because of mixed-script string ' => [
63
+ 'àㄚ ' ,
64
+ [
65
+ 'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_SINGLE_SCRIPT ,
66
+ 'profileLocales ' => ['zh_Hant_TW ' ],
67
+ ],
68
+ NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
69
+ 'Restriction level check failed. ' ,
70
+ ];
71
+
72
+ yield 'Fails restriction level check because of disallowed Armenian script ' => [
73
+ 'àԱ ' ,
74
+ [
75
+ 'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_HIGH ,
76
+ 'profileLocales ' => ['hy_AM ' ],
77
+ ],
78
+ NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
79
+ 'Restriction level check failed. ' ,
80
+ ];
81
+
82
+ yield 'Fails restriction level check because of disallowed Greek script ' => [
83
+ 'àπ ' ,
84
+ [
85
+ 'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_MODERATE ,
86
+ 'profileLocales ' => ['el_GR ' ],
87
+ ],
88
+ NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
89
+ 'Restriction level check failed. ' ,
90
+ ];
91
+
92
+ yield 'Fails restriction level check because of Greek script absent from profile ' => [
93
+ 'àπ ' ,
94
+ [
95
+ 'checks ' => NoSuspiciousCharacters::CHECK_RESTRICTION_LEVEL ,
96
+ 'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_MINIMAL ,
97
+ ],
98
+ NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
99
+ 'Restriction level check failed. ' ,
100
+ ];
101
+
102
+ yield 'Fails INVISIBLE check because of duplicated non-spacing mark ' => [
103
+ 'à̀ ' ,
104
+ [
105
+ 'checks ' => NoSuspiciousCharacters::CHECK_INVISIBLE ,
106
+ ],
107
+ NoSuspiciousCharacters::INVISIBLE_ERROR ,
108
+ 'Invisible check failed. ' ,
109
+ ];
110
+
111
+ yield 'Fails CHAR_LIMIT check because of Greek script absent from profile ' => [
112
+ 'àπ ' ,
113
+ [
114
+ 'checks ' => NoSuspiciousCharacters::CHECK_CHAR_LIMIT ,
115
+ ],
116
+ NoSuspiciousCharacters::CHAR_LIMIT_ERROR ,
117
+ 'Char limit check failed. ' ,
118
+ ];
119
+
120
+ yield 'Fails MIXED_NUMBERS check because of different numbering systems ' => [
121
+ '8৪ ' ,
122
+ [
123
+ 'checks ' => NoSuspiciousCharacters::CHECK_MIXED_NUMBERS ,
124
+ ],
125
+ NoSuspiciousCharacters::MIXED_NUMBERS_ERROR ,
126
+ 'Mixed numbers check failed. ' ,
127
+ ];
128
+
129
+ yield 'Fails HIDDEN_OVERLAY check because of hidden combining character ' => [
130
+ 'i̇ ' ,
131
+ [
132
+ 'checks ' => NoSuspiciousCharacters::CHECK_HIDDEN_OVERLAY ,
133
+ ],
134
+ NoSuspiciousCharacters::HIDDEN_OVERLAY_ERROR ,
135
+ 'Hidden overlay check failed. ' ,
56
136
];
57
- yield 'Fails restriction level check because of mixed-script string ' => ['àㄚ ' , [
58
- 'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_SINGLE_SCRIPT ,
59
- 'profileLocales ' => ['zh_Hant_TW ' ],
60
- ]];
61
- yield 'Fails restriction level check because of disallowed Armenian script ' => ['àԱ ' , [
62
- 'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_HIGH ,
63
- 'profileLocales ' => ['hy_AM ' ],
64
- ]];
65
- yield 'Fails restriction level check because of disallowed Greek script ' => ['àπ ' , [
66
- 'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_MODERATE ,
67
- 'profileLocales ' => ['el_GR ' ],
68
- ]];
69
- yield 'Fails restriction level check because of Greek script absent from profile ' => ['àπ ' , [
70
- 'checks ' => NoSuspiciousCharacters::CHECK_RESTRICTION_LEVEL ,
71
- 'restrictionLevel ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_MINIMAL ,
72
- ]];
73
-
74
- yield 'Fails INVISIBLE check because of duplicated non-spacing mark ' => ['à̀ ' , [
75
- 'checks ' => NoSuspiciousCharacters::CHECK_INVISIBLE ,
76
- ]];
77
- yield 'Fails CHAR_LIMIT check because of Greek script absent from profile ' => ['àπ ' , [
78
- 'checks ' => NoSuspiciousCharacters::CHECK_CHAR_LIMIT ,
79
- ]];
80
- yield 'Fails MIXED_NUMBERS check because of different numbering systems ' => ['8৪ ' , [
81
- 'checks ' => NoSuspiciousCharacters::CHECK_MIXED_NUMBERS ,
82
- ]];
83
- yield 'Fails HIDDEN_OVERLAY check because of hidden combining character ' => ['i̇ ' , [
84
- 'checks ' => NoSuspiciousCharacters::CHECK_HIDDEN_OVERLAY ,
85
- ]];
86
137
}
87
138
88
139
public function testConstants ()
0 commit comments