mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-01 11:50:28 +02:00
[1.2.0]
- 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:
@@ -4,39 +4,44 @@ require_once 'HTMLPurifier/StrategyHarness.php';
|
||||
require_once 'HTMLPurifier/Strategy/RemoveForeignElements.php';
|
||||
|
||||
class HTMLPurifier_Strategy_RemoveForeignElementsTest
|
||||
extends HTMLPurifier_StrategyHarness
|
||||
extends HTMLPurifier_StrategyHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->obj = new HTMLPurifier_Strategy_RemoveForeignElements();
|
||||
}
|
||||
|
||||
function test() {
|
||||
|
||||
$strategy = new HTMLPurifier_Strategy_RemoveForeignElements();
|
||||
|
||||
$inputs = array();
|
||||
$expect = array();
|
||||
$this->assertResult('');
|
||||
|
||||
$inputs[0] = '';
|
||||
$expect[0] = $inputs[0];
|
||||
$this->assertResult('This is <b>bold text</b>.');
|
||||
|
||||
$inputs[1] = 'This is <b>bold text</b>.';
|
||||
$expect[1] = $inputs[1];
|
||||
$this->assertResult(
|
||||
'<asdf>Bling</asdf><d href="bang">Bong</d><foobar />',
|
||||
'BlingBong'
|
||||
);
|
||||
|
||||
// [INVALID]
|
||||
$inputs[2] = '<asdf>Bling</asdf><d href="bang">Bong</d><foobar />';
|
||||
$expect[2] = 'BlingBong';
|
||||
|
||||
// test simple transform
|
||||
$inputs[3] = '<menu><li>Item 1</li></menu>';
|
||||
$expect[3] = '<ul><li>Item 1</li></ul>';
|
||||
$this->assertResult(
|
||||
'<menu><li>Item 1</li></menu>',
|
||||
'<ul><li>Item 1</li></ul>'
|
||||
);
|
||||
|
||||
// test center transform
|
||||
$inputs[4] = '<center>Look I am Centered!</center>';
|
||||
$expect[4] = '<div style="text-align:center;">Look I am Centered!</div>';
|
||||
$this->assertResult(
|
||||
'<center>Look I am Centered!</center>',
|
||||
'<div style="text-align:center;">Look I am Centered!</div>'
|
||||
);
|
||||
|
||||
// test font transform
|
||||
$inputs[5] = '<font color="red" face="Arial" size="6">Big Warning!</font>';
|
||||
$expect[5] = '<span style="color:red;font-family:Arial;font-size:xx-large;">Big Warning!</span>';
|
||||
$this->assertResult(
|
||||
'<font color="red" face="Arial" size="6">Big Warning!</font>',
|
||||
'<span style="color:red;font-family:Arial;font-size:xx-large;">Big'.
|
||||
' Warning!</span>'
|
||||
);
|
||||
|
||||
$this->assertStrategyWorks($strategy, $inputs, $expect);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user