1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
class phpbb_text_processing_decode_message_test extends phpbb_test_case
{
public function setUp()
{
parent::setUp();
global $phpbb_dispatcher;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
}
/**
* @dataProvider get_legacy_tests
*/
public function test_legacy($original, $expected, $bbcode_uid = '')
{
$actual = $original;
decode_message($actual, $bbcode_uid);
$this->assertSame($expected, $actual);
}
public function get_legacy_tests()
{
return array(
array(
"&<>"'",
"&<>"'"
),
array(
'<!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) -->',
':)'
),
array(
'<!-- w --><a class="postlink" href="http://www.phpbb.com">www.phpbb.com</a><!-- w -->',
'http://www.phpbb.com'
),
array(
'<!-- m --><a class="postlink" href="http://www.phpbb.com">http://www.phpbb.com</a><!-- m -->',
'http://www.phpbb.com'
),
array(
'<!-- m --><a class="postlink" href="http://www.phpbb.com">this is just text</a><!-- m -->',
'http://www.phpbb.com'
),
array(
'<!-- m --><a class="postlink" href="http://www.phpbb.com/some/more/link/that/is/shortened">http://www.phpbb.com/some/ ... /shortened</a><!-- m -->',
'http://www.phpbb.com/some/more/link/that/is/shortened'
),
/**
* Fails as per PHPBB3-8420
* @link http://tracker.phpbb.com/browse/PHPBB3-8420
*
array(
'[url=http://example.com:2cpxwbdy]<!-- s:arrow: --><img src="{SMILIES_PATH}/icon_arrow.gif" alt=":arrow:" title="Arrow" /><!-- s:arrow: --> here[/url:2cpxwbdy]',
'[url=http://example.com] :arrow: here[/url]',
'2cpxwbdy'
),
*/
);
}
/**
* @dataProvider get_text_formatter_tests
*/
public function test_text_formatter($original, $expected)
{
$this->get_test_case_helpers()->set_s9e_services();
$actual = $original;
decode_message($actual);
$this->assertSame($expected, $actual);
}
public function get_text_formatter_tests()
{
return array(
array(
"<t>&<>\"'",
"&<>"'"
),
array(
'<r><E>:)</E></r>',
':)'
),
array(
"<t>a<br/>\nb</t>",
"a\nb"
),
/**
* @link http://tracker.phpbb.com/browse/PHPBB3-8420
*/
array(
'<r><URL url="http://example.com"><s>[url=http://example.com]</s> <E>:arrow:</E> here<e>[/url]</e></URL></r>',
'[url=http://example.com] :arrow: here[/url]'
),
);
}
}
|