@@ -160,6 +160,9 @@ public function testCharacterLimiter()
160
160
public function testAsciiToEntities ()
161
161
{
162
162
$ strs = [
163
+ 'Œ ' => 'Œ ' ,
164
+ 'Âé ' => 'Âé ' ,
165
+ 'Â? ' => 'Â? ' ,
163
166
'“‘ “test” ' => '“‘ “test” ' ,
164
167
'†¥¨ˆøåß∂ƒ©˙∆˚¬ ' => '†¥¨ˆøåß∂ƒ©˙∆˚¬ ' ,
165
168
];
@@ -172,6 +175,9 @@ public function testAsciiToEntities()
172
175
public function testEntitiesToAscii ()
173
176
{
174
177
$ strs = [
178
+ 'Œ ' => 'Œ ' ,
179
+ 'Âé ' => 'Âé ' ,
180
+ 'Â? ' => 'Â? ' ,
175
181
'“‘ “test” ' => '“‘ “test” ' ,
176
182
'†¥¨ˆøåß∂ƒ©˙∆˚¬ ' => '†¥¨ˆøåß∂ƒ©˙∆˚¬ ' ,
177
183
];
@@ -201,12 +207,20 @@ public function testConvertAccentedCharacters()
201
207
}
202
208
203
209
public function testCensoredWords ()
210
+ {
211
+ $ this ->assertSame ('fuck ' , word_censor ('fuck ' , []));
212
+ }
213
+
214
+ public function testCensoredWordsWithReplacement ()
204
215
{
205
216
$ censored = [
206
217
'boob ' ,
207
218
'nerd ' ,
208
219
'ass ' ,
220
+ 'asshole ' ,
209
221
'fart ' ,
222
+ 'fuck ' ,
223
+ 'fucking ' ,
210
224
];
211
225
$ strs = [
212
226
'Ted bobbled the ball ' => 'Ted bobbled the ball ' ,
@@ -222,6 +236,29 @@ public function testCensoredWords()
222
236
}
223
237
}
224
238
239
+ public function testCensoredWordsNonReplacement ()
240
+ {
241
+ $ censored = [
242
+ 'boob ' ,
243
+ 'nerd ' ,
244
+ 'ass ' ,
245
+ 'asshole ' ,
246
+ 'fart ' ,
247
+ 'fuck ' ,
248
+ 'fucking ' ,
249
+ ];
250
+ $ strs = [
251
+ 'How are you today? ' => 'How are you today? ' ,
252
+ 'I am fine, thankyou! ' => 'I am fine, thankyou! ' ,
253
+ 'Are you fucking kidding me? ' => 'Are you ####### kidding me? ' ,
254
+ 'Fucking asshole! ' => '####### #######! ' ,
255
+ ];
256
+
257
+ foreach ($ strs as $ str => $ expected ) {
258
+ $ this ->assertSame ($ expected , word_censor ($ str , $ censored ));
259
+ }
260
+ }
261
+
225
262
public function testHighlightCode ()
226
263
{
227
264
$ expect = "<code><span style= \"color: #000000 \"> \n<span style= \"color: #0000BB \"><?php var_dump</span><span style= \"color: #007700 \">(</span><span style= \"color: #0000BB \"> \$this</span><span style= \"color: #007700 \">); </span><span style= \"color: #0000BB \">?> </span> \n</span> \n</code> " ;
0 commit comments