Fix autoparagraph bug with non-inline elements.
[htmlpurifier.git] / tests / HTMLPurifier / Strategy / ValidateAttributes_TidyTest.php
blobd4eeeebfc24be49479621b6a8c0f29357d4c8c6b
1 <?php
3 class HTMLPurifier_Strategy_ValidateAttributes_TidyTest extends HTMLPurifier_StrategyHarness
6 function setUp() {
7 parent::setUp();
8 $this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
9 $this->config->set('HTML.TidyLevel', 'heavy');
12 function testConvertCenterAlign() {
13 $this->assertResult(
14 '<h1 align="center">Centered Headline</h1>',
15 '<h1 style="text-align:center;">Centered Headline</h1>'
19 function testConvertRightAlign() {
20 $this->assertResult(
21 '<h1 align="right">Right-aligned Headline</h1>',
22 '<h1 style="text-align:right;">Right-aligned Headline</h1>'
26 function testConvertLeftAlign() {
27 $this->assertResult(
28 '<h1 align="left">Left-aligned Headline</h1>',
29 '<h1 style="text-align:left;">Left-aligned Headline</h1>'
33 function testConvertJustifyAlign() {
34 $this->assertResult(
35 '<p align="justify">Justified Paragraph</p>',
36 '<p style="text-align:justify;">Justified Paragraph</p>'
40 function testRemoveInvalidAlign() {
41 $this->assertResult(
42 '<h1 align="invalid">Invalid Headline</h1>',
43 '<h1>Invalid Headline</h1>'
47 function testConvertTableLengths() {
48 $this->assertResult(
49 '<td width="5%" height="10" /><th width="10" height="5%" /><hr width="10" height="10" />',
50 '<td style="width:5%;height:10px;" /><th style="width:10px;height:5%;" /><hr style="width:10px;" />'
54 function testTdConvertNowrap() {
55 $this->assertResult(
56 '<td nowrap />',
57 '<td style="white-space:nowrap;" />'
61 function testCaptionConvertAlignLeft() {
62 $this->assertResult(
63 '<caption align="left" />',
64 '<caption style="text-align:left;" />'
68 function testCaptionConvertAlignRight() {
69 $this->assertResult(
70 '<caption align="right" />',
71 '<caption style="text-align:right;" />'
75 function testCaptionConvertAlignTop() {
76 $this->assertResult(
77 '<caption align="top" />',
78 '<caption style="caption-side:top;" />'
82 function testCaptionConvertAlignBottom() {
83 $this->assertResult(
84 '<caption align="bottom" />',
85 '<caption style="caption-side:bottom;" />'
89 function testCaptionRemoveInvalidAlign() {
90 $this->assertResult(
91 '<caption align="nonsense" />',
92 '<caption />'
96 function testTableConvertAlignLeft() {
97 $this->assertResult(
98 '<table align="left" />',
99 '<table style="float:left;" />'
103 function testTableConvertAlignCenter() {
104 $this->assertResult(
105 '<table align="center" />',
106 '<table style="margin-left:auto;margin-right:auto;" />'
110 function testTableConvertAlignRight() {
111 $this->assertResult(
112 '<table align="right" />',
113 '<table style="float:right;" />'
117 function testTableRemoveInvalidAlign() {
118 $this->assertResult(
119 '<table align="top" />',
120 '<table />'
124 function testImgConvertAlignLeft() {
125 $this->assertResult(
126 '<img src="foobar.jpg" alt="foobar" align="left" />',
127 '<img src="foobar.jpg" alt="foobar" style="float:left;" />'
131 function testImgConvertAlignRight() {
132 $this->assertResult(
133 '<img src="foobar.jpg" alt="foobar" align="right" />',
134 '<img src="foobar.jpg" alt="foobar" style="float:right;" />'
138 function testImgConvertAlignBottom() {
139 $this->assertResult(
140 '<img src="foobar.jpg" alt="foobar" align="bottom" />',
141 '<img src="foobar.jpg" alt="foobar" style="vertical-align:baseline;" />'
145 function testImgConvertAlignMiddle() {
146 $this->assertResult(
147 '<img src="foobar.jpg" alt="foobar" align="middle" />',
148 '<img src="foobar.jpg" alt="foobar" style="vertical-align:middle;" />'
152 function testImgConvertAlignTop() {
153 $this->assertResult(
154 '<img src="foobar.jpg" alt="foobar" align="top" />',
155 '<img src="foobar.jpg" alt="foobar" style="vertical-align:top;" />'
159 function testImgRemoveInvalidAlign() {
160 $this->assertResult(
161 '<img src="foobar.jpg" alt="foobar" align="outerspace" />',
162 '<img src="foobar.jpg" alt="foobar" />'
166 function testBorderConvertHVSpace() {
167 $this->assertResult(
168 '<img src="foo" alt="foo" hspace="1" vspace="3" />',
169 '<img src="foo" alt="foo" style="margin-top:3px;margin-bottom:3px;margin-left:1px;margin-right:1px;" />'
173 function testHrConvertSize() {
174 $this->assertResult(
175 '<hr size="3" />',
176 '<hr style="height:3px;" />'
180 function testHrConvertNoshade() {
181 $this->assertResult(
182 '<hr noshade />',
183 '<hr style="color:#808080;background-color:#808080;border:0;" />'
187 function testHrConvertAlignLeft() {
188 $this->assertResult(
189 '<hr align="left" />',
190 '<hr style="margin-left:0;margin-right:auto;text-align:left;" />'
194 function testHrConvertAlignCenter() {
195 $this->assertResult(
196 '<hr align="center" />',
197 '<hr style="margin-left:auto;margin-right:auto;text-align:center;" />'
201 function testHrConvertAlignRight() {
202 $this->assertResult(
203 '<hr align="right" />',
204 '<hr style="margin-left:auto;margin-right:0;text-align:right;" />'
208 function testHrRemoveInvalidAlign() {
209 $this->assertResult(
210 '<hr align="bottom" />',
211 '<hr />'
215 function testBrConvertClearLeft() {
216 $this->assertResult(
217 '<br clear="left" />',
218 '<br style="clear:left;" />'
222 function testBrConvertClearRight() {
223 $this->assertResult(
224 '<br clear="right" />',
225 '<br style="clear:right;" />'
229 function testBrConvertClearAll() {
230 $this->assertResult(
231 '<br clear="all" />',
232 '<br style="clear:both;" />'
236 function testBrConvertClearNone() {
237 $this->assertResult(
238 '<br clear="none" />',
239 '<br style="clear:none;" />'
243 function testBrRemoveInvalidClear() {
244 $this->assertResult(
245 '<br clear="foo" />',
246 '<br />'
250 function testUlConvertTypeDisc() {
251 $this->assertResult(
252 '<ul type="disc" />',
253 '<ul style="list-style-type:disc;" />'
257 function testUlConvertTypeSquare() {
258 $this->assertResult(
259 '<ul type="square" />',
260 '<ul style="list-style-type:square;" />'
264 function testUlConvertTypeCircle() {
265 $this->assertResult(
266 '<ul type="circle" />',
267 '<ul style="list-style-type:circle;" />'
271 function testUlConvertTypeCaseInsensitive() {
272 $this->assertResult(
273 '<ul type="CIRCLE" />',
274 '<ul style="list-style-type:circle;" />'
278 function testUlRemoveInvalidType() {
279 $this->assertResult(
280 '<ul type="a" />',
281 '<ul />'
285 function testOlConvertType1() {
286 $this->assertResult(
287 '<ol type="1" />',
288 '<ol style="list-style-type:decimal;" />'
292 function testOlConvertTypeLowerI() {
293 $this->assertResult(
294 '<ol type="i" />',
295 '<ol style="list-style-type:lower-roman;" />'
299 function testOlConvertTypeUpperI() {
300 $this->assertResult(
301 '<ol type="I" />',
302 '<ol style="list-style-type:upper-roman;" />'
306 function testOlConvertTypeLowerA() {
307 $this->assertResult(
308 '<ol type="a" />',
309 '<ol style="list-style-type:lower-alpha;" />'
313 function testOlConvertTypeUpperA() {
314 $this->assertResult(
315 '<ol type="A" />',
316 '<ol style="list-style-type:upper-alpha;" />'
320 function testOlRemoveInvalidType() {
321 $this->assertResult(
322 '<ol type="disc" />',
323 '<ol />'
327 function testLiConvertTypeCircle() {
328 $this->assertResult(
329 '<li type="circle" />',
330 '<li style="list-style-type:circle;" />'
334 function testLiConvertTypeA() {
335 $this->assertResult(
336 '<li type="A" />',
337 '<li style="list-style-type:upper-alpha;" />'
341 function testLiConvertTypeCaseSensitive() {
342 $this->assertResult(
343 '<li type="CIRCLE" />',
344 '<li />'
351 // vim: et sw=4 sts=4