@@ -14,7 +14,7 @@ public function setUp(): void
14
14
{
15
15
parent ::setUp ();
16
16
17
- Config::set ('blasp.profanities ' , ['fucking ' , 'shit ' , 'cunt ' , 'fuck ' ]);
17
+ Config::set ('blasp.profanities ' , ['fucking ' , 'shit ' , 'cunt ' , 'fuck ' , ' penis ' , ' cock ' , ' twat ' , ' ass ' , ' dick ' , ' sex ' , ' butt ' , ' arse ' , ' lick ' , ' anal ' , ' clusterfuck ' , ' bullshit ' , ' fucked ' , ' damn ' , ' crap ' , ' hell ' ]);
18
18
Config::set ('blasp.separators ' , [' ' , '- ' , '_ ' ]);
19
19
Config::set ('blasp.substitutions ' , [
20
20
'/a/ ' => ['a ' , '4 ' , '@ ' , 'Á ' , 'á ' , 'À ' , 'Â ' , 'à ' , 'Â ' , 'â ' , 'Ä ' , 'ä ' , 'Ã ' , 'ã ' , 'Å ' , 'å ' , 'æ ' , 'Æ ' , 'α ' , 'Δ ' , 'Λ ' , 'λ ' ],
@@ -116,6 +116,18 @@ public function test_combination_match()
116
116
$ this ->assertSame ('This is a ********* sentence ' , $ result ->cleanString );
117
117
}
118
118
119
+ public function test_multiple_profanities_no_spaces ()
120
+ {
121
+ $ blaspService = new BlaspService ();
122
+
123
+ $ result = $ blaspService ->check ('cuntfuck shit ' );
124
+
125
+ $ this ->assertTrue ($ result ->hasProfanity );
126
+ $ this ->assertSame (3 , $ result ->profanitiesCount );
127
+ $ this ->assertCount (3 , $ result ->uniqueProfanitiesFound );
128
+ $ this ->assertSame ('******** **** ' , $ result ->cleanString );
129
+ }
130
+
119
131
public function test_multiple_profanities ()
120
132
{
121
133
$ blaspService = new BlaspService ();
@@ -128,4 +140,117 @@ public function test_multiple_profanities()
128
140
$ this ->assertSame ('This is a ********* sentence you ******* ****! ' , $ result ->cleanString );
129
141
}
130
142
143
+ public function test_scunthorpe_problem ()
144
+ {
145
+ $ blaspService = new BlaspService ();
146
+
147
+ $ result = $ blaspService ->check ('I live in a town called Scunthorpe ' );
148
+
149
+ $ this ->assertTrue (!$ result ->hasProfanity );
150
+ $ this ->assertSame (0 , $ result ->profanitiesCount );
151
+ $ this ->assertCount (0 , $ result ->uniqueProfanitiesFound );
152
+ $ this ->assertSame ('I live in a town called Scunthorpe ' , $ result ->cleanString );
153
+ }
154
+
155
+ public function test_penistone_problem ()
156
+ {
157
+ $ blaspService = new BlaspService ();
158
+
159
+ $ result = $ blaspService ->check ('I live in a town called Penistone ' );
160
+
161
+ $ this ->assertTrue (!$ result ->hasProfanity );
162
+ $ this ->assertSame (0 , $ result ->profanitiesCount );
163
+ $ this ->assertCount (0 , $ result ->uniqueProfanitiesFound );
164
+ $ this ->assertSame ('I live in a town called Penistone ' , $ result ->cleanString );
165
+ }
166
+
167
+ public function test_false_positives ()
168
+ {
169
+ $ words = [
170
+ 'Scunthorpe ' ,
171
+ 'Cockburn ' ,
172
+ 'Penistone ' ,
173
+ 'Lightwater ' ,
174
+ 'Assume ' ,
175
+ 'bass ' ,
176
+ 'class ' ,
177
+ 'Compass ' ,
178
+ 'Pass ' ,
179
+ 'Dickinson ' ,
180
+ 'Middlesex ' ,
181
+ 'Cockerel ' ,
182
+ 'Butterscotch ' ,
183
+ 'Blackcock ' ,
184
+ 'Countryside ' ,
185
+ 'Arsenal ' ,
186
+ 'Flick ' ,
187
+ 'Flicker ' ,
188
+ 'Analyst ' ,
189
+ 'blackCocktail ' ,
190
+ ];
191
+
192
+ foreach ($ words as $ word ) {
193
+
194
+ $ blaspService = new BlaspService ();
195
+
196
+ $ result = $ blaspService ->check ($ word );
197
+
198
+ $ this ->assertTrue (!$ result ->hasProfanity );
199
+ $ this ->assertSame (0 , $ result ->profanitiesCount );
200
+ $ this ->assertCount (0 , $ result ->uniqueProfanitiesFound );
201
+ $ this ->assertSame ($ word , $ result ->cleanString );
202
+ }
203
+ }
204
+
205
+ public function test_cuntfuck_fuckcunt ()
206
+ {
207
+ $ blaspService = new BlaspService ();
208
+
209
+ $ result = $ blaspService ->check ('cuntfuck fuckcunt ' );
210
+
211
+ $ this ->assertTrue ($ result ->hasProfanity );
212
+ $ this ->assertSame (4 , $ result ->profanitiesCount );
213
+ $ this ->assertCount (2 , $ result ->uniqueProfanitiesFound );
214
+ $ this ->assertSame ('******** ******** ' , $ result ->cleanString );
215
+ }
216
+
217
+ public function test_fucking_shit_cunt_fuck ()
218
+ {
219
+ $ blaspService = new BlaspService ();
220
+
221
+ $ result = $ blaspService ->check ('fuckingshitcuntfuck ' );
222
+
223
+ $ this ->assertTrue ($ result ->hasProfanity );
224
+ $ this ->assertSame (4 , $ result ->profanitiesCount );
225
+ $ this ->assertCount (4 , $ result ->uniqueProfanitiesFound );
226
+ $ this ->assertSame ('******************* ' , $ result ->cleanString );
227
+ }
228
+
229
+ public function test_billy_butcher ()
230
+ {
231
+ $ blaspService = new BlaspService ();
232
+
233
+ $ result = $ blaspService ->check ('oi! cunt! ' );
234
+
235
+ $ this ->assertTrue ($ result ->hasProfanity );
236
+ $ this ->assertSame (1 , $ result ->profanitiesCount );
237
+ $ this ->assertCount (1 , $ result ->uniqueProfanitiesFound );
238
+ $ this ->assertSame ('oi! ****! ' , $ result ->cleanString );
239
+ }
240
+
241
+ public function test_paragraph ()
242
+ {
243
+ $ blaspService = new BlaspService ();
244
+
245
+ $ paragraph = "This damn project is such a pain in the ass. I can't believe I have to deal with this bullshit every single day. It's like everything is completely fucked up, and nobody gives a shit. Sometimes I just want to scream, 'What the hell is going on?' Honestly, it's a total clusterfuck, and I'm so fucking done with this crap. " ;
246
+
247
+ $ result = $ blaspService ->check ($ paragraph );
248
+
249
+ $ expectedOutcome = "This **** project is such a pain in the ***. I can't believe I have to deal with this ******** every single day. It's like everything is completely ****** up, and nobody gives a ****. Sometimes I just want to scream, 'What the **** is going on?' Honestly, it's a total ***********, and I'm so ******* done with this ****. " ;
250
+
251
+ $ this ->assertTrue ($ result ->hasProfanity );
252
+ $ this ->assertSame (9 , $ result ->profanitiesCount );
253
+ $ this ->assertCount (9 , $ result ->uniqueProfanitiesFound );
254
+ $ this ->assertSame ($ expectedOutcome , $ result ->cleanString );
255
+ }
131
256
}
0 commit comments