/** * Obtain list of naughty words and build preg style replacement arrays for use by the * calling script */ function obtain_word_list() { global $db; if (($censors = $this->get('_word_censors')) === false) { $sql = 'SELECT word, replacement FROM ' . WORDS_TABLE; $result = $db->sql_query($sql); $censors = array(); while ($row = $db->sql_fetchrow($result)) { $censors['match'][] = get_censor_preg_expression($row['word']); $censors['replace'][] = $row['replacement']; } $db->sql_freeresult($result); $this->put('_word_censors', $censors); } return $censors; }
/** * @dataProvider censor_test_data */ public function test_censor_no_unicode($pattern, $subject) { $regex = get_censor_preg_expression($pattern, false); $this->assertRegExp($regex, $subject); }