diff options
author | Maat <maat-pub@mageia.biz> | 2020-05-09 01:15:08 +0200 |
---|---|---|
committer | Maat <maat-pub@mageia.biz> | 2020-05-09 01:15:08 +0200 |
commit | 6985226b17e8a0ef0a720bf1d12fe0c216e13dab (patch) | |
tree | 116d2565ac02c40abe0548863c6badf8ec3e1d1e /tests/text_formatter/s9e/acp_utils_test.php | |
parent | 8ea437e30605e0f66b5220bf904a61d7c1d11ddd (diff) | |
parent | 8d00784dfe2c8bcb10843ff70b4cfa998d703285 (diff) | |
download | forums-6985226b17e8a0ef0a720bf1d12fe0c216e13dab.tar forums-6985226b17e8a0ef0a720bf1d12fe0c216e13dab.tar.gz forums-6985226b17e8a0ef0a720bf1d12fe0c216e13dab.tar.bz2 forums-6985226b17e8a0ef0a720bf1d12fe0c216e13dab.tar.xz forums-6985226b17e8a0ef0a720bf1d12fe0c216e13dab.zip |
Diffstat (limited to 'tests/text_formatter/s9e/acp_utils_test.php')
-rw-r--r-- | tests/text_formatter/s9e/acp_utils_test.php | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/text_formatter/s9e/acp_utils_test.php b/tests/text_formatter/s9e/acp_utils_test.php new file mode 100644 index 0000000000..9d84924042 --- /dev/null +++ b/tests/text_formatter/s9e/acp_utils_test.php @@ -0,0 +1,79 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +class phpbb_textformatter_s9e_acp_utils_test extends phpbb_test_case +{ + /** + * @dataProvider get_analyse_bbcode_tests + */ + public function test_analyse_bbcode($definition, $template, $expected) + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $factory = $container->get('text_formatter.s9e.factory'); + $acp_utils = new \phpbb\textformatter\s9e\acp_utils($factory); + $actual = $acp_utils->analyse_bbcode($definition, $template); + + $this->assertEquals($expected, $actual); + } + + public function get_analyse_bbcode_tests() + { + return [ + [ + '[x]{TEXT}[/x]', + '<b>{TEXT}</b>', + [ + 'status' => 'safe', + 'name' => 'X' + ] + ], + [ + '[hr]', + '<hr>', + [ + 'status' => 'safe', + 'name' => 'HR' + ] + ], + [ + '[x]{TEXT}[/x]', + '<script>{TEXT}</script>', + [ + 'status' => 'unsafe', + 'name' => 'X', + 'error_text' => 'Cannot allow unfiltered data in this context', + 'error_html' => '<script> + <span class="highlight"><xsl:apply-templates/></span> +</script>' + ] + ], + [ + '???', + '<hr>', + [ + 'status' => 'invalid_definition', + 'error_text' => 'Cannot interpret the BBCode definition' + ] + ], + [ + '[x]{TEXT}[/x]', + '<xsl:invalid', + [ + 'status' => 'invalid_template', + 'name' => 'X', + 'error_text' => "Invalid XSL: Couldn't find end of Start Tag invalid line 1\n" + ] + ], + ]; + } +} |