2006-11-23 03:23:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_ChildDef_StrictBlockquoteTest
|
|
|
|
extends HTMLPurifier_ChildDefHarness
|
|
|
|
{
|
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
2007-02-04 03:53:57 +00:00
|
|
|
$this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p');
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testEmptyInput() {
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult('');
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testPreserveValidP() {
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult('<p>Valid</p>');
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testPreserveValidDiv() {
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult('<div>Still valid</div>');
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testWrapTextWithP() {
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult('Needs wrap', '<p>Needs wrap</p>');
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testNoWrapForWhitespaceOrValidElements() {
|
2007-06-18 19:53:46 +00:00
|
|
|
$this->assertResult('<p>Do not wrap</p> <p>Whitespace</p>');
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testWrapTextNextToValidElements() {
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Wrap'. '<p>Do not wrap</p>',
|
|
|
|
'<p>Wrap</p><p>Do not wrap</p>'
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testWrapInlineElements() {
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<p>Do not</p>'.'<b>Wrap</b>',
|
|
|
|
'<p>Do not</p><p><b>Wrap</b></p>'
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testWrapAndRemoveInvalidTags() {
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<li>Not allowed</li>Paragraph.<p>Hmm.</p>',
|
|
|
|
'<p>Not allowedParagraph.</p><p>Hmm.</p>'
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testWrapComplicatedSring() {
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult(
|
|
|
|
$var = 'He said<br />perhaps<br />we should <b>nuke</b> them.',
|
|
|
|
"<p>$var</p>"
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testWrapAndRemoveInvalidTagsComplex() {
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<foo>Bar</foo><bas /><b>People</b>Conniving.'. '<p>Fools!</p>',
|
|
|
|
'<p>Bar'. '<b>People</b>Conniving.</p><p>Fools!</p>'
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testAlternateWrapper() {
|
|
|
|
$this->config->set('HTML', 'BlockWrapper', 'div');
|
|
|
|
$this->assertResult('Needs wrap', '<div>Needs wrap</div>');
|
2006-11-23 03:23:35 +00:00
|
|
|
|
2007-06-21 15:15:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testError() {
|
2008-04-15 03:33:09 +00:00
|
|
|
$this->expectError('Cannot use non-block element as block wrapper');
|
2007-06-21 15:15:02 +00:00
|
|
|
$this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p');
|
2007-08-06 06:22:23 +00:00
|
|
|
$this->config->set('HTML', 'BlockWrapper', 'dav');
|
2008-04-15 03:33:09 +00:00
|
|
|
$this->config->set('Cache', 'DefinitionImpl', null);
|
2007-08-06 06:22:23 +00:00
|
|
|
$this->assertResult('Needs wrap', '<p>Needs wrap</p>');
|
2006-11-23 03:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|