1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Comrade42\PhpBBParser\Tests; |
4
|
|
|
|
5
|
|
|
use Comrade42\PhpBBParser\Helper\BBCodes\DOMParser; |
6
|
|
|
use Comrade42\PhpBBParser\Helper\BBCodes\PCREParser; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class PCREParserTest |
10
|
|
|
* @package Comrade42\PhpBBParser\Tests |
11
|
|
|
*/ |
12
|
|
|
class PCREParserTest extends \PHPUnit_Framework_TestCase |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @param string $html |
16
|
|
|
* @param string $expected |
17
|
|
|
* @dataProvider providerParseTypeface |
18
|
|
|
*/ |
19
|
10 |
|
public function testParseTypeface($html, $expected) |
20
|
|
|
{ |
21
|
10 |
|
$this->assertEquals($expected, PCREParser::parseTypeface($html)); |
22
|
|
|
// $this->assertEquals($expected, DOMParser::parseTypeface($html)); |
|
|
|
|
23
|
10 |
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param string $html |
27
|
|
|
* @param string $expected |
28
|
|
|
* @dataProvider providerParseAlign |
29
|
|
|
*/ |
30
|
7 |
|
public function testParseAlign($html, $expected) |
31
|
|
|
{ |
32
|
7 |
|
$this->assertEquals($expected, PCREParser::parseAlign($html)); |
33
|
7 |
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param string $html |
37
|
|
|
* @param string $expected |
38
|
|
|
* @dataProvider provideParseColor |
39
|
|
|
*/ |
40
|
5 |
|
public function testParseColor($html, $expected) |
41
|
|
|
{ |
42
|
5 |
|
$this->assertEquals($expected, PCREParser::parseColor($html)); |
43
|
5 |
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param string $html |
47
|
|
|
* @param string $expected |
48
|
|
|
* @dataProvider provideParseSize |
49
|
|
|
*/ |
50
|
5 |
|
public function testParseSize($html, $expected) |
51
|
|
|
{ |
52
|
5 |
|
$this->assertEquals($expected, PCREParser::parseSize($html)); |
53
|
5 |
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param string $html |
57
|
|
|
* @param string $expected |
58
|
|
|
* @dataProvider provideParseFont |
59
|
|
|
*/ |
60
|
5 |
|
public function testParseFont($html, $expected) |
61
|
|
|
{ |
62
|
5 |
|
$this->assertEquals($expected, PCREParser::parseFont($html)); |
63
|
5 |
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param string $html |
67
|
|
|
* @param string $expected |
68
|
|
|
* @dataProvider provideParseQuote |
69
|
|
|
*/ |
70
|
8 |
|
public function testParseQuote($html, $expected) |
71
|
|
|
{ |
72
|
8 |
|
$this->assertEquals($expected, PCREParser::parseQuote($html)); |
73
|
8 |
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param string $html |
77
|
|
|
* @param string $expected |
78
|
|
|
* @dataProvider provideParseCode |
79
|
|
|
*/ |
80
|
4 |
|
public function testParseCode($html, $expected) |
81
|
|
|
{ |
82
|
4 |
|
$this->assertEquals($expected, PCREParser::parseCode($html)); |
83
|
4 |
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @param string $html |
87
|
|
|
* @param string $expected |
88
|
|
|
* @dataProvider provideParseHide |
89
|
|
|
*/ |
90
|
4 |
|
public function testParseHide($html, $expected) |
91
|
|
|
{ |
92
|
4 |
|
$this->assertEquals($expected, PCREParser::parseHide($html)); |
93
|
4 |
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param string $html |
97
|
|
|
* @param string $expected |
98
|
|
|
* @dataProvider provideParseList |
99
|
|
|
*/ |
100
|
7 |
|
public function testParseList($html, $expected) |
101
|
|
|
{ |
102
|
7 |
|
$this->assertEquals($expected, PCREParser::parseList($html)); |
103
|
7 |
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @param string $html |
107
|
|
|
* @param string $expected |
108
|
|
|
* @dataProvider provideParseLink |
109
|
|
|
*/ |
110
|
8 |
|
public function testParseLink($html, $expected) |
111
|
|
|
{ |
112
|
8 |
|
$this->assertEquals($expected, PCREParser::parseLink($html)); |
113
|
8 |
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @param string $html |
117
|
|
|
* @param string $expected |
118
|
|
|
* @dataProvider provideParseImage |
119
|
|
|
*/ |
120
|
5 |
|
public function testParseImage($html, $expected) |
121
|
|
|
{ |
122
|
5 |
|
$this->assertEquals($expected, PCREParser::parseImage($html)); |
123
|
5 |
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @param string $html |
127
|
|
|
* @param string $expected |
128
|
|
|
* @dataProvider provideParseVideo |
129
|
|
|
*/ |
130
|
6 |
|
public function testParseVideo($html, $expected) |
131
|
|
|
{ |
132
|
6 |
|
$this->assertEquals($expected, PCREParser::parseVideo($html)); |
133
|
6 |
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @param string $html |
137
|
|
|
* @param string $expected |
138
|
|
|
* @dataProvider provideParseFlash |
139
|
|
|
*/ |
140
|
4 |
|
public function testParseFlash($html, $expected) |
141
|
|
|
{ |
142
|
4 |
|
$this->assertEquals($expected, PCREParser::parseFlash($html)); |
143
|
4 |
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @param string $html |
147
|
|
|
* @param string $expected |
148
|
|
|
* @dataProvider provideParseTable |
149
|
|
|
*/ |
150
|
4 |
|
public function testParseTable($html, $expected) |
151
|
|
|
{ |
152
|
4 |
|
$this->assertEquals($expected, PCREParser::parseTable($html)); |
153
|
4 |
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param string $html |
157
|
|
|
* @param string $expected |
158
|
|
|
* @dataProvider provideParseScrolling |
159
|
|
|
*/ |
160
|
6 |
|
public function testParseScrolling($html, $expected) |
161
|
|
|
{ |
162
|
6 |
|
$this->assertEquals($expected, PCREParser::parseScrolling($html)); |
163
|
6 |
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @param string $html |
167
|
|
|
* @param string $expected |
168
|
|
|
* @dataProvider provideParseLine |
169
|
|
|
*/ |
170
|
4 |
|
public function testParseLine($html, $expected) |
171
|
|
|
{ |
172
|
4 |
|
$this->assertEquals($expected, PCREParser::parseLine($html)); |
173
|
4 |
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @param string $html |
177
|
|
|
* @param string $expected |
178
|
|
|
* @dataProvider provideParseIndex |
179
|
|
|
*/ |
180
|
6 |
|
public function testParseIndex($html, $expected) |
181
|
|
|
{ |
182
|
6 |
|
$this->assertEquals($expected, PCREParser::parseIndex($html)); |
183
|
6 |
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @param string $html |
187
|
|
|
* @param string $expected |
188
|
|
|
* @dataProvider provideParseEffect |
189
|
|
|
*/ |
190
|
10 |
|
public function testParseEffect($html, $expected) |
191
|
|
|
{ |
192
|
10 |
|
$this->assertEquals($expected, PCREParser::parseEffect($html)); |
193
|
10 |
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @param string $html |
197
|
|
|
* @param string $expected |
198
|
|
|
* @dataProvider provideParseRandom |
199
|
|
|
*/ |
200
|
5 |
|
public function testParseRandom($html, $expected) |
201
|
|
|
{ |
202
|
5 |
|
$this->assertEquals($expected, PCREParser::parseRandom($html)); |
203
|
5 |
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* @return array |
207
|
|
|
* @see testParseTypeface |
208
|
|
|
*/ |
209
|
|
View Code Duplication |
public function providerParseTypeface() |
|
|
|
|
210
|
|
|
{ |
211
|
|
|
return array( |
212
|
|
|
array('', ''), |
213
|
|
|
array('Привет', 'Привет'), |
214
|
|
|
array('<strong>Привет</strong>', '[b]Привет[/b]'), |
215
|
|
|
array('<u>Добрый день</u>', '[u]Добрый день[/u]'), |
216
|
|
|
array('<i>Это круто!</i>', '[i]Это круто![/i]'), |
217
|
|
|
array('<strike>черновик</strike>', '[strike]черновик[/strike]'), |
218
|
|
|
array('<strong>Привет</strong> <strong>Привет</strong>', '[b]Привет[/b] [b]Привет[/b]'), |
219
|
|
|
array('<strong>Привет</strong> <u>Добрый день</u>', '[b]Привет[/b] [u]Добрый день[/u]'), |
220
|
|
|
array('<u>Добрый <strike>черновик</strike> день</u>', '[u]Добрый [strike]черновик[/strike] день[/u]'), |
221
|
|
|
array('Добрый <strike>черновик</strike> день', 'Добрый [strike]черновик[/strike] день') |
222
|
|
|
); |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* @return array |
227
|
|
|
* @see testParseAlign |
228
|
|
|
*/ |
229
|
|
View Code Duplication |
public function providerParseAlign() |
|
|
|
|
230
|
|
|
{ |
231
|
|
|
return array( |
232
|
|
|
array('', ''), |
233
|
|
|
array('Привет', 'Привет'), |
234
|
|
|
array('<div align="left">Текст слева</div>', '[left]Текст слева[/left]'), |
235
|
|
|
array('<div align="center">Текст по центру</div>', '[center]Текст по центру[/center]'), |
236
|
|
|
array('<div align="right">Текст справа</div>', '[right]Текст справа[/right]'), |
237
|
|
|
array('<div align="justify">Lorem ipsum</div>', '[justify]Lorem ipsum[/justify]'), |
238
|
|
|
array('Добрый <div align="left">Текст слева</div> день', 'Добрый [left]Текст слева[/left] день') |
239
|
|
|
); |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* @return array |
244
|
|
|
* @see testParseColor |
245
|
|
|
*/ |
246
|
|
View Code Duplication |
public function provideParseColor() |
|
|
|
|
247
|
|
|
{ |
248
|
|
|
return array( |
249
|
|
|
array('', ''), |
250
|
|
|
array('Привет', 'Привет'), |
251
|
|
|
array('<span style="color:red">Привет! (red)</span>', '[color=red]Привет! (red)[/color]'), |
252
|
|
|
array('<span style="color:#FF0000">Привет! (#FF0000)</span>', '[color=#FF0000]Привет! (#FF0000)[/color]'), |
253
|
|
|
array('Добрый <span style="color:red">Привет! (red)</span> день', 'Добрый [color=red]Привет! (red)[/color] день') |
254
|
|
|
); |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* @return array |
259
|
|
|
* @see testParseSize |
260
|
|
|
*/ |
261
|
|
View Code Duplication |
public function provideParseSize() |
|
|
|
|
262
|
|
|
{ |
263
|
|
|
return array( |
264
|
|
|
array('', ''), |
265
|
|
|
array('Привет', 'Привет'), |
266
|
|
|
array('<span style="font-size:9px">МАЛЕНЬКИЙ</span>', '[size=9]МАЛЕНЬКИЙ[/size]'), |
267
|
|
|
array('<span style="font-size:24px">ОГРОМНЫЙ</span>', '[size=24]ОГРОМНЫЙ[/size]'), |
268
|
|
|
array('Добрый <span style="font-size:9px">МАЛЕНЬКИЙ</span> день', 'Добрый [size=9]МАЛЕНЬКИЙ[/size] день') |
269
|
|
|
); |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* @return array |
274
|
|
|
* @see testParseFont |
275
|
|
|
*/ |
276
|
|
View Code Duplication |
public function provideParseFont() |
|
|
|
|
277
|
|
|
{ |
278
|
|
|
return array( |
279
|
|
|
array('', ''), |
280
|
|
|
array('Привет', 'Привет'), |
281
|
|
|
array('<span style="font-family: Arial"> Arial</span>', '[font=Arial] Arial[/font]'), |
282
|
|
|
array('<span style="font-family: Comic Sans Ms">Comic Sans Ms</span>', '[font=Comic Sans Ms]Comic Sans Ms[/font]'), |
283
|
|
|
array('Добрый <span style="font-family: Arial">Arial</span> день', 'Добрый [font=Arial]Arial[/font] день') |
284
|
|
|
); |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* @return array |
289
|
|
|
* @see testParseQuote |
290
|
|
|
*/ |
291
|
|
View Code Duplication |
public function provideParseQuote() |
|
|
|
|
292
|
|
|
{ |
293
|
|
|
return array( |
294
|
|
|
array('', ''), |
295
|
|
|
array('Привет', 'Привет'), |
296
|
|
|
array('<blockquote><div>Цитата без ссылки</div></blockquote>', '[quote]Цитата без ссылки[/quote]'), |
297
|
|
|
array('Добрый <blockquote><div>Цитата без ссылки</div></blockquote> день', 'Добрый [quote]Цитата без ссылки[/quote] день'), |
298
|
|
|
array('<blockquote><div><cite>Иванов пишет:</cite>Добрый день</div></blockquote>', '[quote="Иванов"]Добрый день[/quote]'), |
299
|
|
|
array('Добрый <blockquote><div><cite>Иванов пишет:</cite>Добрый день</div></blockquote> день', 'Добрый [quote="Иванов"]Добрый день[/quote] день'), |
300
|
|
|
array( |
301
|
|
|
'<blockquote><div><cite>Вася пишет:</cite><blockquote><div>Добрый день</div></blockquote>Привет, Петя</div></blockquote>Привет всем!', |
302
|
|
|
'[quote="Вася"][quote]Добрый день[/quote]Привет, Петя[/quote]Привет всем!' |
303
|
|
|
), |
304
|
|
|
array( |
305
|
|
|
'<blockquote><div><cite>Вася пишет:</cite><blockquote><div><cite>Петя пишет:</cite>Добрый день</div></blockquote>Привет, Петя</div></blockquote>Привет всем!', |
306
|
|
|
'[quote="Вася"][quote="Петя"]Добрый день[/quote]Привет, Петя[/quote]Привет всем!' |
307
|
|
|
) |
308
|
|
|
); |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
/** |
312
|
|
|
* @return array |
313
|
|
|
* @see testParseCode |
314
|
|
|
*/ |
315
|
|
View Code Duplication |
public function provideParseCode() |
|
|
|
|
316
|
|
|
{ |
317
|
|
|
return array( |
318
|
|
|
array('', ''), |
319
|
|
|
array('Привет', 'Привет'), |
320
|
|
|
array('<dl class="codebox"><dt>Код:</dt><dd><code>"Это код"</code></dd></dl>', '[code]"Это код"[/code]'), |
321
|
|
|
array('Добрый <dl class="codebox"><dt>Код:</dt><dd><code>"Это код"</code></dd></dl> день', 'Добрый [code]"Это код"[/code] день') |
322
|
|
|
); |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* @return array |
327
|
|
|
* @see testParseHide |
328
|
|
|
*/ |
329
|
|
View Code Duplication |
public function provideParseHide() |
|
|
|
|
330
|
|
|
{ |
331
|
|
|
return array( |
332
|
|
|
array('', ''), |
333
|
|
|
array('Привет', 'Привет'), |
334
|
|
|
array('<dl class="codebox hidecode"><dt style="border: none;"></dt><dd>123</dd></dl>', '[hide]123[/hide]'), |
335
|
|
|
array('Добрый <dl class="codebox hidecode"><dt style="border: none;"></dt><dd>123</dd></dl> день', 'Добрый [hide]123[/hide] день') |
336
|
|
|
); |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* @return array |
341
|
|
|
* @see testParseList |
342
|
|
|
*/ |
343
|
|
View Code Duplication |
public function provideParseList() |
|
|
|
|
344
|
|
|
{ |
345
|
|
|
return array( |
346
|
|
|
array('', ''), |
347
|
|
|
array('Привет', 'Привет'), |
348
|
|
|
array('<ul><li>Красный</li></ul>', '[list][*]Красный[/list]'), |
349
|
|
|
array('<ul><li>Красный</li><li>Синий</li><li>Желтый</li></ul>', '[list][*]Красный[*]Синий[*]Желтый[/list]'), |
350
|
|
|
array('Добрый <ul><li>Красный</li><li>Синий</li><li>Желтый</li></ul> день', 'Добрый [list][*]Красный[*]Синий[*]Желтый[/list] день'), |
351
|
|
|
array('<ol type="1"><li>A</li><li>B</li><li>C</li></ol>', '[list=1][*]A[*]B[*]C[/list]'), |
352
|
|
|
array('<ol type="a"><li>A</li><li>B</li><li>C</li></ol>', '[list=a][*]A[*]B[*]C[/list]') |
353
|
|
|
); |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
/** |
357
|
|
|
* @return array |
358
|
|
|
* @see testParseLink |
359
|
|
|
*/ |
360
|
|
View Code Duplication |
public function provideParseLink() |
|
|
|
|
361
|
|
|
{ |
362
|
|
|
return array( |
363
|
|
|
array('', ''), |
364
|
|
|
array('Привет', 'Привет'), |
365
|
|
|
array( |
366
|
|
|
'<a href="http://www.forum2x2.ru">http://www.forum2x2.ru</a>', |
367
|
|
|
'[url]http://www.forum2x2.ru[/url]' |
368
|
|
|
), |
369
|
|
|
array( |
370
|
|
|
'<a href="http://www.forum2x2.ru" target="_blank" rel="nofollow">http://www.forum2x2.ru</a>', |
371
|
|
|
'[url]http://www.forum2x2.ru[/url]' |
372
|
|
|
), |
373
|
|
|
array( |
374
|
|
|
'Добрый <a href="http://www.forum2x2.ru">http://www.forum2x2.ru</a> день', |
375
|
|
|
'Добрый [url]http://www.forum2x2.ru[/url] день' |
376
|
|
|
), |
377
|
|
|
array( |
378
|
|
|
'<a href="http://www.forum2x2.ru">Посетите forum2x2.ru!</a>', |
379
|
|
|
'[url=http://www.forum2x2.ru]Посетите forum2x2.ru![/url]' |
380
|
|
|
), |
381
|
|
|
array( |
382
|
|
|
'<a href="http://www.forum2x2.ru" target="_blank" rel="nofollow">Посетите forum2x2.ru!</a>', |
383
|
|
|
'[url=http://www.forum2x2.ru]Посетите forum2x2.ru![/url]' |
384
|
|
|
), |
385
|
|
|
array( |
386
|
|
|
'Добрый <a href="http://www.forum2x2.ru">Посетите forum2x2.ru!</a> день', |
387
|
|
|
'Добрый [url=http://www.forum2x2.ru]Посетите forum2x2.ru![/url] день' |
388
|
|
|
) |
389
|
|
|
); |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
/** |
393
|
|
|
* @return array |
394
|
|
|
* @see testParseImage |
395
|
|
|
*/ |
396
|
|
View Code Duplication |
public function provideParseImage() |
|
|
|
|
397
|
|
|
{ |
398
|
|
|
return array( |
399
|
|
|
array('', ''), |
400
|
|
|
array('Привет', 'Привет'), |
401
|
|
|
array( |
402
|
|
|
'<img src="http://www.illiweb.com/fa/banner/ru/banner1.gif" alt="">', |
403
|
|
|
'[img]http://www.illiweb.com/fa/banner/ru/banner1.gif[/img]' |
404
|
|
|
), |
405
|
|
|
array( |
406
|
|
|
'<img src="http://www.illiweb.com/fa/banner/ru/banner1.gif" style="width: 320px;height: 280px" alt="">', |
407
|
|
|
'[img(320px,280px)]http://www.illiweb.com/fa/banner/ru/banner1.gif[/img]' |
408
|
|
|
), |
409
|
|
|
array( |
410
|
|
|
'Добрый <img src="http://www.illiweb.com/fa/banner/ru/banner1.gif" alt=""> день', |
411
|
|
|
'Добрый [img]http://www.illiweb.com/fa/banner/ru/banner1.gif[/img] день' |
412
|
|
|
) |
413
|
|
|
); |
414
|
|
|
} |
415
|
|
|
|
416
|
|
|
/** |
417
|
|
|
* @return array |
418
|
|
|
* @see testParseVideo |
419
|
|
|
*/ |
420
|
|
View Code Duplication |
public function provideParseVideo() |
|
|
|
|
421
|
|
|
{ |
422
|
|
|
return array( |
423
|
|
|
array('', ''), |
424
|
|
|
array('Привет', 'Привет'), |
425
|
|
|
array( |
426
|
|
|
'<embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://www.youtube.com/v/J10MxpWAQF4" width="425" height="350" type="application/x-shockwave-flash" wmode="transparent" quality="high" scale="exactfit">', |
427
|
|
|
'[youtube]J10MxpWAQF4[/youtube]' |
428
|
|
|
), |
429
|
|
|
array( |
430
|
|
|
'Добрый <embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://www.youtube.com/v/J10MxpWAQF4" width="425" height="350" type="application/x-shockwave-flash" wmode="transparent" quality="high" scale="exactfit"> день', |
431
|
|
|
'Добрый [youtube]J10MxpWAQF4[/youtube] день' |
432
|
|
|
), |
433
|
|
|
array( |
434
|
|
|
'<embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://www.dailymotion.com/swf/xllcfg" width="425" height="350" type="application/x-shockwave-flash" wmode="transparent" quality="high" scale="exactfit" allowscriptaccess="always" allowfullscreen="true">', |
435
|
|
|
'[dailymotion]xllcfg[/dailymotion]' |
436
|
|
|
), |
437
|
|
|
array( |
438
|
|
|
'Добрый <embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://www.dailymotion.com/swf/xllcfg" width="425" height="350" type="application/x-shockwave-flash" wmode="transparent" quality="high" scale="exactfit" allowscriptaccess="always" allowfullscreen="true"> день', |
439
|
|
|
'Добрый [dailymotion]xllcfg[/dailymotion] день' |
440
|
|
|
) |
441
|
|
|
); |
442
|
|
|
} |
443
|
|
|
|
444
|
|
|
/** |
445
|
|
|
* @return array |
446
|
|
|
* @see testParseFlash |
447
|
|
|
*/ |
448
|
|
View Code Duplication |
public function provideParseFlash() |
|
|
|
|
449
|
|
|
{ |
450
|
|
|
return array( |
451
|
|
|
array('', ''), |
452
|
|
|
array('Привет', 'Привет'), |
453
|
|
|
array( |
454
|
|
|
'<embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://illiweb.com/fa/i/test_bbcode.swf" width="200" height="40" type="application/x-shockwave-flash" wmode="transparent" quality="high" scale="exactfit">', |
455
|
|
|
'[flash(200,40)]http://illiweb.com/fa/i/test_bbcode.swf[/flash]' |
456
|
|
|
), |
457
|
|
|
array( |
458
|
|
|
'Добрый <embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://illiweb.com/fa/i/test_bbcode.swf" width="200" height="40" type="application/x-shockwave-flash" wmode="transparent" quality="high" scale="exactfit"> день', |
459
|
|
|
'Добрый [flash(200,40)]http://illiweb.com/fa/i/test_bbcode.swf[/flash] день' |
460
|
|
|
) |
461
|
|
|
); |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
/** |
465
|
|
|
* @return array |
466
|
|
|
* @see testParseTable |
467
|
|
|
*/ |
468
|
1 |
View Code Duplication |
public function provideParseTable() |
|
|
|
|
469
|
|
|
{ |
470
|
|
|
return array( |
471
|
1 |
|
array('', ''), |
472
|
|
|
array('Привет', 'Привет'), |
473
|
|
|
array( |
474
|
|
|
'<table border="1"><tbody><tr><td>Строка 1 - Ячейка 1</td><td>Строка 1 - Ячейка 2</td><td>Строка 1 - Ячейка 3</td></tr><tr><td>Строка 2 - Ячейка 1</td><td>Строка 2 - Ячейка 2</td><td>Строка 2 - Ячейка 3</td></tr></tbody></table>', |
475
|
|
|
'[table][tr][td]Строка 1 - Ячейка 1[/td][td]Строка 1 - Ячейка 2[/td][td]Строка 1 - Ячейка 3[/td][/tr][tr][td]Строка 2 - Ячейка 1[/td][td]Строка 2 - Ячейка 2[/td][td]Строка 2 - Ячейка 3[/td][/tr][/table]' |
476
|
|
|
), |
477
|
|
|
array( |
478
|
|
|
'Добрый <table border="1"><tbody><tr><td>Строка 1 - Ячейка 1</td><td>Строка 1 - Ячейка 2</td><td>Строка 1 - Ячейка 3</td></tr><tr><td>Строка 2 - Ячейка 1</td><td>Строка 2 - Ячейка 2</td><td>Строка 2 - Ячейка 3</td></tr></tbody></table> день', |
479
|
|
|
'Добрый [table][tr][td]Строка 1 - Ячейка 1[/td][td]Строка 1 - Ячейка 2[/td][td]Строка 1 - Ячейка 3[/td][/tr][tr][td]Строка 2 - Ячейка 1[/td][td]Строка 2 - Ячейка 2[/td][td]Строка 2 - Ячейка 3[/td][/tr][/table] день' |
480
|
|
|
) |
481
|
|
|
); |
482
|
|
|
} |
483
|
|
|
|
484
|
|
|
/** |
485
|
|
|
* @return array |
486
|
|
|
* @see testParseScrolling |
487
|
|
|
*/ |
488
|
|
View Code Duplication |
public function provideParseScrolling() |
|
|
|
|
489
|
|
|
{ |
490
|
|
|
return array( |
491
|
|
|
array('', ''), |
492
|
|
|
array('Привет', 'Привет'), |
493
|
|
|
array( |
494
|
|
|
'<span><marquee>Мое сообщение</marquee></span>', |
495
|
|
|
'[scroll]Мое сообщение[/scroll]' |
496
|
|
|
), |
497
|
|
|
array( |
498
|
|
|
'Добрый <span><marquee>Мое сообщение</marquee></span> день', |
499
|
|
|
'Добрый [scroll]Мое сообщение[/scroll] день' |
500
|
|
|
), |
501
|
|
|
array( |
502
|
|
|
'<marquee direction="up" scrollamount="1" style="height: 60px;">Мое сообщение</marquee>', |
503
|
|
|
'[updown]Мое сообщение[/updown]' |
504
|
|
|
), |
505
|
|
|
array( |
506
|
|
|
'Добрый <marquee direction="up" scrollamount="1" style="height: 60px;">Мое сообщение</marquee> день', |
507
|
|
|
'Добрый [updown]Мое сообщение[/updown] день' |
508
|
|
|
) |
509
|
|
|
); |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
/** |
513
|
|
|
* @return array |
514
|
|
|
* @see testParseLine |
515
|
|
|
*/ |
516
|
|
View Code Duplication |
public function provideParseLine() |
|
|
|
|
517
|
|
|
{ |
518
|
|
|
return array( |
519
|
|
|
array('', ''), |
520
|
|
|
array('Привет', 'Привет'), |
521
|
|
|
array('<hr>', '[hr]'), |
522
|
|
|
array('Первая часть сообщения<hr>Вторая часть сообщения', 'Первая часть сообщения[hr]Вторая часть сообщения') |
523
|
|
|
); |
524
|
|
|
} |
525
|
|
|
|
526
|
|
|
/** |
527
|
|
|
* @return array |
528
|
|
|
* @see testParseIndex |
529
|
|
|
*/ |
530
|
|
View Code Duplication |
public function provideParseIndex() |
|
|
|
|
531
|
|
|
{ |
532
|
|
|
return array( |
533
|
|
|
array('', ''), |
534
|
|
|
array('Привет', 'Привет'), |
535
|
|
|
array('<sub>a+b</sub>', '[sub]a+b[/sub]'), |
536
|
|
|
array('X<sub>a+b</sub>Y', 'X[sub]a+b[/sub]Y'), |
537
|
|
|
array('<sup>е</sup>', '[sup]е[/sup]'), |
538
|
|
|
array('1<sup>е</sup> место', '1[sup]е[/sup] место') |
539
|
|
|
); |
540
|
|
|
} |
541
|
|
|
|
542
|
|
|
/** |
543
|
|
|
* @return array |
544
|
|
|
* @see testParseEffect |
545
|
|
|
*/ |
546
|
|
View Code Duplication |
public function provideParseEffect() |
|
|
|
|
547
|
|
|
{ |
548
|
|
|
return array( |
549
|
|
|
array('', ''), |
550
|
|
|
array('Привет', 'Привет'), |
551
|
|
|
array( |
552
|
|
|
'<span class="flipV">Вертикальный зеркальный эффект</span>', |
553
|
|
|
'[flipv]Вертикальный зеркальный эффект[/flipv]' |
554
|
|
|
), |
555
|
|
|
array( |
556
|
|
|
'Добрый <span class="flipV">Вертикальный зеркальный эффект</span> день', |
557
|
|
|
'Добрый [flipv]Вертикальный зеркальный эффект[/flipv] день' |
558
|
|
|
), |
559
|
|
|
array( |
560
|
|
|
'<span class="flipH">Горизонтальный зеркальный эффект</span>', |
561
|
|
|
'[fliph]Горизонтальный зеркальный эффект[/fliph]' |
562
|
|
|
), |
563
|
|
|
array( |
564
|
|
|
'Добрый <span class="flipH">Горизонтальный зеркальный эффект</span> день', |
565
|
|
|
'Добрый [fliph]Горизонтальный зеркальный эффект[/fliph] день' |
566
|
|
|
), |
567
|
|
|
array( |
568
|
|
|
'<span class="blur">Размытый текст</span>', |
569
|
|
|
'[blur]Размытый текст[/blur]' |
570
|
|
|
), |
571
|
|
|
array( |
572
|
|
|
'Добрый <span class="blur">Размытый текст</span> день', |
573
|
|
|
'Добрый [blur]Размытый текст[/blur] день' |
574
|
|
|
), |
575
|
|
|
array( |
576
|
|
|
'<span class="fade">Затухающий текст</span>', |
577
|
|
|
'[fade]Затухающий текст[/fade]' |
578
|
|
|
), |
579
|
|
|
array( |
580
|
|
|
'Добрый <span class="fade">Затухающий текст</span> день', |
581
|
|
|
'Добрый [fade]Затухающий текст[/fade] день' |
582
|
|
|
) |
583
|
|
|
); |
584
|
|
|
} |
585
|
|
|
|
586
|
|
|
/** |
587
|
|
|
* @return array |
588
|
|
|
* @see testParseRandom |
589
|
|
|
*/ |
590
|
|
View Code Duplication |
public function provideParseRandom() |
|
|
|
|
591
|
|
|
{ |
592
|
|
|
return array( |
593
|
|
|
array('', ''), |
594
|
|
|
array('Привет', 'Привет'), |
595
|
|
|
array( |
596
|
|
|
'<dl class="codebox"><dd><strong>Случайное число (1,50) : </strong>50</dd></dl>', |
597
|
|
|
'[rand]50[/rand]' |
598
|
|
|
), |
599
|
|
|
array( |
600
|
|
|
'<dl class="codebox"><dd><strong>Случайное число (50,100) : </strong>93</dd></dl>', |
601
|
|
|
'[rand]50,100[/rand]' |
602
|
|
|
), |
603
|
|
|
array( |
604
|
|
|
'Добрый <dl class="codebox"><dd><strong>Случайное число (50,100) : </strong>93</dd></dl> день', |
605
|
|
|
'Добрый [rand]50,100[/rand] день' |
606
|
|
|
) |
607
|
|
|
); |
608
|
|
|
} |
609
|
|
|
} |
610
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.