ValidateAttributes_TidyTest.php
9.66 KB
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
<?php
class HTMLPurifier_Strategy_ValidateAttributes_TidyTest extends HTMLPurifier_StrategyHarness
{
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
$this->config->set('HTML.TidyLevel', 'heavy');
}
public function testConvertCenterAlign()
{
$this->assertResult(
'<h1 align="center">Centered Headline</h1>',
'<h1 style="text-align:center;">Centered Headline</h1>'
);
}
public function testConvertRightAlign()
{
$this->assertResult(
'<h1 align="right">Right-aligned Headline</h1>',
'<h1 style="text-align:right;">Right-aligned Headline</h1>'
);
}
public function testConvertLeftAlign()
{
$this->assertResult(
'<h1 align="left">Left-aligned Headline</h1>',
'<h1 style="text-align:left;">Left-aligned Headline</h1>'
);
}
public function testConvertJustifyAlign()
{
$this->assertResult(
'<p align="justify">Justified Paragraph</p>',
'<p style="text-align:justify;">Justified Paragraph</p>'
);
}
public function testRemoveInvalidAlign()
{
$this->assertResult(
'<h1 align="invalid">Invalid Headline</h1>',
'<h1>Invalid Headline</h1>'
);
}
public function testConvertTableLengths()
{
$this->assertResult(
'<td width="5%" height="10" /><th width="10" height="5%" /><hr width="10" height="10" />',
'<td style="width:5%;height:10px;" /><th style="width:10px;height:5%;" /><hr style="width:10px;" />'
);
}
public function testTdConvertNowrap()
{
$this->assertResult(
'<td nowrap />',
'<td style="white-space:nowrap;" />'
);
}
public function testCaptionConvertAlignLeft()
{
$this->assertResult(
'<caption align="left" />',
'<caption style="text-align:left;" />'
);
}
public function testCaptionConvertAlignRight()
{
$this->assertResult(
'<caption align="right" />',
'<caption style="text-align:right;" />'
);
}
public function testCaptionConvertAlignTop()
{
$this->assertResult(
'<caption align="top" />',
'<caption style="caption-side:top;" />'
);
}
public function testCaptionConvertAlignBottom()
{
$this->assertResult(
'<caption align="bottom" />',
'<caption style="caption-side:bottom;" />'
);
}
public function testCaptionRemoveInvalidAlign()
{
$this->assertResult(
'<caption align="nonsense" />',
'<caption />'
);
}
public function testTableConvertAlignLeft()
{
$this->assertResult(
'<table align="left" />',
'<table style="float:left;" />'
);
}
public function testTableConvertAlignCenter()
{
$this->assertResult(
'<table align="center" />',
'<table style="margin-left:auto;margin-right:auto;" />'
);
}
public function testTableConvertAlignRight()
{
$this->assertResult(
'<table align="right" />',
'<table style="float:right;" />'
);
}
public function testTableRemoveInvalidAlign()
{
$this->assertResult(
'<table align="top" />',
'<table />'
);
}
public function testImgConvertAlignLeft()
{
$this->assertResult(
'<img src="foobar.jpg" alt="foobar" align="left" />',
'<img src="foobar.jpg" alt="foobar" style="float:left;" />'
);
}
public function testImgConvertAlignRight()
{
$this->assertResult(
'<img src="foobar.jpg" alt="foobar" align="right" />',
'<img src="foobar.jpg" alt="foobar" style="float:right;" />'
);
}
public function testImgConvertAlignBottom()
{
$this->assertResult(
'<img src="foobar.jpg" alt="foobar" align="bottom" />',
'<img src="foobar.jpg" alt="foobar" style="vertical-align:baseline;" />'
);
}
public function testImgConvertAlignMiddle()
{
$this->assertResult(
'<img src="foobar.jpg" alt="foobar" align="middle" />',
'<img src="foobar.jpg" alt="foobar" style="vertical-align:middle;" />'
);
}
public function testImgConvertAlignTop()
{
$this->assertResult(
'<img src="foobar.jpg" alt="foobar" align="top" />',
'<img src="foobar.jpg" alt="foobar" style="vertical-align:top;" />'
);
}
public function testImgRemoveInvalidAlign()
{
$this->assertResult(
'<img src="foobar.jpg" alt="foobar" align="outerspace" />',
'<img src="foobar.jpg" alt="foobar" />'
);
}
public function testBorderConvertHVSpace()
{
$this->assertResult(
'<img src="foo" alt="foo" hspace="1" vspace="3" />',
'<img src="foo" alt="foo" style="margin-top:3px;margin-bottom:3px;margin-left:1px;margin-right:1px;" />'
);
}
public function testHrConvertSize()
{
$this->assertResult(
'<hr size="3" />',
'<hr style="height:3px;" />'
);
}
public function testHrConvertNoshade()
{
$this->assertResult(
'<hr noshade />',
'<hr style="color:#808080;background-color:#808080;border:0;" />'
);
}
public function testHrConvertAlignLeft()
{
$this->assertResult(
'<hr align="left" />',
'<hr style="margin-left:0;margin-right:auto;text-align:left;" />'
);
}
public function testHrConvertAlignCenter()
{
$this->assertResult(
'<hr align="center" />',
'<hr style="margin-left:auto;margin-right:auto;text-align:center;" />'
);
}
public function testHrConvertAlignRight()
{
$this->assertResult(
'<hr align="right" />',
'<hr style="margin-left:auto;margin-right:0;text-align:right;" />'
);
}
public function testHrRemoveInvalidAlign()
{
$this->assertResult(
'<hr align="bottom" />',
'<hr />'
);
}
public function testBrConvertClearLeft()
{
$this->assertResult(
'<br clear="left" />',
'<br style="clear:left;" />'
);
}
public function testBrConvertClearRight()
{
$this->assertResult(
'<br clear="right" />',
'<br style="clear:right;" />'
);
}
public function testBrConvertClearAll()
{
$this->assertResult(
'<br clear="all" />',
'<br style="clear:both;" />'
);
}
public function testBrConvertClearNone()
{
$this->assertResult(
'<br clear="none" />',
'<br style="clear:none;" />'
);
}
public function testBrRemoveInvalidClear()
{
$this->assertResult(
'<br clear="foo" />',
'<br />'
);
}
public function testUlConvertTypeDisc()
{
$this->assertResult(
'<ul type="disc" />',
'<ul style="list-style-type:disc;" />'
);
}
public function testUlConvertTypeSquare()
{
$this->assertResult(
'<ul type="square" />',
'<ul style="list-style-type:square;" />'
);
}
public function testUlConvertTypeCircle()
{
$this->assertResult(
'<ul type="circle" />',
'<ul style="list-style-type:circle;" />'
);
}
public function testUlConvertTypeCaseInsensitive()
{
$this->assertResult(
'<ul type="CIRCLE" />',
'<ul style="list-style-type:circle;" />'
);
}
public function testUlRemoveInvalidType()
{
$this->assertResult(
'<ul type="a" />',
'<ul />'
);
}
public function testOlConvertType1()
{
$this->assertResult(
'<ol type="1" />',
'<ol style="list-style-type:decimal;" />'
);
}
public function testOlConvertTypeLowerI()
{
$this->assertResult(
'<ol type="i" />',
'<ol style="list-style-type:lower-roman;" />'
);
}
public function testOlConvertTypeUpperI()
{
$this->assertResult(
'<ol type="I" />',
'<ol style="list-style-type:upper-roman;" />'
);
}
public function testOlConvertTypeLowerA()
{
$this->assertResult(
'<ol type="a" />',
'<ol style="list-style-type:lower-alpha;" />'
);
}
public function testOlConvertTypeUpperA()
{
$this->assertResult(
'<ol type="A" />',
'<ol style="list-style-type:upper-alpha;" />'
);
}
public function testOlRemoveInvalidType()
{
$this->assertResult(
'<ol type="disc" />',
'<ol />'
);
}
public function testLiConvertTypeCircle()
{
$this->assertResult(
'<li type="circle" />',
'<li style="list-style-type:circle;" />'
);
}
public function testLiConvertTypeA()
{
$this->assertResult(
'<li type="A" />',
'<li style="list-style-type:upper-alpha;" />'
);
}
public function testLiConvertTypeCaseSensitive()
{
$this->assertResult(
'<li type="CIRCLE" />',
'<li />'
);
}
}
// vim: et sw=4 sts=4