mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-23 00:41:52 +00:00
bb08f679f0
- Work around unnecessary DOMElement type-cast in PH5P that caused errors in PHP 5.1 - Work around PHP 4 SimpleTest lack-of-error complaining for one-time-only HTMLDefinition errors, this may indicate problems with error-collecting facilities in PHP 5 - Make ErrorCollectorEMock work in both PHP 4 and PHP 5 . tests/multitest.php allows you to test multiple versions by running tests/index.php through multiple interpreters using `phpv` shell script (you must provide this script!) . Minor cosmetic change to flush-definition-cache.php: trailing newline is outputted . Maintenance script for generating PH5P patch added, original PH5P source file also added under version control . Full unit test runner script title made more descriptive with PHP version git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1440 48356398-32a2-884e-a903-53898d9a118a
86 lines
2.4 KiB
PHP
86 lines
2.4 KiB
PHP
<?php
|
|
|
|
require_once 'HTMLPurifier/ChildDefHarness.php';
|
|
require_once 'HTMLPurifier/ChildDef/StrictBlockquote.php';
|
|
|
|
class HTMLPurifier_ChildDef_StrictBlockquoteTest
|
|
extends HTMLPurifier_ChildDefHarness
|
|
{
|
|
|
|
function setUp() {
|
|
parent::setUp();
|
|
$this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p');
|
|
}
|
|
|
|
function testEmptyInput() {
|
|
$this->assertResult('');
|
|
}
|
|
|
|
function testPreserveValidP() {
|
|
$this->assertResult('<p>Valid</p>');
|
|
}
|
|
|
|
function testPreserveValidDiv() {
|
|
$this->assertResult('<div>Still valid</div>');
|
|
}
|
|
|
|
function testWrapTextWithP() {
|
|
$this->assertResult('Needs wrap', '<p>Needs wrap</p>');
|
|
}
|
|
|
|
function testNoWrapForWhitespaceOrValidElements() {
|
|
$this->assertResult('<p>Do not wrap</p> <p>Whitespace</p>');
|
|
}
|
|
|
|
function testWrapTextNextToValidElements() {
|
|
$this->assertResult(
|
|
'Wrap'. '<p>Do not wrap</p>',
|
|
'<p>Wrap</p><p>Do not wrap</p>'
|
|
);
|
|
}
|
|
|
|
function testWrapInlineElements() {
|
|
$this->assertResult(
|
|
'<p>Do not</p>'.'<b>Wrap</b>',
|
|
'<p>Do not</p><p><b>Wrap</b></p>'
|
|
);
|
|
}
|
|
|
|
function testWrapAndRemoveInvalidTags() {
|
|
$this->assertResult(
|
|
'<li>Not allowed</li>Paragraph.<p>Hmm.</p>',
|
|
'<p>Not allowedParagraph.</p><p>Hmm.</p>'
|
|
);
|
|
}
|
|
|
|
function testWrapComplicatedSring() {
|
|
$this->assertResult(
|
|
$var = 'He said<br />perhaps<br />we should <b>nuke</b> them.',
|
|
"<p>$var</p>"
|
|
);
|
|
}
|
|
|
|
function testWrapAndRemoveInvalidTagsComplex() {
|
|
$this->assertResult(
|
|
'<foo>Bar</foo><bas /><b>People</b>Conniving.'. '<p>Fools!</p>',
|
|
'<p>Bar'. '<b>People</b>Conniving.</p><p>Fools!</p>'
|
|
);
|
|
}
|
|
|
|
function testAlternateWrapper() {
|
|
$this->config->set('HTML', 'BlockWrapper', 'div');
|
|
$this->assertResult('Needs wrap', '<div>Needs wrap</div>');
|
|
|
|
}
|
|
|
|
function testError() {
|
|
// $this->expectError('Cannot use non-block element as block wrapper');
|
|
$this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p');
|
|
$this->config->set('HTML', 'BlockWrapper', 'dav');
|
|
$this->assertResult('Needs wrap', '<p>Needs wrap</p>');
|
|
$this->swallowErrors();
|
|
}
|
|
|
|
}
|
|
|