Add test case for removing empty list items.
[htmlpurifier.git] / tests / HTMLPurifier / Injector / RemoveEmptyTest.php
blob4a976acf0778b15546e7c7a715b4d5a5f25a0cc9
1 <?php
3 class HTMLPurifier_Injector_RemoveEmptyTest extends HTMLPurifier_InjectorHarness
6 public function setup()
8 parent::setup();
9 $this->config->set('AutoFormat.RemoveEmpty', true);
12 public function testPreserve()
14 $this->assertResult('<b>asdf</b>');
17 public function testRemove()
19 $this->assertResult('<b></b>', '');
22 public function testRemoveWithSpace()
24 $this->assertResult('<b> </b>', '');
27 public function testRemoveWithAttr()
29 $this->assertResult('<b class="asdf"></b>', '');
32 public function testRemoveIdAndName()
34 $this->assertResult('<a id="asdf" name="asdf"></a>', '');
37 public function testPreserveColgroup()
39 $this->assertResult('<colgroup></colgroup>');
42 public function testPreserveId()
44 $this->config->set('Attr.EnableID', true);
45 $this->assertResult('<a id="asdf"></a>');
48 public function testPreserveName()
50 $this->config->set('Attr.EnableID', true);
51 $this->assertResult('<a name="asdf"></a>');
54 public function testRemoveNested()
56 $this->assertResult('<b><i></i></b>', '');
59 public function testRemoveNested2()
61 $this->assertResult('<b><i><u></u></i></b>', '');
64 public function testRemoveNested3()
66 $this->assertResult('<b> <i> <u> </u> </i> </b>', '');
69 public function testRemoveNbsp()
71 $this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
72 $this->assertResult('<b>&nbsp;</b>', '');
75 public function testRemoveNbspMix()
77 $this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
78 $this->assertResult('<b>&nbsp; &nbsp;</b>', '');
81 public function testRemoveLi()
83 $this->assertResult("<ul><li>\n\n\n</li></ul>", '');
86 public function testDontRemoveNbsp()
88 $this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
89 $this->assertResult('<td>&nbsp;</b>', "<td>\xC2\xA0</td>");
92 public function testRemoveNbspExceptionsSpecial()
94 $this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
95 $this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions', 'b');
96 $this->assertResult('<b>&nbsp;</b>', "<b>\xC2\xA0</b>");
99 public function testRemoveIframe()
101 $this->config->set('HTML.SafeIframe', true);
102 $this->assertResult('<iframe></iframe>', '');
105 public function testNoRemoveIframe()
107 $this->config->set('HTML.SafeIframe', true);
108 $this->assertResult('<iframe src="http://google.com"></iframe>', '');
111 public function testRemoveDisallowedIframe()
113 $this->config->set('HTML.SafeIframe', true);
114 $this->config->set('URI.SafeIframeRegexp', '%^http://www.youtube.com/embed/%');
115 $this->assertResult('<iframe src="http://google.com"></iframe>', '');
120 // vim: et sw=4 sts=4