mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-10 07:38:41 +00:00
1945ddca5c
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@161 48356398-32a2-884e-a903-53898d9a118a
57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
|
|
require_once 'HTMLPurifier/StrategyHarness.php';
|
|
require_once 'HTMLPurifier/Strategy/MakeWellFormed.php';
|
|
|
|
class HTMLPurifier_Strategy_MakeWellFormedTest
|
|
extends HTMLPurifier_StrategyHarness
|
|
{
|
|
|
|
function test() {
|
|
|
|
$strategy = new HTMLPurifier_Strategy_MakeWellFormed();
|
|
|
|
$inputs = array();
|
|
$expect = array();
|
|
|
|
$inputs[0] = '';
|
|
$expect[0] = $inputs[0];
|
|
|
|
$inputs[1] = 'This is <b>bold text</b>.';
|
|
$expect[1] = $inputs[1];
|
|
|
|
$inputs[2] = '<b>Unclosed tag, gasp!';
|
|
$expect[2] = '<b>Unclosed tag, gasp!</b>';
|
|
|
|
$inputs[3] = '<b><i>Bold and italic?</b>';
|
|
$expect[3] = '<b><i>Bold and italic?</i></b>';
|
|
|
|
// CHANGE THIS BEHAVIOR!
|
|
$inputs[4] = 'Unused end tags... recycle!</b>';
|
|
$expect[4] = 'Unused end tags... recycle!</b>';
|
|
|
|
$inputs[5] = '<br style="clear:both;">';
|
|
$expect[5] = '<br style="clear:both;" />';
|
|
|
|
$inputs[6] = '<div style="clear:both;" />';
|
|
$expect[6] = '<div style="clear:both;"></div>';
|
|
|
|
// test automatic paragraph closing
|
|
|
|
$inputs[7] = '<p>Paragraph 1<p>Paragraph 2';
|
|
$expect[7] = '<p>Paragraph 1</p><p>Paragraph 2</p>';
|
|
|
|
$inputs[8] = '<div><p>Paragraphs<p>In<p>A<p>Div</div>';
|
|
$expect[8] = '<div><p>Paragraphs</p><p>In</p><p>A</p><p>Div</p></div>';
|
|
|
|
// automatic list closing
|
|
|
|
$inputs[9] = '<ol><li>Item 1<li>Item 2</ol>';
|
|
$expect[9] = '<ol><li>Item 1</li><li>Item 2</li></ol>';
|
|
|
|
$this->assertStrategyWorks($strategy, $inputs, $expect);
|
|
}
|
|
|
|
}
|
|
|
|
?>
|