Release 2.1.3, merged in 1404 to HEAD.
[htmlpurifier/bfroehle.git] / tests / HTMLPurifier / ChildDef / StrictBlockquoteTest.php
blobe55f96e5ee18bb79a8feeaac1a92995fccdff11e
1 <?php
3 require_once 'HTMLPurifier/ChildDefHarness.php';
4 require_once 'HTMLPurifier/ChildDef/StrictBlockquote.php';
6 class HTMLPurifier_ChildDef_StrictBlockquoteTest
7 extends HTMLPurifier_ChildDefHarness
10 function setUp() {
11 parent::setUp();
12 $this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p');
15 function testEmptyInput() {
16 $this->assertResult('');
19 function testPreserveValidP() {
20 $this->assertResult('<p>Valid</p>');
23 function testPreserveValidDiv() {
24 $this->assertResult('<div>Still valid</div>');
27 function testWrapTextWithP() {
28 $this->assertResult('Needs wrap', '<p>Needs wrap</p>');
31 function testNoWrapForWhitespaceOrValidElements() {
32 $this->assertResult('<p>Do not wrap</p> <p>Whitespace</p>');
35 function testWrapTextNextToValidElements() {
36 $this->assertResult(
37 'Wrap'. '<p>Do not wrap</p>',
38 '<p>Wrap</p><p>Do not wrap</p>'
42 function testWrapInlineElements() {
43 $this->assertResult(
44 '<p>Do not</p>'.'<b>Wrap</b>',
45 '<p>Do not</p><p><b>Wrap</b></p>'
49 function testWrapAndRemoveInvalidTags() {
50 $this->assertResult(
51 '<li>Not allowed</li>Paragraph.<p>Hmm.</p>',
52 '<p>Not allowedParagraph.</p><p>Hmm.</p>'
56 function testWrapComplicatedSring() {
57 $this->assertResult(
58 $var = 'He said<br />perhaps<br />we should <b>nuke</b> them.',
59 "<p>$var</p>"
63 function testWrapAndRemoveInvalidTagsComplex() {
64 $this->assertResult(
65 '<foo>Bar</foo><bas /><b>People</b>Conniving.'. '<p>Fools!</p>',
66 '<p>Bar'. '<b>People</b>Conniving.</p><p>Fools!</p>'
70 function testAlternateWrapper() {
71 $this->config->set('HTML', 'BlockWrapper', 'div');
72 $this->assertResult('Needs wrap', '<div>Needs wrap</div>');
76 function testError() {
77 // $this->expectError('Cannot use non-block element as block wrapper');
78 $this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p');
79 $this->config->set('HTML', 'BlockWrapper', 'dav');
80 $this->assertResult('Needs wrap', '<p>Needs wrap</p>');
81 $this->swallowErrors();