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_processing/generate_text_for_storage_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_processing/generate_text_for_storage_test.php')
-rw-r--r-- | tests/text_processing/generate_text_for_storage_test.php | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/text_processing/generate_text_for_storage_test.php b/tests/text_processing/generate_text_for_storage_test.php new file mode 100644 index 0000000000..0bacaacfb8 --- /dev/null +++ b/tests/text_processing/generate_text_for_storage_test.php @@ -0,0 +1,70 @@ +<?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'; +require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; +require_once __DIR__ . '/../mock/container_builder.php'; + +class phpbb_text_processing_generate_text_for_storage_test extends phpbb_test_case +{ + public function setUp() + { + global $config, $phpbb_container, $phpbb_dispatcher; + + parent::setUp(); + + $config = new \phpbb\config\config(array()); + set_config(null, null, null, $config); + + $phpbb_container = new phpbb_mock_container_builder; + $phpbb_container->set('config', $config); + $this->get_test_case_helpers()->set_s9e_services($phpbb_container); + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher; + } + + /** + * @dataProvider get_text_formatter_tests + */ + public function test_text_formatter($original, $expected, $allow_bbcode = true, $allow_urls = true, $allow_smilies = true, $setup = null) + { + $actual = $original; + $uid = ''; + $bitfield = ''; + $flags = 0; + + if (isset($setup)) + { + $setup(); + } + + generate_text_for_storage($actual, $uid, $bitfield, $flags, $allow_bbcode, $allow_urls, $allow_smilies); + + $this->assertSame($expected, $actual); + } + + public function get_text_formatter_tests() + { + return array( + array( + 'Hello world', + '<t>Hello world</t>' + ), + array( + 'Hello [url=http://example.org]world[/url] :)', + '<r>Hello <URL url="http://example.org"><s>[url=http://example.org]</s>world<e>[/url]</e></URL> <E>:)</E></r>' + ), + array( + '&<>"\'', + '<t>&<>"\'</t>' + ), + ); + } +} |