3 class HTMLPurifier_ChildDef_RequiredTest
extends HTMLPurifier_ChildDefHarness
6 function testPrepareString() {
7 $def = new HTMLPurifier_ChildDef_Required('foobar | bang |gizmo');
8 $this->assertIdentical($def->elements
,
16 function testPrepareArray() {
17 $def = new HTMLPurifier_ChildDef_Required(array('href', 'src'));
18 $this->assertIdentical($def->elements
,
27 $this->obj
= new HTMLPurifier_ChildDef_Required('dt | dd');
30 function testEmptyInput() {
31 $this->assertResult('', false);
34 function testRemoveIllegalTagsAndElements() {
36 '<dt>Term</dt>Text in an illegal location'.
37 '<dd>Definition</dd><b>Illegal tag</b>',
38 '<dt>Term</dt><dd>Definition</dd>');
39 $this->assertResult('How do you do!', false);
42 function testIgnoreWhitespace() {
43 // whitespace shouldn't trigger it
44 $this->assertResult("\n<dd>Definition</dd> ");
47 function testPreserveWhitespaceAfterRemoval() {
49 '<dd>Definition</dd> <b></b> ',
50 '<dd>Definition</dd> '
54 function testDeleteNodeIfOnlyWhitespace() {
55 $this->assertResult("\t ", false);
58 function testPCDATAAllowed() {
59 $this->obj
= new HTMLPurifier_ChildDef_Required('#PCDATA | b');
60 $this->assertResult('Out <b>Bold text</b><img />', 'Out <b>Bold text</b>');
63 function testPCDATAAllowedWithEscaping() {
64 $this->obj
= new HTMLPurifier_ChildDef_Required('#PCDATA | b');
65 $this->config
->set('Core', 'EscapeInvalidChildren', true);
67 'Out <b>Bold text</b><img />',
68 'Out <b>Bold text</b><img />'