mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-05 21:57:26 +02:00
[1.6.1] Refactor AttrTransform to reduce duplication.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1016 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
42
tests/HTMLPurifier/AttrTransformTest.php
Normal file
42
tests/HTMLPurifier/AttrTransformTest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier/AttrTransform.php';
|
||||
|
||||
class HTMLPurifier_AttrTransformTest extends UnitTestCase
|
||||
{
|
||||
|
||||
function test_prependCSS() {
|
||||
|
||||
$t = new HTMLPurifier_AttrTransform();
|
||||
|
||||
$attr = array();
|
||||
$t->prependCSS($attr, 'style:new;');
|
||||
$this->assertIdentical(array('style' => 'style:new;'), $attr);
|
||||
|
||||
$attr = array('style' => 'style:original;');
|
||||
$t->prependCSS($attr, 'style:new;');
|
||||
$this->assertIdentical(array('style' => 'style:new;style:original;'), $attr);
|
||||
|
||||
$attr = array('style' => 'style:original;', 'misc' => 'un-related');
|
||||
$t->prependCSS($attr, 'style:new;');
|
||||
$this->assertIdentical(array('style' => 'style:new;style:original;', 'misc' => 'un-related'), $attr);
|
||||
|
||||
}
|
||||
|
||||
function test_confiscateAttr() {
|
||||
|
||||
$t = new HTMLPurifier_AttrTransform();
|
||||
|
||||
$attr = array('flavor' => 'sweet');
|
||||
$this->assertIdentical('sweet', $t->confiscateAttr($attr, 'flavor'));
|
||||
$this->assertIdentical(array(), $attr);
|
||||
|
||||
$attr = array('flavor' => 'sweet');
|
||||
$this->assertIdentical(null, $t->confiscateAttr($attr, 'color'));
|
||||
$this->assertIdentical(array('flavor' => 'sweet'), $attr);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user