Add vim modelines to all files.
[htmlpurifier.git] / tests / HTMLPurifier / ChildDef / RequiredTest.php
blobf8d23075947dfcdf314dbe96c53810fdeb6ce0e8
1 <?php
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,
9 array(
10 'foobar' => true
11 ,'bang' => true
12 ,'gizmo' => true
13 ));
16 function testPrepareArray() {
17 $def = new HTMLPurifier_ChildDef_Required(array('href', 'src'));
18 $this->assertIdentical($def->elements,
19 array(
20 'href' => true
21 ,'src' => true
22 ));
25 function setUp() {
26 parent::setUp();
27 $this->obj = new HTMLPurifier_ChildDef_Required('dt | dd');
30 function testEmptyInput() {
31 $this->assertResult('', false);
34 function testRemoveIllegalTagsAndElements() {
35 $this->assertResult(
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() {
48 $this->assertResult(
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);
66 $this->assertResult(
67 'Out <b>Bold text</b><img />',
68 'Out <b>Bold text</b>&lt;img /&gt;'
73 // vim: et sw=4 sts=4