1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-04 21:28:06 +02:00
- All important classes that use Context were migrated. Todo: Classes that currently use $config but not $context are AttrTransform (done in r493) and URIScheme+Registry (done in r500). There may be more classes, incl TagTransform (done in r497) that should have both $config and $context added.
- Strategy unit tests now migrated to use HTMLPurifier_Harness

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@485 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2006-10-01 21:55:13 +00:00
parent 8f515b9cda
commit 2d6bf12fe0
18 changed files with 282 additions and 307 deletions

View File

@@ -3,53 +3,62 @@
require_once 'HTMLPurifier/StrategyHarness.php';
require_once 'HTMLPurifier/Strategy/MakeWellFormed.php';
class HTMLPurifier_Strategy_MakeWellFormedTest
extends HTMLPurifier_StrategyHarness
class HTMLPurifier_Strategy_MakeWellFormedTest extends HTMLPurifier_StrategyHarness
{
function setUp() {
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
}
function test() {
$strategy = new HTMLPurifier_Strategy_MakeWellFormed();
$this->assertResult('');
$this->assertResult('This is <b>bold text</b>.');
$inputs = array();
$expect = array();
$this->assertResult(
'<b>Unclosed tag, gasp!',
'<b>Unclosed tag, gasp!</b>'
);
$inputs[0] = '';
$expect[0] = $inputs[0];
$this->assertResult(
'<b><i>Bold and italic?</b>',
'<b><i>Bold and italic?</i></b>'
);
$inputs[1] = 'This is <b>bold text</b>.';
$expect[1] = $inputs[1];
$this->assertResult(
'Unused end tags... recycle!</b>',
'Unused end tags... recycle!'
);
$inputs[2] = '<b>Unclosed tag, gasp!';
$expect[2] = '<b>Unclosed tag, gasp!</b>';
$this->assertResult(
'<br style="clear:both;">',
'<br style="clear:both;" />'
);
$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!';
$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>';
$this->assertResult(
'<div style="clear:both;" />',
'<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>';
$this->assertResult(
'<p>Paragraph 1<p>Paragraph 2',
'<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>';
$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>'
);
// 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);
$this->assertResult(
'<ol><li>Item 1<li>Item 2</ol>',
'<ol><li>Item 1</li><li>Item 2</li></ol>'
);
}
}