Update to work with Git version of SimpleTest.
[htmlpurifier.git] / tests / HTMLPurifier / Strategy / MakeWellFormedTest.php
blob20b65d3efcf2c7915028e95eb4e920706e44817f
1 <?php
3 class HTMLPurifier_Strategy_MakeWellFormedTest extends HTMLPurifier_StrategyHarness
6 public function setUp()
8 parent::setUp();
9 $this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
12 public function testEmptyInput()
14 $this->assertResult('');
17 public function testWellFormedInput()
19 $this->assertResult('This is <b>bold text</b>.');
22 public function testUnclosedTagTerminatedByDocumentEnd()
24 $this->assertResult(
25 '<b>Unclosed tag, gasp!',
26 '<b>Unclosed tag, gasp!</b>'
30 public function testUnclosedTagTerminatedByParentNodeEnd()
32 $this->assertResult(
33 '<b><i>Bold and italic?</b>',
34 '<b><i>Bold and italic?</i></b><i></i>'
38 public function testRemoveStrayClosingTag()
40 $this->assertResult(
41 'Unused end tags... recycle!</b>',
42 'Unused end tags... recycle!'
46 public function testConvertStartToEmpty()
48 $this->assertResult(
49 '<br style="clear:both;">',
50 '<br style="clear:both;" />'
54 public function testConvertEmptyToStart()
56 $this->assertResult(
57 '<div style="clear:both;" />',
58 '<div style="clear:both;"></div>'
62 public function testAutoCloseParagraph()
64 $this->assertResult(
65 '<p>Paragraph 1<p>Paragraph 2',
66 '<p>Paragraph 1</p><p>Paragraph 2</p>'
70 public function testAutoCloseParagraphInsideDiv()
72 $this->assertResult(
73 '<div><p>Paragraphs<p>In<p>A<p>Div</div>',
74 '<div><p>Paragraphs</p><p>In</p><p>A</p><p>Div</p></div>'
78 public function testAutoCloseListItem()
80 $this->assertResult(
81 '<ol><li>Item 1<li>Item 2</ol>',
82 '<ol><li>Item 1</li><li>Item 2</li></ol>'
86 public function testAutoCloseColgroup()
88 $this->assertResult(
89 '<table><colgroup><col /><tr></tr></table>',
90 '<table><colgroup><col /></colgroup><tr></tr></table>'
94 public function testAutoCloseMultiple()
96 $this->assertResult(
97 '<b><span><div></div>asdf',
98 '<b><span></span></b><div><b></b></div><b>asdf</b>'
102 public function testUnrecognized()
104 $this->assertResult(
105 '<asdf><foobar /><biddles>foo</asdf>',
106 '<asdf><foobar /><biddles>foo</biddles></asdf>'
110 public function testBlockquoteWithInline()
112 $this->config->set('HTML.Doctype', 'XHTML 1.0 Strict');
113 $this->assertResult(
114 // This is actually invalid, but will be fixed by
115 // ChildDef_StrictBlockquote
116 '<blockquote>foo<b>bar</b></blockquote>'
120 public function testLongCarryOver()
122 $this->assertResult(
123 '<b>asdf<div>asdf<i>df</i></div>asdf</b>',
124 '<b>asdf</b><div><b>asdf<i>df</i></b></div><b>asdf</b>'
128 public function testInterleaved()
130 $this->assertResult(
131 '<u>foo<i>bar</u>baz</i>',
132 '<u>foo<i>bar</i></u><i>baz</i>'
136 public function testNestedOl()
138 $this->assertResult(
139 '<ol><ol><li>foo</li></ol></ol>',
140 '<ol><ol><li>foo</li></ol></ol>'
144 public function testNestedUl()
146 $this->assertResult(
147 '<ul><ul><li>foo</li></ul></ul>',
148 '<ul><ul><li>foo</li></ul></ul>'
152 public function testNestedOlWithStrangeEnding()
154 $this->assertResult(
155 '<ol><li><ol><ol><li>foo</li></ol></li><li>foo</li></ol>',
156 '<ol><li><ol><ol><li>foo</li></ol></ol></li><li>foo</li></ol>'
160 public function testNoAutocloseIfNoParentsCanAccomodateTag()
162 $this->assertResult(
163 '<table><tr><td><li>foo</li></td></tr></table>',
164 '<table><tr><td>foo</td></tr></table>'
170 // vim: et sw=4 sts=4