2006-11-23 03:23:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_ChildDef_StrictBlockquoteTest
|
|
|
|
extends HTMLPurifier_ChildDefHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function setUp()
|
|
|
|
{
|
2007-08-06 06:22:23 +00:00
|
|
|
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
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testEmptyInput()
|
|
|
|
{
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult('');
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testPreserveValidP()
|
|
|
|
{
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult('<p>Valid</p>');
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testPreserveValidDiv()
|
|
|
|
{
|
2006-11-23 03:23:35 +00:00
|
|
|
$this->assertResult('<div>Still valid</div>');
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public 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
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public 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
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public 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
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public 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
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public 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
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public 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
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public 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
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testAlternateWrapper()
|
|
|
|
{
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('HTML.BlockWrapper', 'div');
|
2007-08-06 06:22:23 +00:00
|
|
|
$this->assertResult('Needs wrap', '<div>Needs wrap</div>');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-21 15:15:02 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public 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');
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('HTML.BlockWrapper', 'dav');
|
|
|
|
$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
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-11-23 03:23:35 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|