Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
15.62% |
10 / 64 |
|
60.00% |
3 / 5 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_text_processing_decode_message_test | |
15.62% |
10 / 64 |
|
60.00% |
3 / 5 |
20.02 | |
0.00% |
0 / 1 |
| setUp | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| test_legacy | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| get_legacy_tests | |
0.00% |
0 / 36 |
|
0.00% |
0 / 1 |
2 | |||
| test_text_formatter | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| get_text_formatter_tests | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
2 | |||
| 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 | class phpbb_text_processing_decode_message_test extends phpbb_test_case |
| 15 | { |
| 16 | protected function setUp(): void |
| 17 | { |
| 18 | parent::setUp(); |
| 19 | |
| 20 | global $phpbb_dispatcher; |
| 21 | |
| 22 | $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * @dataProvider get_legacy_tests |
| 27 | */ |
| 28 | public function test_legacy($original, $expected, $bbcode_uid = '') |
| 29 | { |
| 30 | $actual = $original; |
| 31 | decode_message($actual, $bbcode_uid); |
| 32 | |
| 33 | $this->assertSame($expected, $actual); |
| 34 | } |
| 35 | |
| 36 | public static function get_legacy_tests() |
| 37 | { |
| 38 | return array( |
| 39 | array( |
| 40 | "&<>"'", |
| 41 | "&<>"'" |
| 42 | ), |
| 43 | array( |
| 44 | '<!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) -->', |
| 45 | ':)' |
| 46 | ), |
| 47 | array( |
| 48 | '<!-- w --><a class="postlink" href="http://www.phpbb.com">www.phpbb.com</a><!-- w -->', |
| 49 | 'www.phpbb.com' |
| 50 | ), |
| 51 | array( |
| 52 | '<!-- m --><a class="postlink" href="http://www.phpbb.com">http://www.phpbb.com</a><!-- m -->', |
| 53 | 'http://www.phpbb.com' |
| 54 | ), |
| 55 | array( |
| 56 | '<!-- m --><a class="postlink" href="http://www.phpbb.com">this is just text</a><!-- m -->', |
| 57 | 'http://www.phpbb.com' |
| 58 | ), |
| 59 | array( |
| 60 | '<!-- m --><a class="postlink" href="http://www.phpbb.com/some/more/link/that/is/shortened">http://www.phpbb.com/some/ ... /shortened</a><!-- m -->', |
| 61 | 'http://www.phpbb.com/some/more/link/that/is/shortened' |
| 62 | ), |
| 63 | /** |
| 64 | * Fails as per PHPBB3-8420 |
| 65 | * @link http://tracker.phpbb.com/browse/PHPBB3-8420 |
| 66 | * |
| 67 | array( |
| 68 | '[url=http://example.com:2cpxwbdy]<!-- s:arrow: --><img src="{SMILIES_PATH}/icon_arrow.gif" alt=":arrow:" title="Arrow" /><!-- s:arrow: --> here[/url:2cpxwbdy]', |
| 69 | '[url=http://example.com] :arrow: here[/url]', |
| 70 | '2cpxwbdy' |
| 71 | ), |
| 72 | */ |
| 73 | ); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * @dataProvider get_text_formatter_tests |
| 78 | */ |
| 79 | public function test_text_formatter($original, $expected) |
| 80 | { |
| 81 | $this->get_test_case_helpers()->set_s9e_services(); |
| 82 | |
| 83 | $actual = $original; |
| 84 | decode_message($actual); |
| 85 | |
| 86 | $this->assertSame($expected, $actual); |
| 87 | } |
| 88 | |
| 89 | public static function get_text_formatter_tests() |
| 90 | { |
| 91 | return array( |
| 92 | array( |
| 93 | "<t>&<>\"'", |
| 94 | "&<>"'" |
| 95 | ), |
| 96 | array( |
| 97 | '<r><E>:)</E></r>', |
| 98 | ':)' |
| 99 | ), |
| 100 | array( |
| 101 | "<t>a<br/>\nb</t>", |
| 102 | "a\nb" |
| 103 | ), |
| 104 | /** |
| 105 | * @link http://tracker.phpbb.com/browse/PHPBB3-8420 |
| 106 | */ |
| 107 | array( |
| 108 | '<r><URL url="http://example.com"><s>[url=http://example.com]</s> <E>:arrow:</E> here<e>[/url]</e></URL></r>', |
| 109 | '[url=http://example.com] :arrow: here[/url]' |
| 110 | ), |
| 111 | ); |
| 112 | } |
| 113 | } |