mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-31 19:30:21 +02:00
Minor test-case refactoring.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1100 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -11,15 +11,12 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
|
||||
$this->obj = new HTMLPurifier_Strategy_FixNesting();
|
||||
}
|
||||
|
||||
function test() {
|
||||
|
||||
$this->config = array('HTML.Doctype' => 'XHTML 1.0 Strict');
|
||||
function testBlockAndInlineIntegration() {
|
||||
|
||||
// legal inline
|
||||
$this->assertResult('<b>Bold text</b>');
|
||||
|
||||
// legal inline and block
|
||||
// as the parent element is considered FLOW
|
||||
// legal inline and block (default parent element is FLOW)
|
||||
$this->assertResult('<a href="about:blank">Blank</a><div>Block</div>');
|
||||
|
||||
// illegal block in inline
|
||||
@@ -35,6 +32,10 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
|
||||
array('Core.EscapeInvalidChildren' => true)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
function testNodeRemovalIntegration() {
|
||||
|
||||
// test of empty set that's required, resulting in removal of node
|
||||
$this->assertResult('<ul></ul>', '');
|
||||
|
||||
@@ -44,27 +45,17 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
|
||||
'<ul><li>Legal item</li></ul>'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
function testTableIntegration() {
|
||||
// test custom table definition
|
||||
$this->assertResult(
|
||||
'<table><tr><td>Cell 1</td></tr></table>',
|
||||
'<table><tr><td>Cell 1</td></tr></table>'
|
||||
);
|
||||
$this->assertResult('<table></table>', '');
|
||||
|
||||
// breaks without the redundant checking code
|
||||
$this->assertResult('<table><tr></tr></table>', '');
|
||||
|
||||
// special case, prevents scrolling one back to find parent
|
||||
$this->assertResult('<table><tr></tr><tr></tr></table>', '');
|
||||
|
||||
// cascading rollbacks
|
||||
$this->assertResult(
|
||||
'<table><tbody><tr></tr><tr></tr></tbody><tr></tr><tr></tr></table>',
|
||||
''
|
||||
);
|
||||
|
||||
// rollbacks twice
|
||||
$this->assertResult('<table></table><table></table>', '');
|
||||
}
|
||||
|
||||
function testChameleonIntegration() {
|
||||
|
||||
// block in inline ins not allowed
|
||||
$this->assertResult(
|
||||
@@ -84,12 +75,6 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
|
||||
'<h1><ins>Not allowed!</ins></h1>'
|
||||
);
|
||||
|
||||
// test exclusions
|
||||
$this->assertResult(
|
||||
'<a><span><a>Not allowed</a></span></a>',
|
||||
'<a><span></span></a>'
|
||||
);
|
||||
|
||||
// stacked ins/del
|
||||
$this->assertResult(
|
||||
'<h1><ins><del><div>Not allowed!</div></del></ins></h1>',
|
||||
@@ -99,6 +84,17 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
|
||||
'<div><ins><del><div>Allowed!</div></del></ins></div>'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
function testExclusionsIntegration() {
|
||||
// test exclusions
|
||||
$this->assertResult(
|
||||
'<a><span><a>Not allowed</a></span></a>',
|
||||
'<a><span></span></a>'
|
||||
);
|
||||
}
|
||||
|
||||
function testCustomParentIntegration() {
|
||||
// test inline parent
|
||||
$this->assertResult(
|
||||
'<b>Bold</b>', true, array('HTML.Parent' => 'span')
|
||||
@@ -107,13 +103,31 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
|
||||
'<div>Reject</div>', 'Reject', array('HTML.Parent' => 'span')
|
||||
);
|
||||
|
||||
// test fallback to div
|
||||
$this->expectError('Cannot use unrecognized element as parent.');
|
||||
$this->assertResult(
|
||||
'<div>Accept</div>', true, array('HTML.Parent' => 'fling')
|
||||
'<div>Accept</div>', true, array('HTML.Parent' => 'obviously-impossible')
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
function testDoubleCheckIntegration() {
|
||||
// breaks without the redundant checking code
|
||||
$this->assertResult('<table><tr></tr></table>', '');
|
||||
|
||||
// special case, prevents scrolling one back to find parent
|
||||
$this->assertResult('<table><tr></tr><tr></tr></table>', '');
|
||||
|
||||
// cascading rollbacks
|
||||
$this->assertResult(
|
||||
'<table><tbody><tr></tr><tr></tr></tbody><tr></tr><tr></tr></table>',
|
||||
''
|
||||
);
|
||||
|
||||
// rollbacks twice
|
||||
$this->assertResult('<table></table><table></table>', '');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user