2006-11-23 03:23:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/ChildDefHarness.php';
|
|
|
|
require_once 'HTMLPurifier/ChildDef/StrictBlockquote.php';
|
|
|
|
|
|
|
|
class HTMLPurifier_ChildDef_StrictBlockquoteTest
|
|
|
|
extends HTMLPurifier_ChildDefHarness
|
|
|
|
{
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
|
2007-02-04 03:53:57 +00:00
|
|
|
$this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p');
|
2006-11-23 03:23:35 +00:00
|
|
|
|
2007-06-18 19:53:46 +00:00
|
|
|
// assuming default wrap is p
|
|
|
|
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult('');
|
|
|
|
$this->assertResult('<p>Valid</p>');
|
|
|
|
$this->assertResult('<div>Still valid</div>');
|
|
|
|
$this->assertResult('Needs wrap', '<p>Needs wrap</p>');
|
2007-06-18 19:53:46 +00:00
|
|
|
$this->assertResult('<p>Do not wrap</p> <p>Whitespace</p>');
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Wrap'. '<p>Do not wrap</p>',
|
|
|
|
'<p>Wrap</p><p>Do not wrap</p>'
|
|
|
|
);
|
|
|
|
$this->assertResult(
|
|
|
|
'<p>Do not</p>'.'<b>Wrap</b>',
|
|
|
|
'<p>Do not</p><p><b>Wrap</b></p>'
|
|
|
|
);
|
|
|
|
$this->assertResult(
|
|
|
|
'<li>Not allowed</li>Paragraph.<p>Hmm.</p>',
|
|
|
|
'<p>Not allowedParagraph.</p><p>Hmm.</p>'
|
|
|
|
);
|
|
|
|
$this->assertResult(
|
|
|
|
$var = 'He said<br />perhaps<br />we should <b>nuke</b> them.',
|
|
|
|
"<p>$var</p>"
|
|
|
|
);
|
|
|
|
$this->assertResult(
|
|
|
|
'<foo>Bar</foo><bas /><b>People</b>Conniving.'. '<p>Fools!</p>',
|
|
|
|
'<p>Bar'. '<b>People</b>Conniving.</p><p>Fools!</p>'
|
|
|
|
);
|
2007-06-18 19:53:46 +00:00
|
|
|
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult('Needs wrap', '<div>Needs wrap</div>',
|
|
|
|
array('HTML.BlockWrapper' => 'div'));
|
|
|
|
|
2007-06-21 15:15:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testError() {
|
|
|
|
$this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p');
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult('Needs wrap', '<p>Needs wrap</p>',
|
|
|
|
array('HTML.BlockWrapper' => 'dav'));
|
2007-06-21 15:15:02 +00:00
|
|
|
$this->swallowErrors();
|
2006-11-23 03:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|