2006-07-24 02:41:06 +00:00
|
|
|
<?php
|
|
|
|
|
2006-08-05 00:30:31 +00:00
|
|
|
require_once 'HTMLPurifier/StrategyHarness.php';
|
2006-07-24 02:41:06 +00:00
|
|
|
require_once 'HTMLPurifier/Strategy/MakeWellFormed.php';
|
|
|
|
|
2006-10-01 21:55:13 +00:00
|
|
|
class HTMLPurifier_Strategy_MakeWellFormedTest extends HTMLPurifier_StrategyHarness
|
2006-07-24 02:41:06 +00:00
|
|
|
{
|
|
|
|
|
2006-10-01 21:55:13 +00:00
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
|
|
|
|
}
|
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testEmptyInput() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult('');
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testWellFormedInput() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult('This is <b>bold text</b>.');
|
2007-05-27 23:12:17 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testUnclosedTagTerminatedByDocumentEnd() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<b>Unclosed tag, gasp!',
|
|
|
|
'<b>Unclosed tag, gasp!</b>'
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testUnclosedTagTerminatedByParentNodeEnd() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<b><i>Bold and italic?</b>',
|
|
|
|
'<b><i>Bold and italic?</i></b>'
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testRemoveStrayClosingTag() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Unused end tags... recycle!</b>',
|
|
|
|
'Unused end tags... recycle!'
|
|
|
|
);
|
2007-05-27 23:12:17 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testConvertStartToEmpty() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<br style="clear:both;">',
|
|
|
|
'<br style="clear:both;" />'
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testConvertEmptyToStart() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div style="clear:both;" />',
|
|
|
|
'<div style="clear:both;"></div>'
|
|
|
|
);
|
2007-05-27 23:12:17 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testAutoCloseParagraph() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<p>Paragraph 1<p>Paragraph 2',
|
|
|
|
'<p>Paragraph 1</p><p>Paragraph 2</p>'
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testAutoCloseParagraphInsideDiv() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$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>'
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testAutoCloseListItem() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<ol><li>Item 1<li>Item 2</ol>',
|
|
|
|
'<ol><li>Item 1</li><li>Item 2</li></ol>'
|
|
|
|
);
|
2006-07-24 02:41:06 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testAutoCloseColgroup() {
|
2007-06-24 02:59:06 +00:00
|
|
|
$this->assertResult(
|
2007-08-06 06:22:23 +00:00
|
|
|
'<table><colgroup><col /><tr></tr></table>',
|
|
|
|
'<table><colgroup><col /></colgroup><tr></tr></table>'
|
2007-06-24 02:59:06 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2006-07-24 02:41:06 +00:00
|
|
|
}
|
|
|
|
|