From fa5c7f6440282891dba1142920157971b90b5ad1 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Mon, 22 Aug 2011 15:35:47 +0100 Subject: [PATCH] [ticket/10240] Added censor_text tests. PHPBB-10240 --- tests/mock/cache.php | 22 +++++++ tests/mock_user.php | 12 ++++ tests/text_processing/censor_text_test.php | 73 ++++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 tests/text_processing/censor_text_test.php diff --git a/tests/mock/cache.php b/tests/mock/cache.php index 11e525ff79..020574b0bb 100644 --- a/tests/mock/cache.php +++ b/tests/mock/cache.php @@ -41,6 +41,28 @@ class phpbb_mock_cache { return $this->data['_bots']; } + + /** + * Obtain list of word censors. We don't need to parse them here, + * that is tested elsewhere. + */ + public function obtain_word_list() + { + return array( + 'match' => array( + '#(? array( + 'replacement1', + 'replacement2', + 'replacement3', + 'replacement4', + ), + ); + } public function set_bots($bots) { diff --git a/tests/mock_user.php b/tests/mock_user.php index 74d31c4c4a..a6ff5f6628 100644 --- a/tests/mock_user.php +++ b/tests/mock_user.php @@ -17,4 +17,16 @@ class phpbb_mock_user { public $host = "testhost"; public $page = array('root_script_path' => '/'); + + public function optionget($item) + { + switch ($item) + { + case 'viewcensors': + return false; + + default: + trigger_error('Option not found, add it to the mock user object.'); + } + } } diff --git a/tests/text_processing/censor_text_test.php b/tests/text_processing/censor_text_test.php new file mode 100644 index 0000000000..3820a1135f --- /dev/null +++ b/tests/text_processing/censor_text_test.php @@ -0,0 +1,73 @@ +assertEquals(censor_text($input), $expected, $label); + } +}