1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-06 14:16:32 +02:00

PSR-2 reformatting PHPDoc corrections

With minor corrections.

Signed-off-by: Marcus Bointon <marcus@synchromedia.co.uk>
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
Marcus Bointon
2013-07-16 13:56:14 +02:00
committed by Edward Z. Yang
parent 19eee14899
commit fac747bdbd
433 changed files with 13302 additions and 6690 deletions

View File

@@ -4,7 +4,8 @@ class HTMLPurifier_Strategy_Composite_Test
extends HTMLPurifier_Strategy_Composite
{
public function __construct(&$strategies) {
public function __construct(&$strategies)
{
$this->strategies =& $strategies;
}
@@ -14,8 +15,8 @@ class HTMLPurifier_Strategy_Composite_Test
class HTMLPurifier_Strategy_CompositeTest extends HTMLPurifier_Harness
{
function test() {
public function test()
{
generate_mock_once('HTMLPurifier_Strategy');
generate_mock_once('HTMLPurifier_Config');
generate_mock_once('HTMLPurifier_Context');

View File

@@ -3,37 +3,43 @@
class HTMLPurifier_Strategy_CoreTest extends HTMLPurifier_StrategyHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_Core();
}
function testBlankInput() {
public function testBlankInput()
{
$this->assertResult('');
}
function testMakeWellFormed() {
public function testMakeWellFormed()
{
$this->assertResult(
'<b>Make well formed.',
'<b>Make well formed.</b>'
);
}
function testFixNesting() {
public function testFixNesting()
{
$this->assertResult(
'<b><div>Fix nesting.</div></b>',
'<b></b><div><b>Fix nesting.</b></div><b></b>'
);
}
function testRemoveForeignElements() {
public function testRemoveForeignElements()
{
$this->assertResult(
'<asdf>Foreign element removal.</asdf>',
'Foreign element removal.'
);
}
function testFirstThree() {
public function testFirstThree()
{
$this->assertResult(
'<foo><b><div>All three.</div></b>',
'<b></b><div><b>All three.</b></div><b></b>'

View File

@@ -6,7 +6,8 @@ class HTMLPurifier_Strategy_ErrorsHarness extends HTMLPurifier_ErrorsHarness
// needs to be defined
protected function getStrategy() {}
protected function invoke($input) {
protected function invoke($input)
{
$strategy = $this->getStrategy();
$lexer = new HTMLPurifier_Lexer_DirectLex();
$tokens = $lexer->tokenizeHTML($input, $this->config, $this->context);

View File

@@ -3,27 +3,32 @@
class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_FixNesting();
}
function testPreserveInlineInRoot() {
public function testPreserveInlineInRoot()
{
$this->assertResult('<b>Bold text</b>');
}
function testPreserveInlineAndBlockInRoot() {
public function testPreserveInlineAndBlockInRoot()
{
$this->assertResult('<a href="about:blank">Blank</a><div>Block</div>');
}
function testRemoveBlockInInline() {
public function testRemoveBlockInInline()
{
$this->assertResult(
'<b><div>Illegal div.</div></b>',
'<b>Illegal div.</b>'
);
}
function testEscapeBlockInInline() {
public function testEscapeBlockInInline()
{
$this->config->set('Core.EscapeInvalidChildren', true);
$this->assertResult(
'<b><div>Illegal div.</div></b>',
@@ -31,60 +36,70 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
);
}
function testRemoveNodeWithMissingRequiredElements() {
public function testRemoveNodeWithMissingRequiredElements()
{
$this->assertResult('<ul></ul>', '');
}
function testListHandleIllegalPCDATA() {
public function testListHandleIllegalPCDATA()
{
$this->assertResult(
'<ul>Illegal text<li>Legal item</li></ul>',
'<ul><li>Illegal text</li><li>Legal item</li></ul>'
);
}
function testRemoveIllegalPCDATA() {
public function testRemoveIllegalPCDATA()
{
$this->assertResult(
'<table><tr>Illegal text<td></td></tr></table>',
'<table><tr><td></td></tr></table>'
);
}
function testCustomTableDefinition() {
public function testCustomTableDefinition()
{
$this->assertResult('<table><tr><td>Cell 1</td></tr></table>');
}
function testRemoveEmptyTable() {
public function testRemoveEmptyTable()
{
$this->assertResult('<table></table>', '');
}
function testChameleonRemoveBlockInNodeInInline() {
public function testChameleonRemoveBlockInNodeInInline()
{
$this->assertResult(
'<span><ins><div>Not allowed!</div></ins></span>',
'<span><ins>Not allowed!</ins></span>'
);
}
function testChameleonRemoveBlockInBlockNodeWithInlineContent() {
public function testChameleonRemoveBlockInBlockNodeWithInlineContent()
{
$this->assertResult(
'<h1><ins><div>Not allowed!</div></ins></h1>',
'<h1><ins>Not allowed!</ins></h1>'
);
}
function testNestedChameleonRemoveBlockInNodeWithInlineContent() {
public function testNestedChameleonRemoveBlockInNodeWithInlineContent()
{
$this->assertResult(
'<h1><ins><del><div>Not allowed!</div></del></ins></h1>',
'<h1><ins><del>Not allowed!</del></ins></h1>'
);
}
function testNestedChameleonPreserveBlockInBlock() {
public function testNestedChameleonPreserveBlockInBlock()
{
$this->assertResult(
'<div><ins><del><div>Allowed!</div></del></ins></div>'
);
}
function testChameleonEscapeInvalidBlockInInline() {
public function testChameleonEscapeInvalidBlockInInline()
{
$this->config->set('Core.EscapeInvalidChildren', true);
$this->assertResult( // alt config
'<span><ins><div>Not allowed!</div></ins></span>',
@@ -92,7 +107,8 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
);
}
function testExclusionsIntegration() {
public function testExclusionsIntegration()
{
// test exclusions
$this->assertResult(
'<a><span><a>Not allowed</a></span></a>',
@@ -100,17 +116,20 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
);
}
function testPreserveInlineNodeInInlineRootNode() {
public function testPreserveInlineNodeInInlineRootNode()
{
$this->config->set('HTML.Parent', 'span');
$this->assertResult('<b>Bold</b>');
}
function testRemoveBlockNodeInInlineRootNode() {
public function testRemoveBlockNodeInInlineRootNode()
{
$this->config->set('HTML.Parent', 'span');
$this->assertResult('<div>Reject</div>', 'Reject');
}
function testInvalidParentError() {
public function testInvalidParentError()
{
// test fallback to div
$this->config->set('HTML.Parent', 'obviously-impossible');
$this->config->set('Cache.DefinitionImpl', null);
@@ -118,28 +137,34 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
$this->assertResult('<div>Accept</div>');
}
function testCascadingRemovalOfNodesMissingRequiredChildren() {
public function testCascadingRemovalOfNodesMissingRequiredChildren()
{
$this->assertResult('<table><tr></tr></table>', '');
}
function testCascadingRemovalSpecialCaseCannotScrollOneBack() {
public function testCascadingRemovalSpecialCaseCannotScrollOneBack()
{
$this->assertResult('<table><tr></tr><tr></tr></table>', '');
}
function testLotsOfCascadingRemovalOfNodes() {
public function testLotsOfCascadingRemovalOfNodes()
{
$this->assertResult('<table><tbody><tr></tr><tr></tr></tbody><tr></tr><tr></tr></table>', '');
}
function testAdjacentRemovalOfNodeMissingRequiredChildren() {
public function testAdjacentRemovalOfNodeMissingRequiredChildren()
{
$this->assertResult('<table></table><table></table>', '');
}
function testStrictBlockquoteInHTML401() {
public function testStrictBlockquoteInHTML401()
{
$this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
$this->assertResult('<blockquote>text</blockquote>', '<blockquote><p>text</p></blockquote>');
}
function testDisabledExcludes() {
public function testDisabledExcludes()
{
$this->config->set('Core.DisableExcludes', true);
$this->assertResult('<pre><font><font></font></font></pre>');
}

View File

@@ -3,34 +3,40 @@
class HTMLPurifier_Strategy_FixNesting_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness
{
protected function getStrategy() {
protected function getStrategy()
{
return new HTMLPurifier_Strategy_FixNesting();
}
function testNodeRemoved() {
public function testNodeRemoved()
{
$this->expectErrorCollection(E_ERROR, 'Strategy_FixNesting: Node removed');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('ul', array(), 1));
$this->invoke('<ul></ul>');
}
function testNodeExcluded() {
public function testNodeExcluded()
{
$this->expectErrorCollection(E_ERROR, 'Strategy_FixNesting: Node excluded');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('a', array(), 2));
$this->invoke("<a>\n<a></a></a>");
}
function testNodeReorganized() {
public function testNodeReorganized()
{
$this->expectErrorCollection(E_WARNING, 'Strategy_FixNesting: Node reorganized');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('span', array(), 1));
$this->invoke("<span>Valid<div>Invalid</div></span>");
}
function testNoNodeReorganizedForEmptyNode() {
public function testNoNodeReorganizedForEmptyNode()
{
$this->expectNoErrorCollection();
$this->invoke("<span></span>");
}
function testNodeContentsRemoved() {
public function testNodeContentsRemoved()
{
$this->expectErrorCollection(E_ERROR, 'Strategy_FixNesting: Node contents removed');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('span', array(), 1));
$this->invoke("<span><div></div></span>");

View File

@@ -4,7 +4,8 @@ class HTMLPurifier_Strategy_MakeWellFormed_EndInsertInjector extends HTMLPurifie
{
public $name = 'EndInsertInjector';
public $needed = array('span');
public function handleEnd(&$token) {
public function handleEnd(&$token)
{
if ($token->name == 'div') return;
$token = array(
new HTMLPurifier_Token_Start('b'),

View File

@@ -2,35 +2,44 @@
class HTMLPurifier_Strategy_MakeWellFormed_EndInsertInjectorTest extends HTMLPurifier_StrategyHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
$this->config->set('AutoFormat.Custom', array(
new HTMLPurifier_Strategy_MakeWellFormed_EndInsertInjector()
));
}
function testEmpty() {
public function testEmpty()
{
$this->assertResult('');
}
function testNormal() {
public function testNormal()
{
$this->assertResult('<i>Foo</i>', '<i>Foo<b>Comment</b></i>');
}
function testEndOfDocumentProcessing() {
public function testEndOfDocumentProcessing()
{
$this->assertResult('<i>Foo', '<i>Foo<b>Comment</b></i>');
}
function testDoubleEndOfDocumentProcessing() {
public function testDoubleEndOfDocumentProcessing()
{
$this->assertResult('<i><i>Foo', '<i><i>Foo<b>Comment</b></i><b>Comment</b></i>');
}
function testEndOfNodeProcessing() {
public function testEndOfNodeProcessing()
{
$this->assertResult('<div><i>Foo</div>asdf', '<div><i>Foo<b>Comment</b></i></div><i>asdf<b>Comment</b></i>');
}
function testEmptyToStartEndProcessing() {
public function testEmptyToStartEndProcessing()
{
$this->assertResult('<i />', '<i><b>Comment</b></i>');
}
function testSpuriousEndTag() {
public function testSpuriousEndTag()
{
$this->assertResult('</i>', '');
}
function testLessButStillSpuriousEndTag() {
public function testLessButStillSpuriousEndTag()
{
$this->assertResult('<div></i></div>', '<div></div>');
}
}

View File

@@ -4,15 +4,18 @@ class HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjector extends HTMLPurifie
{
public $name = 'EndRewindInjector';
public $needed = array('span');
public function handleElement(&$token) {
public function handleElement(&$token)
{
if (isset($token->_InjectorTest_EndRewindInjector_delete)) {
$token = false;
}
}
public function handleText(&$token) {
public function handleText(&$token)
{
$token = false;
}
public function handleEnd(&$token) {
public function handleEnd(&$token)
{
$i = null;
if (
$this->backward($i, $prev) &&

View File

@@ -2,26 +2,32 @@
class HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjectorTest extends HTMLPurifier_StrategyHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
$this->config->set('AutoFormat.Custom', array(
new HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjector()
));
}
function testBasic() {
public function testBasic()
{
$this->assertResult('');
}
function testFunction() {
public function testFunction()
{
$this->assertResult('<span>asdf</span>','');
}
function testFailedFunction() {
public function testFailedFunction()
{
$this->assertResult('<span>asd<b>asdf</b>asdf</span>','<span><b></b></span>');
}
function testPadded() {
public function testPadded()
{
$this->assertResult('<b></b><span>asdf</span><b></b>','<b></b><b></b>');
}
function testDoubled() {
public function testDoubled()
{
$this->config->set('AutoFormat.Custom', array(
new HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjector(),
new HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjector(),

View File

@@ -4,7 +4,8 @@ class HTMLPurifier_Strategy_MakeWellFormed_SkipInjector extends HTMLPurifier_Inj
{
public $name = 'EndRewindInjector';
public $needed = array('span');
public function handleElement(&$token) {
public function handleElement(&$token)
{
$token = array(clone $token, clone $token);
}
}

View File

@@ -2,20 +2,24 @@
class HTMLPurifier_Strategy_MakeWellFormed_SkipInjectorTest extends HTMLPurifier_StrategyHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
$this->config->set('AutoFormat.Custom', array(
new HTMLPurifier_Strategy_MakeWellFormed_SkipInjector()
));
}
function testEmpty() {
public function testEmpty()
{
$this->assertResult('');
}
function testMultiply() {
public function testMultiply()
{
$this->assertResult('<br />', '<br /><br />');
}
function testMultiplyMultiply() {
public function testMultiplyMultiply()
{
$this->config->set('AutoFormat.Custom', array(
new HTMLPurifier_Strategy_MakeWellFormed_SkipInjector(),
new HTMLPurifier_Strategy_MakeWellFormed_SkipInjector()

View File

@@ -3,97 +3,112 @@
class HTMLPurifier_Strategy_MakeWellFormedTest extends HTMLPurifier_StrategyHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult('');
}
function testWellFormedInput() {
public function testWellFormedInput()
{
$this->assertResult('This is <b>bold text</b>.');
}
function testUnclosedTagTerminatedByDocumentEnd() {
public function testUnclosedTagTerminatedByDocumentEnd()
{
$this->assertResult(
'<b>Unclosed tag, gasp!',
'<b>Unclosed tag, gasp!</b>'
);
}
function testUnclosedTagTerminatedByParentNodeEnd() {
public function testUnclosedTagTerminatedByParentNodeEnd()
{
$this->assertResult(
'<b><i>Bold and italic?</b>',
'<b><i>Bold and italic?</i></b><i></i>'
);
}
function testRemoveStrayClosingTag() {
public function testRemoveStrayClosingTag()
{
$this->assertResult(
'Unused end tags... recycle!</b>',
'Unused end tags... recycle!'
);
}
function testConvertStartToEmpty() {
public function testConvertStartToEmpty()
{
$this->assertResult(
'<br style="clear:both;">',
'<br style="clear:both;" />'
);
}
function testConvertEmptyToStart() {
public function testConvertEmptyToStart()
{
$this->assertResult(
'<div style="clear:both;" />',
'<div style="clear:both;"></div>'
);
}
function testAutoCloseParagraph() {
public function testAutoCloseParagraph()
{
$this->assertResult(
'<p>Paragraph 1<p>Paragraph 2',
'<p>Paragraph 1</p><p>Paragraph 2</p>'
);
}
function testAutoCloseParagraphInsideDiv() {
public function testAutoCloseParagraphInsideDiv()
{
$this->assertResult(
'<div><p>Paragraphs<p>In<p>A<p>Div</div>',
'<div><p>Paragraphs</p><p>In</p><p>A</p><p>Div</p></div>'
);
}
function testAutoCloseListItem() {
public function testAutoCloseListItem()
{
$this->assertResult(
'<ol><li>Item 1<li>Item 2</ol>',
'<ol><li>Item 1</li><li>Item 2</li></ol>'
);
}
function testAutoCloseColgroup() {
public function testAutoCloseColgroup()
{
$this->assertResult(
'<table><colgroup><col /><tr></tr></table>',
'<table><colgroup><col /></colgroup><tr></tr></table>'
);
}
function testAutoCloseMultiple() {
public function testAutoCloseMultiple()
{
$this->assertResult(
'<b><span><div></div>asdf',
'<b><span></span></b><div><b></b></div><b>asdf</b>'
);
}
function testUnrecognized() {
public function testUnrecognized()
{
$this->assertResult(
'<asdf><foobar /><biddles>foo</asdf>',
'<asdf><foobar /><biddles>foo</biddles></asdf>'
);
}
function testBlockquoteWithInline() {
public function testBlockquoteWithInline()
{
$this->config->set('HTML.Doctype', 'XHTML 1.0 Strict');
$this->assertResult(
// This is actually invalid, but will be fixed by
@@ -102,42 +117,48 @@ class HTMLPurifier_Strategy_MakeWellFormedTest extends HTMLPurifier_StrategyHarn
);
}
function testLongCarryOver() {
public function testLongCarryOver()
{
$this->assertResult(
'<b>asdf<div>asdf<i>df</i></div>asdf</b>',
'<b>asdf</b><div><b>asdf<i>df</i></b></div><b>asdf</b>'
);
}
function testInterleaved() {
public function testInterleaved()
{
$this->assertResult(
'<u>foo<i>bar</u>baz</i>',
'<u>foo<i>bar</i></u><i>baz</i>'
);
}
function testNestedOl() {
public function testNestedOl()
{
$this->assertResult(
'<ol><ol><li>foo</li></ol></ol>',
'<ol><ol><li>foo</li></ol></ol>'
);
}
function testNestedUl() {
public function testNestedUl()
{
$this->assertResult(
'<ul><ul><li>foo</li></ul></ul>',
'<ul><ul><li>foo</li></ul></ul>'
);
}
function testNestedOlWithStrangeEnding() {
public function testNestedOlWithStrangeEnding()
{
$this->assertResult(
'<ol><li><ol><ol><li>foo</li></ol></li><li>foo</li></ol>',
'<ol><li><ol><ol><li>foo</li></ol></ol></li><li>foo</li></ol>'
);
}
function testNoAutocloseIfNoParentsCanAccomodateTag() {
public function testNoAutocloseIfNoParentsCanAccomodateTag()
{
$this->assertResult(
'<table><tr><td><li>foo</li></td></tr></table>',
'<table><tr><td>foo</td></tr></table>'

View File

@@ -3,56 +3,65 @@
class HTMLPurifier_Strategy_MakeWellFormed_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness
{
protected function getStrategy() {
protected function getStrategy()
{
return new HTMLPurifier_Strategy_MakeWellFormed();
}
function testUnnecessaryEndTagRemoved() {
public function testUnnecessaryEndTagRemoved()
{
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag removed');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 0));
$this->invoke('</b>');
}
function testUnnecessaryEndTagToText() {
public function testUnnecessaryEndTagToText()
{
$this->config->set('Core.EscapeInvalidTags', true);
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag to text');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 0));
$this->invoke('</b>');
}
function testTagAutoclose() {
public function testTagAutoclose()
{
$this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag auto closed', new HTMLPurifier_Token_Start('p', array(), 1, 0));
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('div', array(), 1, 6));
$this->invoke('<p>Foo<div>Bar</div>');
}
function testTagCarryOver() {
public function testTagCarryOver()
{
$b = new HTMLPurifier_Token_Start('b', array(), 1, 0);
$this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag carryover', $b);
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('div', array(), 1, 6));
$this->invoke('<b>Foo<div>Bar</div>');
}
function testStrayEndTagRemoved() {
public function testStrayEndTagRemoved()
{
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag removed');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 3));
$this->invoke('<i></b></i>');
}
function testStrayEndTagToText() {
public function testStrayEndTagToText()
{
$this->config->set('Core.EscapeInvalidTags', true);
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag to text');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 3));
$this->invoke('<i></b></i>');
}
function testTagClosedByElementEnd() {
public function testTagClosedByElementEnd()
{
$this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by element end', new HTMLPurifier_Token_Start('b', array(), 1, 3));
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('i', array(), 1, 12));
$this->invoke('<i><b>Foobar</i>');
}
function testTagClosedByDocumentEnd() {
public function testTagClosedByDocumentEnd()
{
$this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by document end', new HTMLPurifier_Token_Start('b', array(), 1, 0));
$this->invoke('<b>Foobar');
}

View File

@@ -3,7 +3,8 @@
class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_StrategyHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
$this->config->set('AutoFormat.AutoParagraph', true);
@@ -12,7 +13,8 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str
generate_mock_once('HTMLPurifier_Injector');
}
function testEndHandler() {
public function testEndHandler()
{
$mock = new HTMLPurifier_InjectorMock();
$b = new HTMLPurifier_Token_End('b');
$b->skip = array(0 => true);
@@ -32,48 +34,55 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str
$this->assertResult('<i><b>asdf</b>', '<i><b>asdf</b></i>');
}
function testErrorRequiredElementNotAllowed() {
public function testErrorRequiredElementNotAllowed()
{
$this->config->set('HTML.Allowed', '');
$this->expectError('Cannot enable AutoParagraph injector because p is not allowed');
$this->expectError('Cannot enable Linkify injector because a is not allowed');
$this->assertResult('Foobar');
}
function testErrorRequiredAttributeNotAllowed() {
public function testErrorRequiredAttributeNotAllowed()
{
$this->config->set('HTML.Allowed', 'a,p');
$this->expectError('Cannot enable Linkify injector because a.href is not allowed');
$this->assertResult('<p>http://example.com</p>');
}
function testOnlyAutoParagraph() {
public function testOnlyAutoParagraph()
{
$this->assertResult(
'Foobar',
'<p>Foobar</p>'
);
}
function testParagraphWrappingOnlyLink() {
public function testParagraphWrappingOnlyLink()
{
$this->assertResult(
'http://example.com',
'<p><a href="http://example.com">http://example.com</a></p>'
);
}
function testParagraphWrappingNodeContainingLink() {
public function testParagraphWrappingNodeContainingLink()
{
$this->assertResult(
'<b>http://example.com</b>',
'<p><b><a href="http://example.com">http://example.com</a></b></p>'
);
}
function testParagraphWrappingPoorlyFormedNodeContainingLink() {
public function testParagraphWrappingPoorlyFormedNodeContainingLink()
{
$this->assertResult(
'<b>http://example.com',
'<p><b><a href="http://example.com">http://example.com</a></b></p>'
);
}
function testTwoParagraphsContainingOnlyOneLink() {
public function testTwoParagraphsContainingOnlyOneLink()
{
$this->assertResult(
"http://example.com\n\nhttp://dev.example.com",
'<p><a href="http://example.com">http://example.com</a></p>
@@ -82,7 +91,8 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str
);
}
function testParagraphNextToDivWithLinks() {
public function testParagraphNextToDivWithLinks()
{
$this->assertResult(
'http://example.com <div>http://example.com</div>',
'<p><a href="http://example.com">http://example.com</a> </p>
@@ -91,14 +101,16 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str
);
}
function testRealisticLinkInSentence() {
public function testRealisticLinkInSentence()
{
$this->assertResult(
'This URL http://example.com is what you need',
'<p>This URL <a href="http://example.com">http://example.com</a> is what you need</p>'
);
}
function testParagraphAfterLinkifiedURL() {
public function testParagraphAfterLinkifiedURL()
{
$this->assertResult(
"http://google.com
@@ -109,7 +121,8 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str
);
}
function testEmptyAndParagraph() {
public function testEmptyAndParagraph()
{
// This is a fairly degenerate case, but it demonstrates that
// the two don't error out together, at least.
// Change this behavior!
@@ -127,7 +140,8 @@ asdf<b></b></p>
);
}
function testRewindAndParagraph() {
public function testRewindAndParagraph()
{
$this->assertResult(
"bar

View File

@@ -3,41 +3,48 @@
class HTMLPurifier_Strategy_RemoveForeignElementsTest extends HTMLPurifier_StrategyHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_RemoveForeignElements();
}
function testBlankInput() {
public function testBlankInput()
{
$this->assertResult('');
}
function testPreserveRecognizedElements() {
public function testPreserveRecognizedElements()
{
$this->assertResult('This is <b>bold text</b>.');
}
function testRemoveForeignElements() {
public function testRemoveForeignElements()
{
$this->assertResult(
'<asdf>Bling</asdf><d href="bang">Bong</d><foobar />',
'BlingBong'
);
}
function testRemoveScriptAndContents() {
public function testRemoveScriptAndContents()
{
$this->assertResult(
'<script>alert();</script>',
''
);
}
function testRemoveStyleAndContents() {
public function testRemoveStyleAndContents()
{
$this->assertResult(
'<style>.foo {blink;}</style>',
''
);
}
function testRemoveOnlyScriptTagsLegacy() {
public function testRemoveOnlyScriptTagsLegacy()
{
$this->config->set('Core.RemoveScriptContents', false);
$this->assertResult(
'<script>alert();</script>',
@@ -45,7 +52,8 @@ class HTMLPurifier_Strategy_RemoveForeignElementsTest extends HTMLPurifier_Strat
);
}
function testRemoveOnlyScriptTags() {
public function testRemoveOnlyScriptTags()
{
$this->config->set('Core.HiddenElements', array());
$this->assertResult(
'<script>alert();</script>',
@@ -53,20 +61,24 @@ class HTMLPurifier_Strategy_RemoveForeignElementsTest extends HTMLPurifier_Strat
);
}
function testRemoveInvalidImg() {
public function testRemoveInvalidImg()
{
$this->assertResult('<img />', '');
}
function testPreserveValidImg() {
public function testPreserveValidImg()
{
$this->assertResult('<img src="foobar.gif" alt="foobar.gif" />');
}
function testPreserveInvalidImgWhenRemovalIsDisabled() {
public function testPreserveInvalidImgWhenRemovalIsDisabled()
{
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult('<img />');
}
function testTextifyCommentedScriptContents() {
public function testTextifyCommentedScriptContents()
{
$this->config->set('HTML.Trusted', true);
$this->config->set('Output.CommentScriptContents', false); // simplify output
$this->assertResult(
@@ -79,33 +91,39 @@ alert(&lt;b&gt;bold&lt;/b&gt;);
);
}
function testRequiredAttributesTestNotPerformedOnEndTag() {
public function testRequiredAttributesTestNotPerformedOnEndTag()
{
$def = $this->config->getHTMLDefinition(true);
$def->addElement('f', 'Block', 'Optional: #PCDATA', false, array('req*' => 'Text'));
$this->assertResult('<f req="text">Foo</f> Bar');
}
function testPreserveCommentsWithHTMLTrusted() {
public function testPreserveCommentsWithHTMLTrusted()
{
$this->config->set('HTML.Trusted', true);
$this->assertResult('<!-- foo -->');
}
function testRemoveTrailingHyphensInComment() {
public function testRemoveTrailingHyphensInComment()
{
$this->config->set('HTML.Trusted', true);
$this->assertResult('<!-- foo ----->', '<!-- foo -->');
}
function testCollapseDoubleHyphensInComment() {
public function testCollapseDoubleHyphensInComment()
{
$this->config->set('HTML.Trusted', true);
$this->assertResult('<!-- bo --- asdf--as -->', '<!-- bo - asdf-as -->');
}
function testPreserveCommentsWithLookup() {
public function testPreserveCommentsWithLookup()
{
$this->config->set('HTML.AllowedComments', array('allowed'));
$this->assertResult('<!-- allowed --><!-- not allowed -->', '<!-- allowed -->');
}
function testPreserveCommentsWithRegexp() {
public function testPreserveCommentsWithRegexp()
{
$this->config->set('HTML.AllowedCommentsRegexp', '/^allowed[1-9]$/');
$this->assertResult('<!-- allowed1 --><!-- not allowed -->', '<!-- allowed1 -->');
}

View File

@@ -3,63 +3,73 @@
class HTMLPurifier_Strategy_RemoveForeignElements_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness
{
public function setup() {
public function setup()
{
parent::setup();
$this->config->set('HTML.TidyLevel', 'heavy');
}
protected function getStrategy() {
protected function getStrategy()
{
return new HTMLPurifier_Strategy_RemoveForeignElements();
}
function testTagTransform() {
public function testTagTransform()
{
$this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Tag transform', 'center');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('div', array('style' => 'text-align:center;'), 1));
$this->invoke('<center>');
}
function testMissingRequiredAttr() {
public function testMissingRequiredAttr()
{
// a little fragile, since img has two required attributes
$this->expectErrorCollection(E_ERROR, 'Strategy_RemoveForeignElements: Missing required attribute', 'alt');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Empty('img', array(), 1));
$this->invoke('<img />');
}
function testForeignElementToText() {
public function testForeignElementToText()
{
$this->config->set('Core.EscapeInvalidTags', true);
$this->expectErrorCollection(E_WARNING, 'Strategy_RemoveForeignElements: Foreign element to text');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('invalid', array(), 1));
$this->invoke('<invalid>');
}
function testForeignElementRemoved() {
public function testForeignElementRemoved()
{
// uses $CurrentToken.Serialized
$this->expectErrorCollection(E_ERROR, 'Strategy_RemoveForeignElements: Foreign element removed');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('invalid', array(), 1));
$this->invoke('<invalid>');
}
function testCommentRemoved() {
public function testCommentRemoved()
{
$this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Comment removed');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test ', 1));
$this->invoke('<!-- test -->');
}
function testTrailingHyphenInCommentRemoved() {
public function testTrailingHyphenInCommentRemoved()
{
$this->config->set('HTML.Trusted', true);
$this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Trailing hyphen in comment removed');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test ', 1));
$this->invoke('<!-- test ---->');
}
function testDoubleHyphenInCommentRemoved() {
public function testDoubleHyphenInCommentRemoved()
{
$this->config->set('HTML.Trusted', true);
$this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Hyphens in comment collapsed');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test - test - test ', 1));
$this->invoke('<!-- test --- test -- test -->');
}
function testForeignMetaElementRemoved() {
public function testForeignMetaElementRemoved()
{
$this->collector->expectAt(0, 'send', array(E_ERROR, 'Strategy_RemoveForeignElements: Foreign meta element removed'));
$this->collector->expectContextAt(0, 'CurrentToken', new HTMLPurifier_Token_Start('script', array(), 1));
$this->collector->expectAt(1, 'send', array(E_ERROR, 'Strategy_RemoveForeignElements: Token removed to end', 'script'));

View File

@@ -4,20 +4,23 @@ class HTMLPurifier_Strategy_RemoveForeignElements_TidyTest
extends HTMLPurifier_StrategyHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_RemoveForeignElements();
$this->config->set('HTML.TidyLevel', 'heavy');
}
function testCenterTransform() {
public function testCenterTransform()
{
$this->assertResult(
'<center>Look I am Centered!</center>',
'<div style="text-align:center;">Look I am Centered!</div>'
);
}
function testFontTransform() {
public function testFontTransform()
{
$this->assertResult(
'<font color="red" face="Arial" size="6">Big Warning!</font>',
'<span style="color:red;font-family:Arial;font-size:xx-large;">Big'.
@@ -25,7 +28,8 @@ class HTMLPurifier_Strategy_RemoveForeignElements_TidyTest
);
}
function testTransformToForbiddenElement() {
public function testTransformToForbiddenElement()
{
$this->config->set('HTML.Allowed', 'div');
$this->assertResult(
'<font color="red" face="Arial" size="6">Big Warning!</font>',
@@ -33,7 +37,8 @@ class HTMLPurifier_Strategy_RemoveForeignElements_TidyTest
);
}
function testMenuTransform() {
public function testMenuTransform()
{
$this->assertResult(
'<menu><li>Item 1</li></menu>',
'<ul><li>Item 1</li></ul>'

View File

@@ -4,34 +4,40 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
HTMLPurifier_StrategyHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult('');
}
function testRemoveIDByDefault() {
public function testRemoveIDByDefault()
{
$this->assertResult(
'<div id="valid">Kill the ID.</div>',
'<div>Kill the ID.</div>'
);
}
function testRemoveInvalidDir() {
public function testRemoveInvalidDir()
{
$this->assertResult(
'<span dir="up-to-down">Bad dir.</span>',
'<span>Bad dir.</span>'
);
}
function testPreserveValidClass() {
public function testPreserveValidClass()
{
$this->assertResult('<div class="valid">Valid</div>');
}
function testSelectivelyRemoveInvalidClasses() {
public function testSelectivelyRemoveInvalidClasses()
{
$this->config->set('HTML.Doctype', 'XHTML 1.1');
$this->assertResult(
'<div class="valid 0invalid">Keep valid.</div>',
@@ -39,20 +45,23 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testPreserveTitle() {
public function testPreserveTitle()
{
$this->assertResult(
'<acronym title="PHP: Hypertext Preprocessor">PHP</acronym>'
);
}
function testAddXMLLang() {
public function testAddXMLLang()
{
$this->assertResult(
'<span lang="fr">La soupe.</span>',
'<span lang="fr" xml:lang="fr">La soupe.</span>'
);
}
function testOnlyXMLLangInXHTML11() {
public function testOnlyXMLLangInXHTML11()
{
$this->config->set('HTML.Doctype', 'XHTML 1.1');
$this->assertResult(
'<b lang="en">asdf</b>',
@@ -60,32 +69,37 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testBasicURI() {
public function testBasicURI()
{
$this->assertResult('<a href="http://www.google.com/">Google</a>');
}
function testInvalidURI() {
public function testInvalidURI()
{
$this->assertResult(
'<a href="javascript:badstuff();">Google</a>',
'<a>Google</a>'
);
}
function testBdoAddMissingDir() {
public function testBdoAddMissingDir()
{
$this->assertResult(
'<bdo>Go left.</bdo>',
'<bdo dir="ltr">Go left.</bdo>'
);
}
function testBdoReplaceInvalidDirWithDefault() {
public function testBdoReplaceInvalidDirWithDefault()
{
$this->assertResult(
'<bdo dir="blahblah">Invalid value!</bdo>',
'<bdo dir="ltr">Invalid value!</bdo>'
);
}
function testBdoAlternateDefaultDir() {
public function testBdoAlternateDefaultDir()
{
$this->config->set('Attr.DefaultTextDir', 'rtl');
$this->assertResult(
'<bdo>Go right.</bdo>',
@@ -93,14 +107,16 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testRemoveDirWhenNotRequired() {
public function testRemoveDirWhenNotRequired()
{
$this->assertResult(
'<span dir="blahblah">Invalid value!</span>',
'<span>Invalid value!</span>'
);
}
function testTableAttributes() {
public function testTableAttributes()
{
$this->assertResult(
'<table frame="above" rules="rows" summary="A test table" border="2" cellpadding="5%" cellspacing="3" width="100%">
<col align="right" width="4*" />
@@ -120,14 +136,16 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testColSpanIsNonZero() {
public function testColSpanIsNonZero()
{
$this->assertResult(
'<col span="0" />',
'<col />'
);
}
function testImgAddDefaults() {
public function testImgAddDefaults()
{
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult(
'<img />',
@@ -135,14 +153,16 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testImgGenerateAlt() {
public function testImgGenerateAlt()
{
$this->assertResult(
'<img src="foobar.jpg" />',
'<img src="foobar.jpg" alt="foobar.jpg" />'
);
}
function testImgAddDefaultSrc() {
public function testImgAddDefaultSrc()
{
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult(
'<img alt="pretty picture" />',
@@ -150,7 +170,8 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testImgRemoveNonRetrievableProtocol() {
public function testImgRemoveNonRetrievableProtocol()
{
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult(
'<img src="mailto:foo@example.com" />',
@@ -158,18 +179,21 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testPreserveRel() {
public function testPreserveRel()
{
$this->config->set('Attr.AllowedRel', 'nofollow');
$this->assertResult('<a href="foo" rel="nofollow" />');
}
function testPreserveTarget() {
public function testPreserveTarget()
{
$this->config->set('Attr.AllowedFrameTargets', '_top');
$this->config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
$this->assertResult('<a href="foo" target="_top" />');
}
function testRemoveTargetWhenNotSupported() {
public function testRemoveTargetWhenNotSupported()
{
$this->config->set('HTML.Doctype', 'XHTML 1.0 Strict');
$this->config->set('Attr.AllowedFrameTargets', '_top');
$this->assertResult(
@@ -178,20 +202,23 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testKeepAbsoluteCSSWidthAndHeightOnImg() {
public function testKeepAbsoluteCSSWidthAndHeightOnImg()
{
$this->assertResult(
'<img src="" alt="" style="width:10px;height:10px;border:1px solid #000;" />'
);
}
function testRemoveLargeCSSWidthAndHeightOnImg() {
public function testRemoveLargeCSSWidthAndHeightOnImg()
{
$this->assertResult(
'<img src="" alt="" style="width:10000000px;height:10000000px;border:1px solid #000;" />',
'<img src="" alt="" style="border:1px solid #000;" />'
);
}
function testRemoveLargeCSSWidthAndHeightOnImgWithUserConf() {
public function testRemoveLargeCSSWidthAndHeightOnImgWithUserConf()
{
$this->config->set('CSS.MaxImgLength', '1px');
$this->assertResult(
'<img src="" alt="" style="width:1mm;height:1mm;border:1px solid #000;" />',
@@ -199,28 +226,32 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testKeepLargeCSSWidthAndHeightOnImgWhenToldTo() {
public function testKeepLargeCSSWidthAndHeightOnImgWhenToldTo()
{
$this->config->set('CSS.MaxImgLength', null);
$this->assertResult(
'<img src="" alt="" style="width:10000000px;height:10000000px;border:1px solid #000;" />'
);
}
function testKeepPercentCSSWidthAndHeightOnImgWhenToldTo() {
public function testKeepPercentCSSWidthAndHeightOnImgWhenToldTo()
{
$this->config->set('CSS.MaxImgLength', null);
$this->assertResult(
'<img src="" alt="" style="width:100%;height:100%;border:1px solid #000;" />'
);
}
function testRemoveRelativeCSSWidthAndHeightOnImg() {
public function testRemoveRelativeCSSWidthAndHeightOnImg()
{
$this->assertResult(
'<img src="" alt="" style="width:10em;height:10em;border:1px solid #000;" />',
'<img src="" alt="" style="border:1px solid #000;" />'
);
}
function testRemovePercentCSSWidthAndHeightOnImg() {
public function testRemovePercentCSSWidthAndHeightOnImg()
{
$this->assertResult(
'<img src="" alt="" style="width:100%;height:100%;border:1px solid #000;" />',
'<img src="" alt="" style="border:1px solid #000;" />'

View File

@@ -3,46 +3,53 @@
class HTMLPurifier_Strategy_ValidateAttributes_IDTest extends HTMLPurifier_StrategyHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
$this->config->set('Attr.EnableID', true);
}
function testPreserveIDWhenEnabled() {
public function testPreserveIDWhenEnabled()
{
$this->assertResult('<div id="valid">Preserve the ID.</div>');
}
function testRemoveInvalidID() {
public function testRemoveInvalidID()
{
$this->assertResult(
'<div id="0invalid">Kill the ID.</div>',
'<div>Kill the ID.</div>'
);
}
function testRemoveDuplicateID() {
public function testRemoveDuplicateID()
{
$this->assertResult(
'<div id="valid">Valid</div><div id="valid">Invalid</div>',
'<div id="valid">Valid</div><div>Invalid</div>'
);
}
function testAttributeKeyCaseInsensitivity() {
public function testAttributeKeyCaseInsensitivity()
{
$this->assertResult(
'<div ID="valid">Convert ID to lowercase.</div>',
'<div id="valid">Convert ID to lowercase.</div>'
);
}
function testTrimWhitespace() {
public function testTrimWhitespace()
{
$this->assertResult(
'<div id=" valid ">Trim whitespace.</div>',
'<div id="valid">Trim whitespace.</div>'
);
}
function testIDBlacklist() {
public function testIDBlacklist()
{
$this->config->set('Attr.IDBlacklist', array('invalid'));
$this->assertResult(
'<div id="invalid">Invalid</div>',
@@ -50,7 +57,8 @@ class HTMLPurifier_Strategy_ValidateAttributes_IDTest extends HTMLPurifier_Strat
);
}
function testNameConvertedToID() {
public function testNameConvertedToID()
{
$this->config->set('HTML.TidyLevel', 'heavy');
$this->assertResult(
'<a name="foobar" />',

View File

@@ -3,342 +3,391 @@
class HTMLPurifier_Strategy_ValidateAttributes_TidyTest extends HTMLPurifier_StrategyHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
$this->config->set('HTML.TidyLevel', 'heavy');
}
function testConvertCenterAlign() {
public function testConvertCenterAlign()
{
$this->assertResult(
'<h1 align="center">Centered Headline</h1>',
'<h1 style="text-align:center;">Centered Headline</h1>'
);
}
function testConvertRightAlign() {
public function testConvertRightAlign()
{
$this->assertResult(
'<h1 align="right">Right-aligned Headline</h1>',
'<h1 style="text-align:right;">Right-aligned Headline</h1>'
);
}
function testConvertLeftAlign() {
public function testConvertLeftAlign()
{
$this->assertResult(
'<h1 align="left">Left-aligned Headline</h1>',
'<h1 style="text-align:left;">Left-aligned Headline</h1>'
);
}
function testConvertJustifyAlign() {
public function testConvertJustifyAlign()
{
$this->assertResult(
'<p align="justify">Justified Paragraph</p>',
'<p style="text-align:justify;">Justified Paragraph</p>'
);
}
function testRemoveInvalidAlign() {
public function testRemoveInvalidAlign()
{
$this->assertResult(
'<h1 align="invalid">Invalid Headline</h1>',
'<h1>Invalid Headline</h1>'
);
}
function testConvertTableLengths() {
public function testConvertTableLengths()
{
$this->assertResult(
'<td width="5%" height="10" /><th width="10" height="5%" /><hr width="10" height="10" />',
'<td style="width:5%;height:10px;" /><th style="width:10px;height:5%;" /><hr style="width:10px;" />'
);
}
function testTdConvertNowrap() {
public function testTdConvertNowrap()
{
$this->assertResult(
'<td nowrap />',
'<td style="white-space:nowrap;" />'
);
}
function testCaptionConvertAlignLeft() {
public function testCaptionConvertAlignLeft()
{
$this->assertResult(
'<caption align="left" />',
'<caption style="text-align:left;" />'
);
}
function testCaptionConvertAlignRight() {
public function testCaptionConvertAlignRight()
{
$this->assertResult(
'<caption align="right" />',
'<caption style="text-align:right;" />'
);
}
function testCaptionConvertAlignTop() {
public function testCaptionConvertAlignTop()
{
$this->assertResult(
'<caption align="top" />',
'<caption style="caption-side:top;" />'
);
}
function testCaptionConvertAlignBottom() {
public function testCaptionConvertAlignBottom()
{
$this->assertResult(
'<caption align="bottom" />',
'<caption style="caption-side:bottom;" />'
);
}
function testCaptionRemoveInvalidAlign() {
public function testCaptionRemoveInvalidAlign()
{
$this->assertResult(
'<caption align="nonsense" />',
'<caption />'
);
}
function testTableConvertAlignLeft() {
public function testTableConvertAlignLeft()
{
$this->assertResult(
'<table align="left" />',
'<table style="float:left;" />'
);
}
function testTableConvertAlignCenter() {
public function testTableConvertAlignCenter()
{
$this->assertResult(
'<table align="center" />',
'<table style="margin-left:auto;margin-right:auto;" />'
);
}
function testTableConvertAlignRight() {
public function testTableConvertAlignRight()
{
$this->assertResult(
'<table align="right" />',
'<table style="float:right;" />'
);
}
function testTableRemoveInvalidAlign() {
public function testTableRemoveInvalidAlign()
{
$this->assertResult(
'<table align="top" />',
'<table />'
);
}
function testImgConvertAlignLeft() {
public function testImgConvertAlignLeft()
{
$this->assertResult(
'<img src="foobar.jpg" alt="foobar" align="left" />',
'<img src="foobar.jpg" alt="foobar" style="float:left;" />'
);
}
function testImgConvertAlignRight() {
public function testImgConvertAlignRight()
{
$this->assertResult(
'<img src="foobar.jpg" alt="foobar" align="right" />',
'<img src="foobar.jpg" alt="foobar" style="float:right;" />'
);
}
function testImgConvertAlignBottom() {
public function testImgConvertAlignBottom()
{
$this->assertResult(
'<img src="foobar.jpg" alt="foobar" align="bottom" />',
'<img src="foobar.jpg" alt="foobar" style="vertical-align:baseline;" />'
);
}
function testImgConvertAlignMiddle() {
public function testImgConvertAlignMiddle()
{
$this->assertResult(
'<img src="foobar.jpg" alt="foobar" align="middle" />',
'<img src="foobar.jpg" alt="foobar" style="vertical-align:middle;" />'
);
}
function testImgConvertAlignTop() {
public function testImgConvertAlignTop()
{
$this->assertResult(
'<img src="foobar.jpg" alt="foobar" align="top" />',
'<img src="foobar.jpg" alt="foobar" style="vertical-align:top;" />'
);
}
function testImgRemoveInvalidAlign() {
public function testImgRemoveInvalidAlign()
{
$this->assertResult(
'<img src="foobar.jpg" alt="foobar" align="outerspace" />',
'<img src="foobar.jpg" alt="foobar" />'
);
}
function testBorderConvertHVSpace() {
public function testBorderConvertHVSpace()
{
$this->assertResult(
'<img src="foo" alt="foo" hspace="1" vspace="3" />',
'<img src="foo" alt="foo" style="margin-top:3px;margin-bottom:3px;margin-left:1px;margin-right:1px;" />'
);
}
function testHrConvertSize() {
public function testHrConvertSize()
{
$this->assertResult(
'<hr size="3" />',
'<hr style="height:3px;" />'
);
}
function testHrConvertNoshade() {
public function testHrConvertNoshade()
{
$this->assertResult(
'<hr noshade />',
'<hr style="color:#808080;background-color:#808080;border:0;" />'
);
}
function testHrConvertAlignLeft() {
public function testHrConvertAlignLeft()
{
$this->assertResult(
'<hr align="left" />',
'<hr style="margin-left:0;margin-right:auto;text-align:left;" />'
);
}
function testHrConvertAlignCenter() {
public function testHrConvertAlignCenter()
{
$this->assertResult(
'<hr align="center" />',
'<hr style="margin-left:auto;margin-right:auto;text-align:center;" />'
);
}
function testHrConvertAlignRight() {
public function testHrConvertAlignRight()
{
$this->assertResult(
'<hr align="right" />',
'<hr style="margin-left:auto;margin-right:0;text-align:right;" />'
);
}
function testHrRemoveInvalidAlign() {
public function testHrRemoveInvalidAlign()
{
$this->assertResult(
'<hr align="bottom" />',
'<hr />'
);
}
function testBrConvertClearLeft() {
public function testBrConvertClearLeft()
{
$this->assertResult(
'<br clear="left" />',
'<br style="clear:left;" />'
);
}
function testBrConvertClearRight() {
public function testBrConvertClearRight()
{
$this->assertResult(
'<br clear="right" />',
'<br style="clear:right;" />'
);
}
function testBrConvertClearAll() {
public function testBrConvertClearAll()
{
$this->assertResult(
'<br clear="all" />',
'<br style="clear:both;" />'
);
}
function testBrConvertClearNone() {
public function testBrConvertClearNone()
{
$this->assertResult(
'<br clear="none" />',
'<br style="clear:none;" />'
);
}
function testBrRemoveInvalidClear() {
public function testBrRemoveInvalidClear()
{
$this->assertResult(
'<br clear="foo" />',
'<br />'
);
}
function testUlConvertTypeDisc() {
public function testUlConvertTypeDisc()
{
$this->assertResult(
'<ul type="disc" />',
'<ul style="list-style-type:disc;" />'
);
}
function testUlConvertTypeSquare() {
public function testUlConvertTypeSquare()
{
$this->assertResult(
'<ul type="square" />',
'<ul style="list-style-type:square;" />'
);
}
function testUlConvertTypeCircle() {
public function testUlConvertTypeCircle()
{
$this->assertResult(
'<ul type="circle" />',
'<ul style="list-style-type:circle;" />'
);
}
function testUlConvertTypeCaseInsensitive() {
public function testUlConvertTypeCaseInsensitive()
{
$this->assertResult(
'<ul type="CIRCLE" />',
'<ul style="list-style-type:circle;" />'
);
}
function testUlRemoveInvalidType() {
public function testUlRemoveInvalidType()
{
$this->assertResult(
'<ul type="a" />',
'<ul />'
);
}
function testOlConvertType1() {
public function testOlConvertType1()
{
$this->assertResult(
'<ol type="1" />',
'<ol style="list-style-type:decimal;" />'
);
}
function testOlConvertTypeLowerI() {
public function testOlConvertTypeLowerI()
{
$this->assertResult(
'<ol type="i" />',
'<ol style="list-style-type:lower-roman;" />'
);
}
function testOlConvertTypeUpperI() {
public function testOlConvertTypeUpperI()
{
$this->assertResult(
'<ol type="I" />',
'<ol style="list-style-type:upper-roman;" />'
);
}
function testOlConvertTypeLowerA() {
public function testOlConvertTypeLowerA()
{
$this->assertResult(
'<ol type="a" />',
'<ol style="list-style-type:lower-alpha;" />'
);
}
function testOlConvertTypeUpperA() {
public function testOlConvertTypeUpperA()
{
$this->assertResult(
'<ol type="A" />',
'<ol style="list-style-type:upper-alpha;" />'
);
}
function testOlRemoveInvalidType() {
public function testOlRemoveInvalidType()
{
$this->assertResult(
'<ol type="disc" />',
'<ol />'
);
}
function testLiConvertTypeCircle() {
public function testLiConvertTypeCircle()
{
$this->assertResult(
'<li type="circle" />',
'<li style="list-style-type:circle;" />'
);
}
function testLiConvertTypeA() {
public function testLiConvertTypeA()
{
$this->assertResult(
'<li type="A" />',
'<li style="list-style-type:upper-alpha;" />'
);
}
function testLiConvertTypeCaseSensitive() {
public function testLiConvertTypeCaseSensitive()
{
$this->assertResult(
'<li type="CIRCLE" />',
'<li />'