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();
|
|
|
|
}
|
|
|
|
|
2006-07-24 02:41:06 +00:00
|
|
|
function test() {
|
|
|
|
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult('');
|
|
|
|
$this->assertResult('This is <b>bold text</b>.');
|
2006-07-24 02:41:06 +00:00
|
|
|
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<b>Unclosed tag, gasp!',
|
|
|
|
'<b>Unclosed tag, gasp!</b>'
|
|
|
|
);
|
2006-07-24 02:41:06 +00:00
|
|
|
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<b><i>Bold and italic?</b>',
|
|
|
|
'<b><i>Bold and italic?</i></b>'
|
|
|
|
);
|
2006-07-24 02:41:06 +00:00
|
|
|
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Unused end tags... recycle!</b>',
|
|
|
|
'Unused end tags... recycle!'
|
|
|
|
);
|
2006-07-24 02:41:06 +00:00
|
|
|
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<br style="clear:both;">',
|
|
|
|
'<br style="clear:both;" />'
|
|
|
|
);
|
2006-07-24 02:41:06 +00:00
|
|
|
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div style="clear:both;" />',
|
|
|
|
'<div style="clear:both;"></div>'
|
|
|
|
);
|
2006-07-24 02:41:06 +00:00
|
|
|
|
|
|
|
// test automatic paragraph closing
|
|
|
|
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<p>Paragraph 1<p>Paragraph 2',
|
|
|
|
'<p>Paragraph 1</p><p>Paragraph 2</p>'
|
|
|
|
);
|
2006-07-24 02:41:06 +00:00
|
|
|
|
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>'
|
|
|
|
);
|
2006-07-24 02:41:06 +00:00
|
|
|
|
|
|
|
// automatic list closing
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|