Skip to content

Commit 20a011a

Browse files
authored
Merge pull request #6579 from ddevsr/text-helper
2 parents 7273b9d + 62cdc54 commit 20a011a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/system/Helpers/TextHelperTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ public function testCharacterLimiter()
160160
public function testAsciiToEntities()
161161
{
162162
$strs = [
163+
'Œ' => 'Œ',
164+
'Âé' => 'Âé',
165+
'Â? ' => 'Â? ',
163166
'“‘ “test” ' => '“‘ “test” ',
164167
'†¥¨ˆøåß∂ƒ©˙∆˚¬' => '†¥¨ˆøåß∂ƒ©˙∆˚¬',
165168
];
@@ -172,6 +175,9 @@ public function testAsciiToEntities()
172175
public function testEntitiesToAscii()
173176
{
174177
$strs = [
178+
'Œ' => 'Œ',
179+
'Âé' => 'Âé',
180+
'Â? ' => 'Â? ',
175181
'“‘ “test” ' => '“‘ “test” ',
176182
'†¥¨ˆøåß∂ƒ©˙∆˚¬' => '†¥¨ˆøåß∂ƒ©˙∆˚¬',
177183
];
@@ -201,12 +207,20 @@ public function testConvertAccentedCharacters()
201207
}
202208

203209
public function testCensoredWords()
210+
{
211+
$this->assertSame('fuck', word_censor('fuck', []));
212+
}
213+
214+
public function testCensoredWordsWithReplacement()
204215
{
205216
$censored = [
206217
'boob',
207218
'nerd',
208219
'ass',
220+
'asshole',
209221
'fart',
222+
'fuck',
223+
'fucking',
210224
];
211225
$strs = [
212226
'Ted bobbled the ball' => 'Ted bobbled the ball',
@@ -222,6 +236,29 @@ public function testCensoredWords()
222236
}
223237
}
224238

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+
225262
public function testHighlightCode()
226263
{
227264
$expect = "<code><span style=\"color: #000000\">\n<span style=\"color: #0000BB\">&lt;?php&nbsp;var_dump</span><span style=\"color: #007700\">(</span><span style=\"color: #0000BB\">\$this</span><span style=\"color: #007700\">);&nbsp;</span><span style=\"color: #0000BB\">?&gt;&nbsp;</span>\n</span>\n</code>";

0 commit comments

Comments
 (0)