diff options
Diffstat (limited to 'tests/text_processing')
7 files changed, 64 insertions, 4 deletions
diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index 9c7152a008..86bc803c98 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -29,7 +29,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca */ public function test_legacy($original, $expected, $uid = '', $bitfield = '', $flags = 0, $censor_text = true) { - global $cache, $user; + global $auth, $cache, $config, $user; global $phpbb_root_path, $phpEx; @@ -63,7 +63,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca public function test_censor_is_restored() { - global $phpbb_container; + global $auth, $user, $config, $phpbb_container; $phpbb_container = new phpbb_mock_container_builder; @@ -72,7 +72,8 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\phpbb\datetime'); - $user->optionset('viewcensors', false); + // Do not ignore word censoring by user (switch censoring on in UCP) + $user->optionset('viewcensors', true); $config = new \phpbb\config\config(array('allow_nocensors' => true)); @@ -102,6 +103,14 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca $this->assertSame('apple', $renderer->render($original)); $this->assertSame('banana', generate_text_for_display($original, '', '', 0, true)); $this->assertSame('apple', $renderer->render($original), 'The original setting was not restored'); + + // Test user option switch to ignore censoring + $renderer->set_viewcensors(true); + // 1st: censoring is still on in UCP + $this->assertSame('banana', generate_text_for_display($original, '', '', 0, true)); + // 2nd: switch censoring off in UCP + $user->optionset('viewcensors', false); + $this->assertSame('apple', generate_text_for_display($original, '', '', 0, true)); } /** @@ -109,7 +118,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca */ public function test_text_formatter($original, $expected, $censor_text = true, $setup = null) { - global $phpbb_container; + global $auth, $user, $config, $phpbb_container; $phpbb_container = new phpbb_mock_container_builder; diff --git a/tests/text_processing/tickets_data/PHPBB3-15261.html b/tests/text_processing/tickets_data/PHPBB3-15261.html new file mode 100644 index 0000000000..b563052b47 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15261.html @@ -0,0 +1 @@ +foo **** baz
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15261.txt b/tests/text_processing/tickets_data/PHPBB3-15261.txt new file mode 100644 index 0000000000..a8c4a05c10 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15261.txt @@ -0,0 +1 @@ +foo <bar> baz
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15261.xml b/tests/text_processing/tickets_data/PHPBB3-15261.xml new file mode 100644 index 0000000000..c0d0f395a1 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15261.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_words"> + <column>word_id</column> + <column>word</column> + <column>replacement</column> + + <row> + <value>1</value> + <value><*></value> + <value>****</value> + </row> + </table> +</dataset> diff --git a/tests/text_processing/tickets_data/PHPBB3-15348.html b/tests/text_processing/tickets_data/PHPBB3-15348.html new file mode 100644 index 0000000000..e65925ec28 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15348.html @@ -0,0 +1 @@ +<img class="smilies" src="phpBB/images/smilies/icon_e_surprised.gif" width="15" height="17" alt=":o" title="First half of :ok:"> <img class="smilies" src="phpBB/images/smilies/icon_lol.gif" width="15" height="17" alt="k:" title="Second half of :ok:"> <img alt=":ok:" class="emoji smilies" draggable="false" src="//cdn.jsdelivr.net/emojione/assets/svg/1f197.svg">
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15348.txt b/tests/text_processing/tickets_data/PHPBB3-15348.txt new file mode 100644 index 0000000000..d6b971702c --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15348.txt @@ -0,0 +1 @@ +:o k: :ok:
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15348.xml b/tests/text_processing/tickets_data/PHPBB3-15348.xml new file mode 100644 index 0000000000..0c88c8824f --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15348.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_smilies"> + <column>smiley_id</column> + <column>code</column> + <column>emotion</column> + <column>smiley_url</column> + <column>smiley_width</column> + <column>smiley_height</column> + <column>smiley_order</column> + <column>display_on_posting</column> + <row> + <value>13</value> + <value>:o</value> + <value>First half of :ok:</value> + <value>icon_e_surprised.gif</value> + <value>15</value> + <value>17</value> + <value>14</value> + <value>1</value> + </row> + <row> + <value>99</value> + <value>k:</value> + <value>Second half of :ok:</value> + <value>icon_lol.gif</value> + <value>15</value> + <value>17</value> + <value>22</value> + <value>1</value> + </row> + </table> +</dataset> |