Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
64.71% |
11 / 17 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_functions_content_phpbb_format_quote_test | |
64.71% |
11 / 17 |
|
66.67% |
2 / 3 |
3.40 | |
0.00% |
0 / 1 |
| setUp | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
| data_phpbb_format_quote | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| test_phpbb_format_quote | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | require_once __DIR__ . '/../../phpBB/includes/message_parser.php'; |
| 15 | |
| 16 | class phpbb_functions_content_phpbb_format_quote_test extends phpbb_test_case |
| 17 | { |
| 18 | /** @var \phpbb\language\language */ |
| 19 | protected $lang; |
| 20 | |
| 21 | protected function setUp(): void |
| 22 | { |
| 23 | global $cache, $user, $phpbb_root_path, $phpEx; |
| 24 | |
| 25 | $lang_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); |
| 26 | $this->lang = new \phpbb\language\language($lang_file_loader); |
| 27 | $user = new \phpbb\user($this->lang, '\phpbb\datetime'); |
| 28 | $user->data['user_options'] = 230271; |
| 29 | $cache = new phpbb_mock_cache(); |
| 30 | |
| 31 | parent::setUp(); |
| 32 | } |
| 33 | |
| 34 | public static function data_phpbb_format_quote() |
| 35 | { |
| 36 | return [ |
| 37 | [true, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', '', "[quote=admin user_id=2][quote="username"]quoted[/quote][/quote]\n\n"], |
| 38 | [false, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', '', "admin wrote:\n> [quote="username"]quoted[/quote]\n"], |
| 39 | [true, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', "[url=http://viewtopic.php?p=1#p1]Subject: Foo[/url]\n\n", "[url=http://viewtopic.php?p=1#p1]Subject: Foo[/url]\n\n[quote=admin user_id=2][quote="username"]quoted[/quote][/quote]\n\n"], |
| 40 | [false, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', "http://viewtopic.php?p=1#p1 - Subject: Foo\n\n", "http://viewtopic.php?p=1#p1 - Subject: Foo\n\nadmin wrote:\n> [quote="username"]quoted[/quote]\n"], |
| 41 | ]; |
| 42 | } |
| 43 | |
| 44 | |
| 45 | /** |
| 46 | * @dataProvider data_phpbb_format_quote |
| 47 | */ |
| 48 | public function test_phpbb_format_quote($bbcode_status, $quote_attributes, $message, $message_link, $expected) |
| 49 | { |
| 50 | $text_formatter_utils = new \phpbb\textformatter\s9e\utils(); |
| 51 | |
| 52 | $message_parser = new parse_message($message); |
| 53 | |
| 54 | phpbb_format_quote($this->lang, $message_parser, $text_formatter_utils, $bbcode_status, $quote_attributes, $message_link); |
| 55 | |
| 56 | $this->assertEquals($expected, $message_parser->message); |
| 57 | } |
| 58 | } |