mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
This commit integrates s9e\TextFormatter as outlined in http://area51.phpbb.com/phpBB/viewtopic.php?f=108&t=44467 PHPBB3-11768
90 lines
2.1 KiB
PHP
90 lines
2.1 KiB
PHP
<?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__ . '/../mock/user.php';
|
|
require_once __DIR__ . '/../mock/cache.php';
|
|
|
|
class phpbb_text_processing_generate_text_for_edit_test extends phpbb_test_case
|
|
{
|
|
/**
|
|
* @dataProvider get_legacy_tests
|
|
*/
|
|
public function test_legacy($original, $expected, $uid = '', $flags = 0)
|
|
{
|
|
global $cache, $user, $phpbb_dispatcher;
|
|
|
|
$cache = new phpbb_mock_cache;
|
|
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
|
|
|
|
$user = new phpbb_mock_user;
|
|
$user->optionset('viewcensors', false);
|
|
|
|
$return = generate_text_for_edit($original, $uid, $flags);
|
|
|
|
$this->assertSame($expected, $return['text']);
|
|
}
|
|
|
|
public function get_legacy_tests()
|
|
{
|
|
return array(
|
|
array(
|
|
'',
|
|
''
|
|
),
|
|
array(
|
|
'0',
|
|
'0'
|
|
),
|
|
array(
|
|
'Hello [url=http://example.org:1f4coh9x]world[/url:1f4coh9x] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) -->',
|
|
'Hello [url=http://example.org]world[/url] :)',
|
|
'1f4coh9x',
|
|
0
|
|
),
|
|
array(
|
|
"&<>"'",
|
|
"&<>"'"
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @dataProvider get_text_formatter_tests
|
|
*/
|
|
public function test_text_formatter($original, $expected)
|
|
{
|
|
global $phpbb_dispatcher;
|
|
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
|
|
$this->get_test_case_helpers()->set_s9e_services();
|
|
|
|
$return = generate_text_for_edit($original, '', 0);
|
|
|
|
$this->assertSame($expected, $return['text']);
|
|
}
|
|
|
|
public function get_text_formatter_tests()
|
|
{
|
|
return array(
|
|
array(
|
|
'<t>Plain text</t>',
|
|
'Plain text'
|
|
),
|
|
array(
|
|
'<r>Hello <URL url="http://example.org"><s>[url=http://example.org]</s>world<e>[/url]</e></URL> <E>:)</E></r>',
|
|
'Hello [url=http://example.org]world[/url] :)'
|
|
),
|
|
array(
|
|
'<t>&<>"\'</t>',
|
|
"&<>"'"
|
|
)
|
|
);
|
|
}
|
|
}
|