Add AutoFormat.RemoveEmpty.Predicate, fixes #35.
[htmlpurifier.git] / tests / HTMLPurifier / Injector / RemoveEmptyTest.php
blobd719ba8a12474bca7cf809e08874d1ad4c38636d
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 testDontRemoveNbsp()
83 $this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
84 $this->assertResult('<td>&nbsp;</b>', "<td>\xC2\xA0</td>");
87 public function testRemoveNbspExceptionsSpecial()
89 $this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
90 $this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions', 'b');
91 $this->assertResult('<b>&nbsp;</b>', "<b>\xC2\xA0</b>");
94 public function testRemoveIframe()
96 $this->config->set('HTML.SafeIframe', true);
97 $this->assertResult('<iframe></iframe>', '');
100 public function testNoRemoveIframe()
102 $this->config->set('HTML.SafeIframe', true);
103 $this->assertResult('<iframe src="http://google.com"></iframe>', '');
106 public function testRemoveDisallowedIframe()
108 $this->config->set('HTML.SafeIframe', true);
109 $this->config->set('URI.SafeIframeRegexp', '%^http://www.youtube.com/embed/%');
110 $this->assertResult('<iframe src="http://google.com"></iframe>', '');
115 // vim: et sw=4 sts=4