Fix infinite loop involving wrapping formedness.
[htmlpurifier.git] / tests / HTMLPurifier / Strategy / MakeWellFormedTest.php
blobab4bf9c2001001444f0e44008cc60d1b607ff3a6
1 <?php
3 class HTMLPurifier_Strategy_MakeWellFormedTest extends HTMLPurifier_StrategyHarness
6 function setUp() {
7 parent::setUp();
8 $this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
11 function testEmptyInput() {
12 $this->assertResult('');
15 function testWellFormedInput() {
16 $this->assertResult('This is <b>bold text</b>.');
19 function testUnclosedTagTerminatedByDocumentEnd() {
20 $this->assertResult(
21 '<b>Unclosed tag, gasp!',
22 '<b>Unclosed tag, gasp!</b>'
26 function testUnclosedTagTerminatedByParentNodeEnd() {
27 $this->assertResult(
28 '<b><i>Bold and italic?</b>',
29 '<b><i>Bold and italic?</i></b><i></i>'
33 function testRemoveStrayClosingTag() {
34 $this->assertResult(
35 'Unused end tags... recycle!</b>',
36 'Unused end tags... recycle!'
40 function testConvertStartToEmpty() {
41 $this->assertResult(
42 '<br style="clear:both;">',
43 '<br style="clear:both;" />'
47 function testConvertEmptyToStart() {
48 $this->assertResult(
49 '<div style="clear:both;" />',
50 '<div style="clear:both;"></div>'
54 function testAutoCloseParagraph() {
55 $this->assertResult(
56 '<p>Paragraph 1<p>Paragraph 2',
57 '<p>Paragraph 1</p><p>Paragraph 2</p>'
61 function testAutoCloseParagraphInsideDiv() {
62 $this->assertResult(
63 '<div><p>Paragraphs<p>In<p>A<p>Div</div>',
64 '<div><p>Paragraphs</p><p>In</p><p>A</p><p>Div</p></div>'
68 function testAutoCloseListItem() {
69 $this->assertResult(
70 '<ol><li>Item 1<li>Item 2</ol>',
71 '<ol><li>Item 1</li><li>Item 2</li></ol>'
75 function testAutoCloseColgroup() {
76 $this->assertResult(
77 '<table><colgroup><col /><tr></tr></table>',
78 '<table><colgroup><col /></colgroup><tr></tr></table>'
82 function testAutoCloseMultiple() {
83 $this->assertResult(
84 '<b><span><div></div>asdf',
85 '<b><span></span></b><div><b></b></div><b>asdf</b>'
89 function testUnrecognized() {
90 $this->assertResult(
91 '<asdf><foobar /><biddles>foo</asdf>',
92 '<asdf><foobar /><biddles>foo</biddles></asdf>'
96 function testBlockquoteWithInline() {
97 $this->config->set('HTML.Doctype', 'XHTML 1.0 Strict');
98 $this->assertResult(
99 // This is actually invalid, but will be fixed by
100 // ChildDef_StrictBlockquote
101 '<blockquote>foo<b>bar</b></blockquote>'
105 function testLongCarryOver() {
106 $this->assertResult(
107 '<b>asdf<div>asdf<i>df</i></div>asdf</b>',
108 '<b>asdf</b><div><b>asdf<i>df</i></b></div><b>asdf</b>'
112 function testInterleaved() {
113 $this->assertResult(
114 '<u>foo<i>bar</u>baz</i>',
115 '<u>foo<i>bar</i></u><i>baz</i>'
119 function testNestedOl() {
120 $this->assertResult(
121 '<ol><ol><li>foo</li></ol></ol>',
122 '<ol><li><ol><li>foo</li></ol></li></ol>'
126 function testNestedUl() {
127 $this->assertResult(
128 '<ul><ul></ul></ul>',
129 '<ul><li><ul></ul></li></ul>'
133 function testNestedOlWithStrangeEnding() {
134 $this->assertResult(
135 '<ol><li><ol><ol><li>foo</li></ol></li><li>foo</li></ol>',
136 '<ol><li><ol><li><ol><li>foo</li></ol></li><li>foo</li></ol></li></ol>'
142 // vim: et sw=4 sts=4