FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
phpbb/tests/bbcode/parser_test.php at develop · Pico/phpbb · GitHub
Pico
/
phpbb
Public
forked from
phpbb/phpbb
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
phpbb
/
tests
/
bbcode
/
parser_test.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
269 lines (259 loc) · 8.45 KB
Breadcrumbs
phpbb
/
tests
/
bbcode
/
parser_test.php
Copy path
File metadata and controls
269 lines (259 loc) · 8.45 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<?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
'
;
require_once
dirname
(
__FILE__
) .
'
/../../phpBB/includes/bbcode.php
'
;
require_once
dirname
(
__FILE__
) .
'
/../../phpBB/includes/message_parser.php
'
;
class
phpbb_bbcode_parser_test
extends
\phpbb_test_case
{
public
function
bbcode_firstpass_data
()
{
return
array
(
// Default bbcodes from in their simplest way
array
(
'
Test default bbcodes: simple bold
'
,
'
[b]bold[/b]
'
,
'
[b:]bold[/b:]
'
,
),
array
(
'
Test default bbcodes: simple underlined
'
,
'
[u]underlined[/u]
'
,
'
[u:]underlined[/u:]
'
,
),
array
(
'
Test default bbcodes: simple italic
'
,
'
[i]italic[/i]
'
,
'
[i:]italic[/i:]
'
,
),
array
(
'
Test default bbcodes: simple color rgb
'
,
'
[color=#FF0000]colored[/color]
'
,
'
[color=#FF0000:]colored[/color:]
'
,
),
array
(
'
Test default bbcodes: simple color name
'
,
'
[color=red]colored[/color]
'
,
'
[color=red:]colored[/color:]
'
,
),
array
(
'
Test default bbcodes: simple size
'
,
'
[size=75]smaller[/size]
'
,
'
[size=75:]smaller[/size:]
'
,
),
array
(
'
Test default bbcodes: simple quote
'
,
'
[quote]quoted[/quote]
'
,
'
[quote:]quoted[/quote:]
'
,
),
array
(
'
Test default bbcodes: simple quote with username
'
,
'
[quote="username"]quoted[/quote]
'
,
'
[quote="username":]quoted[/quote:]
'
,
),
array
(
'
Test default bbcodes: simple code
'
,
'
[code]unparsed code[/code]
'
,
'
[code:]unparsed code[/code:]
'
,
),
array
(
'
Test default bbcodes: simple php code
'
,
'
[code=php]unparsed code[/code]
'
,
'
[code=php:]<span class="syntaxdefault">unparsed code</span>[/code:]
'
,
),
array
(
'
Test default bbcodes: simple list
'
,
'
[list]no item[/list]
'
,
'
[list:]no item[/list:u:]
'
,
),
array
(
'
Test default bbcodes: simple list-item only
'
,
'
[*]unparsed
'
,
'
[*]unparsed
'
,
),
array
(
'
Test default bbcodes: simple list-item
'
,
'
[list][*]item[/list]
'
,
'
[list:][*:]item[/*:m:][/list:u:]
'
,
),
array
(
'
Test default bbcodes: simple list-item closed
'
,
'
[list][*]item[/*][/list]
'
,
'
[list:][*:]item[/*:][/list:u:]
'
,
),
array
(
'
Test default bbcodes: simple list-item numbered
'
,
'
[list=1][*]item[/list]
'
,
'
[list=1:][*:]item[/*:m:][/list:o:]
'
,
),
array
(
'
Test default bbcodes: simple list-item alpha
'
,
'
[list=a][*]item[/list]
'
,
'
[list=a:][*:]item[/*:m:][/list:o:]
'
,
),
array
(
'
Test default bbcodes: simple list-item roman
'
,
'
[list=i][*]item[/list]
'
,
'
[list=i:][*:]item[/*:m:][/list:o:]
'
,
),
array
(
'
Test default bbcodes: simple list-item disc
'
,
'
[list=disc][*]item[/list]
'
,
'
[list=disc:][*:]item[/*:m:][/list:u:]
'
,
),
array
(
'
Test default bbcodes: simple list-item circle
'
,
'
[list=circle][*]item[/list]
'
,
'
[list=circle:][*:]item[/*:m:][/list:u:]
'
,
),
array
(
'
Test default bbcodes: simple list-item square
'
,
'
[list=square][*]item[/list]
'
,
'
[list=square:][*:]item[/*:m:][/list:u:]
'
,
),
array
(
'
Test default bbcodes: simple img
'
,
'
[img]https://area51.phpbb.com/images/area51.png[/img]
'
,
'
[img:]https://area51.phpbb.com/images/area51.png[/img:]
'
,
),
array
(
'
Test default bbcodes: simple url
'
,
'
[url]https://area51.phpbb.com/[/url]
'
,
'
[url:]https://area51.phpbb.com/[/url:]
'
,
),
array
(
'
Test default bbcodes: simple url with description
'
,
'
[url=https://area51.phpbb.com/]Area51[/url]
'
,
'
[url=https://area51.phpbb.com/:]Area51[/url:]
'
,
),
array
(
'
Test default bbcodes: simple email
'
,
'
[email]bbcode-test@phpbb.com[/email]
'
,
'
[email:]bbcode-test@phpbb.com[/email:]
'
,
),
array
(
'
Test default bbcodes: simple email with description
'
,
'
[email=bbcode-test@phpbb.com]Email[/email]
'
,
'
[email=bbcode-test@phpbb.com:]Email[/email:]
'
,
),
array
(
'
Test default bbcodes: simple attachment
'
,
'
[attachment=0]filename[/attachment]
'
,
'
[attachment=0:]<!-- ia0 -->filename<!-- ia0 -->[/attachment:]
'
,
),
// Special cases for quote which were reported as bugs before
array
(
'
PHPBB3-1401 - correct: parsed
'
,
'
[quote="[test]test"]test [ test[/quote]
'
,
'
[quote="[test]test":]test [ test[/quote:]
'
,
),
array
(
'
PHPBB3-6117 - correct: parsed
'
,
'
[quote]test[/quote] test ] and [ test [quote]test[/quote]
'
,
'
[quote:]test[/quote:] test ] and [ test [quote:]test[/quote:]
'
,
),
array
(
'
PHPBB3-6200 - correct: parsed
'
,
'
[quote="["]test[/quote]
'
,
'
[quote="[":]test[/quote:]
'
,
),
array
(
'
PHPBB3-9364 - quoted: "test[/[/b]quote] test" / non-quoted: "[/quote] test" - also failed if layout distorted
'
,
'
[quote]test[/[/b]quote] test [/quote][/quote] test
'
,
'
[quote:]test[/[/b]quote] test [/quote:][/quote] test
'
,
),
array
(
'
PHPBB3-8096 - first quote tag parsed, second quote tag unparsed
'
,
'
[quote="a"]a[/quote][quote="a]a[/quote]
'
,
'
[quote="a":]a[/quote:][quote="a]a[/quote]
'
,
),
// Simple bbcodes nesting
array
(
'
Allow textual bbcodes in textual bbcodes
'
,
'
[b]bold [i]bold + italic[/i][/b]
'
,
'
[b:]bold [i:]bold + italic[/i:][/b:]
'
,
),
array
(
'
Allow textual bbcodes in url with description
'
,
'
[url=https://area51.phpbb.com/]Area51 [i]italic[/i][/url]
'
,
'
[url=https://area51.phpbb.com/:]Area51 [i:]italic[/i:][/url:]
'
,
),
array
(
'
Allow url with description in textual bbcodes
'
,
'
[i]italic [url=https://area51.phpbb.com/]Area51[/url][/i]
'
,
'
[i:]italic [url=https://area51.phpbb.com/:]Area51[/url:][/i:]
'
,
),
// Nesting bbcodes into quote usernames
array
(
'
Allow textual bbcodes in usernames
'
,
'
[quote="[i]test[/i]"]test[/quote]
'
,
'
[quote="[i:]test[/i:]":]test[/quote:]
'
,
),
array
(
'
Allow links bbcodes in usernames
'
,
'
[quote="[url=https://area51.phpbb.com/]test[/url]"]test[/quote]
'
,
'
[quote="[url=https://area51.phpbb.com/:]test[/url:]":]test[/quote:]
'
,
),
array
(
'
Allow img bbcodes in usernames - Username displayed the image
'
,
'
[quote="[img]https://area51.phpbb.com/images/area51.png[/img]"]test[/quote]
'
,
'
[quote="[img:]https://area51.phpbb.com/images/area51.png[/img:]":]test[/quote:]
'
,
),
array
(
'
Disallow flash bbcodes in usernames - Username displayed as [flash]http://www.phpbb.com/[/flash]
'
,
'
[quote="[flash]http://www.phpbb.com/[/flash]"]test[/quote]
'
,
'
[quote="[flash]http://www.phpbb.com/[/flash]":]test[/quote:]
'
,
),
array
(
'
Disallow quote bbcodes in usernames - Username displayed as [quote]test[/quote]
'
,
'
[quote="[quote]test[/quote]"]test[/quote]
'
,
'
[quote="[quote]test[/quote]":]test[/quote:]
'
,
),
// Do not parse bbcodes in code boxes
array
(
'
Do not parse textual bbcodes in code
'
,
'
[code]unparsed code [b]bold [i]bold + italic[/i][/b][/code]
'
,
'
[code:]unparsed code [b]bold [i]bold + italic[/i][/b][/code:]
'
,
),
array
(
'
Do not parse quote bbcodes in code
'
,
'
[code]unparsed code [quote="username"]quoted[/quote][/code]
'
,
'
[code:]unparsed code [quote="username"]quoted[/quote][/code:]
'
,
),
// New user friendly mixed nesting
array
(
'
Textual bbcode nesting into textual bbcode
'
,
'
[b]bold [i]bold + italic[/b] italic[/i]
'
,
'
[b:]bold [i:]bold + italic[/b:] italic[/i:]
'
,
'
Incomplete test case: secondpass parses as [b:]bold [i:]bold + italic[/i:] italic[/b:]
'
,
),
);
}
/**
* @dataProvider bbcode_firstpass_data
*/
public
function
test_bbcode_firstpass
(
$
description
,
$
message
,
$
expected
,
$
incomplete
=
false
)
{
if
(
$
incomplete
)
{
$
this
->
markTestIncomplete
(
$
incomplete
);
}
global
$
user
,
$
request
;
$
user
=
new
phpbb_mock_user
;
$
request
=
new
phpbb_mock_request
;
$
bbcode
=
new
bbcode_firstpass
();
$
bbcode
->
message
=
$
message
;
$
bbcode
->
bbcode_init
(
false
);
$
bbcode
->
parse_bbcode
();
$
this
->
assertEquals
(
$
expected
,
$
bbcode
->
message
);
}
}
Back
|
FazBrowse Home
|
New Git URL