From 7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 12 May 2012 17:57:41 -0700 Subject: some important stuff we'll need --- .../tests/HTMLPurifier/Strategy/FixNestingTest.php | 144 +++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 lib/htmlpurifier/tests/HTMLPurifier/Strategy/FixNestingTest.php (limited to 'lib/htmlpurifier/tests/HTMLPurifier/Strategy/FixNestingTest.php') diff --git a/lib/htmlpurifier/tests/HTMLPurifier/Strategy/FixNestingTest.php b/lib/htmlpurifier/tests/HTMLPurifier/Strategy/FixNestingTest.php new file mode 100644 index 000000000..9394352ec --- /dev/null +++ b/lib/htmlpurifier/tests/HTMLPurifier/Strategy/FixNestingTest.php @@ -0,0 +1,144 @@ +obj = new HTMLPurifier_Strategy_FixNesting(); + } + + function testPreserveInlineInRoot() { + $this->assertResult('Bold text'); + } + + function testPreserveInlineAndBlockInRoot() { + $this->assertResult('Blank
Block
'); + } + + function testRemoveBlockInInline() { + $this->assertResult( + '
Illegal div.
', + 'Illegal div.' + ); + } + + function testEscapeBlockInInline() { + $this->config->set('Core.EscapeInvalidChildren', true); + $this->assertResult( + '
Illegal div.
', + '<div>Illegal div.</div>' + ); + } + + function testRemoveNodeWithMissingRequiredElements() { + $this->assertResult('', ''); + } + + function testListHandleIllegalPCDATA() { + $this->assertResult( + '', + '' + ); + } + + function testRemoveIllegalPCDATA() { + $this->assertResult( + 'Illegal text
', + '
' + ); + } + + function testCustomTableDefinition() { + $this->assertResult('
Cell 1
'); + } + + function testRemoveEmptyTable() { + $this->assertResult('
', ''); + } + + function testChameleonRemoveBlockInNodeInInline() { + $this->assertResult( + '
Not allowed!
', + 'Not allowed!' + ); + } + + function testChameleonRemoveBlockInBlockNodeWithInlineContent() { + $this->assertResult( + '

Not allowed!

', + '

Not allowed!

' + ); + } + + function testNestedChameleonRemoveBlockInNodeWithInlineContent() { + $this->assertResult( + '

Not allowed!

', + '

Not allowed!

' + ); + } + + function testNestedChameleonPreserveBlockInBlock() { + $this->assertResult( + '
Allowed!
' + ); + } + + function testChameleonEscapeInvalidBlockInInline() { + $this->config->set('Core.EscapeInvalidChildren', true); + $this->assertResult( // alt config + '
Not allowed!
', + '<div>Not allowed!</div>' + ); + } + + function testExclusionsIntegration() { + // test exclusions + $this->assertResult( + 'Not allowed', + '' + ); + } + + function testPreserveInlineNodeInInlineRootNode() { + $this->config->set('HTML.Parent', 'span'); + $this->assertResult('Bold'); + } + + function testRemoveBlockNodeInInlineRootNode() { + $this->config->set('HTML.Parent', 'span'); + $this->assertResult('
Reject
', 'Reject'); + } + + function testInvalidParentError() { + // test fallback to div + $this->config->set('HTML.Parent', 'obviously-impossible'); + $this->config->set('Cache.DefinitionImpl', null); + $this->expectError('Cannot use unrecognized element as parent'); + $this->assertResult('
Accept
'); + } + + function testCascadingRemovalOfNodesMissingRequiredChildren() { + $this->assertResult('
', ''); + } + + function testCascadingRemovalSpecialCaseCannotScrollOneBack() { + $this->assertResult('
', ''); + } + + function testLotsOfCascadingRemovalOfNodes() { + $this->assertResult('
', ''); + } + + function testAdjacentRemovalOfNodeMissingRequiredChildren() { + $this->assertResult('
', ''); + } + + function testStrictBlockquoteInHTML401() { + $this->config->set('HTML.Doctype', 'HTML 4.01 Strict'); + $this->assertResult('
text
', '

text

'); + } + +} + +// vim: et sw=4 sts=4 -- cgit v1.2.3