diff options
| author | s9e <s9e.dev@gmail.com> | 2014-11-22 20:00:58 +0100 |
|---|---|---|
| committer | JoshyPHP <s9e.dev@gmail.com> | 2015-04-02 19:16:01 +0200 |
| commit | 147a713cc066d493b50b82a9d475aa9af940e2b4 (patch) | |
| tree | 602a17f1928dc4a7c94a4d8fb6349cd702422d2b /tests/text_formatter/s9e/utils_test.php | |
| parent | eb7e6d7c23db65530a46dd62432039c19792d564 (diff) | |
| download | forums-147a713cc066d493b50b82a9d475aa9af940e2b4.tar forums-147a713cc066d493b50b82a9d475aa9af940e2b4.tar.gz forums-147a713cc066d493b50b82a9d475aa9af940e2b4.tar.bz2 forums-147a713cc066d493b50b82a9d475aa9af940e2b4.tar.xz forums-147a713cc066d493b50b82a9d475aa9af940e2b4.zip | |
[ticket/11768] This commit integrates s9e\TextFormatter
This commit integrates s9e\TextFormatter as outlined in
http://area51.phpbb.com/phpBB/viewtopic.php?f=108&t=44467
PHPBB3-11768
Diffstat (limited to 'tests/text_formatter/s9e/utils_test.php')
| -rw-r--r-- | tests/text_formatter/s9e/utils_test.php | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php new file mode 100644 index 0000000000..510beba817 --- /dev/null +++ b/tests/text_formatter/s9e/utils_test.php @@ -0,0 +1,157 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +require_once __DIR__ . '/../../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; + +class phpbb_textformatter_s9e_utils_test extends phpbb_test_case +{ + /** + * @dataProvider get_unparse_tests + */ + public function test_unparse($original, $expected) + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $utils = $container->get('text_formatter.utils'); + + $this->assertSame($expected, $utils->unparse($original)); + } + + public function get_unparse_tests() + { + return array( + array( + '<t>Plain text</t>', + 'Plain text' + ), + array( + "<t>Multi<br/>\nline</t>", + "Multi\nline" + ), + array( + '<r><B><s>[b]</s>bold<e>[/b]</e></B></r>', + '[b]bold[/b]' + ) + ); + } + + /** + * @dataProvider get_remove_formatting_tests + */ + public function test_remove_formatting($original, $expected) + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $utils = $container->get('text_formatter.utils'); + + $this->assertSame($expected, $utils->remove_formatting($original)); + } + + public function get_remove_formatting_tests() + { + return array( + array( + '<t>Plain text</t>', + 'Plain text' + ), + array( + "<t>Multi<br/>\nline</t>", + "Multi\nline" + ), + array( + '<r><B><s>[b]</s>bold<e>[/b]</e></B></r>', + 'bold' + ) + ); + } + + /** + * @dataProvider get_clean_formatting_tests + */ + public function test_clean_formatting($original, $expected) + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $utils = $container->get('text_formatter.utils'); + + $this->assertSame($expected, $utils->clean_formatting($original)); + } + + public function get_clean_formatting_tests() + { + return array( + array( + '<t>Plain text</t>', + 'Plain text' + ), + array( + "<t>Multi<br/>\nline</t>", + "Multi\nline" + ), + array( + '<r><B><s>[b]</s>bold<e>[/b]</e></B></r>', + ' bold ' + ) + ); + } + + /** + * @dataProvider get_remove_bbcode_tests + */ + public function test_remove_bbcode($original, $name, $depth, $expected) + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $utils = $container->get('text_formatter.utils'); + + $this->assertSame($expected, $utils->remove_bbcode($original, $name, $depth)); + } + + public function get_remove_bbcode_tests() + { + return array( + array( + '<t>Plain text</t>', + 'b', + 1, + '<t>Plain text</t>' + ), + array( + '<r><QUOTE author="u0"><s>[quote="u0"]</s><QUOTE author="u1"><s>[quote="u1"]</s><QUOTE author="u2"><s>[quote="u2"]</s>q2<e>[/quote]</e></QUOTE> +q1<e>[/quote]</e></QUOTE> +q0<e>[/quote]</e></QUOTE> +<B><s>[b]</s>bold<e>[/b]</e></B></r>', + 'quote', + 0, + '<r> +<B><s>[b]</s>bold<e>[/b]</e></B></r>' + ), + array( + '<r><QUOTE author="u0"><s>[quote="u0"]</s><QUOTE author="u1"><s>[quote="u1"]</s><QUOTE author="u2"><s>[quote="u2"]</s>q2<e>[/quote]</e></QUOTE> +q1<e>[/quote]</e></QUOTE> +q0<e>[/quote]</e></QUOTE> +<B><s>[b]</s>bold<e>[/b]</e></B></r>', + 'quote', + 1, + '<r><QUOTE author="u0"><s>[quote="u0"]</s> +q0<e>[/quote]</e></QUOTE> +<B><s>[b]</s>bold<e>[/b]</e></B></r>' + ), + array( + '<r><QUOTE author="u0"><s>[quote="u0"]</s><QUOTE author="u1"><s>[quote="u1"]</s><QUOTE author="u2"><s>[quote="u2"]</s>q2<e>[/quote]</e></QUOTE> +q1<e>[/quote]</e></QUOTE> +q0<e>[/quote]</e></QUOTE> +<B><s>[b]</s>bold<e>[/b]</e></B></r>', + 'quote', + 2, + '<r><QUOTE author="u0"><s>[quote="u0"]</s><QUOTE author="u1"><s>[quote="u1"]</s> +q1<e>[/quote]</e></QUOTE> +q0<e>[/quote]</e></QUOTE> +<B><s>[b]</s>bold<e>[/b]</e></B></r>' + ), + ); + } +} |
