mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-23 00:41:52 +00:00
Extract MakeWellFormedTest from DefinitionTest.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@117 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
4c200f6bcb
commit
63396bb076
64
tests/HTMLPurifier/Strategy/MakeWellFormedTest
Normal file
64
tests/HTMLPurifier/Strategy/MakeWellFormedTest
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'HTMLPurifier/StrategyAbstractTest.php';
|
||||||
|
require_once 'HTMLPurifier/Strategy/MakeWellFormed.php';
|
||||||
|
|
||||||
|
class HTMLPurifier_Strategy_MakeWellFormedTest
|
||||||
|
extends HTMLPurifier_StrategyAbstractTest
|
||||||
|
{
|
||||||
|
|
||||||
|
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>';
|
||||||
|
|
||||||
|
foreach ($inputs as $i => $input) {
|
||||||
|
$tokens = $this->lex->tokenizeHTML($input);
|
||||||
|
$result_tokens = $strategy->execute($tokens);
|
||||||
|
$result = $this->gen->generateFromTokens($result_tokens);
|
||||||
|
$this->assertEqual($expect[$i], $result, "Test $i: %s");
|
||||||
|
paintIf($result, $result != $expect[$i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in New Issue
Block a user