* @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_text_processing_generate_text_for_storage_test extends phpbb_test_case
{
public function setUp(): void
{
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, $allow_urls, $allow_smilies, $allow_img_bbcode, $allow_flash_bbcode, $allow_quote_bbcode, $allow_url_bbcode, $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, $allow_img_bbcode, $allow_flash_bbcode, $allow_quote_bbcode, $allow_url_bbcode);
$this->assertSame($expected, $actual);
}
public function get_text_formatter_tests()
{
return array(
array(
'Hello world',
'Hello world',
true,
true,
true,
true,
true,
true,
true,
),
array(
'Hello [url=http://example.org]world[/url] :)',
'Hello [url=http://example.org]world[/url] :)',
true,
true,
true,
true,
true,
true,
true,
),
array(
'&<>"\'',
'&<>"\'',
true,
true,
true,
true,
true,
true,
true,
),
array(
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
false,
false,
false,
false,
false,
false,
false,
),
array(
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
true,
false,
false,
false,
false,
false,
false,
),
array(
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
false,
true,
false,
false,
false,
false,
true,
),
array(
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
false,
false,
true,
false,
false,
false,
false,
),
array(
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
true,
false,
false,
true,
false,
false,
false,
),
array(
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
true,
false,
false,
false,
true,
false,
false,
),
array(
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote]
[url]http://example.org[/url]',
true,
false,
false,
false,
false,
true,
false,
),
array(
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
'[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
true,
false,
false,
false,
false,
false,
true,
),
);
}
}