mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-05 21:57:26 +02:00
[1.2.0] Migrate AttrTransform tests to use the Harness supertype.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@496 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -5,48 +5,58 @@ require_once 'HTMLPurifier/AttrTransform/TextAlign.php';
|
||||
class HTMLPurifier_AttrTransform_TextAlignTest extends HTMLPurifier_AttrTransformHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->obj = new HTMLPurifier_AttrTransform_TextAlign();
|
||||
}
|
||||
|
||||
function test() {
|
||||
|
||||
$this->transform = new HTMLPurifier_AttrTransform_TextAlign();
|
||||
|
||||
$inputs = array();
|
||||
$expect = array();
|
||||
|
||||
// leave empty arrays alone
|
||||
$inputs[0] = array();
|
||||
$expect[0] = true;
|
||||
$this->assertResult( array() );
|
||||
|
||||
// leave arrays without interesting stuff alone
|
||||
$inputs[1] = array('style' => 'font-weight:bold;');
|
||||
$expect[1] = true;
|
||||
$this->assertResult( array('style' => 'font-weight:bold;') );
|
||||
|
||||
// test each of the conversions
|
||||
|
||||
$inputs[2] = array('align' => 'left');
|
||||
$expect[2] = array('style' => 'text-align:left;');
|
||||
$this->assertResult(
|
||||
array('align' => 'left'),
|
||||
array('style' => 'text-align:left;')
|
||||
);
|
||||
|
||||
$inputs[3] = array('align' => 'right');
|
||||
$expect[3] = array('style' => 'text-align:right;');
|
||||
$this->assertResult(
|
||||
array('align' => 'right'),
|
||||
array('style' => 'text-align:right;')
|
||||
);
|
||||
|
||||
$inputs[4] = array('align' => 'center');
|
||||
$expect[4] = array('style' => 'text-align:center;');
|
||||
$this->assertResult(
|
||||
array('align' => 'center'),
|
||||
array('style' => 'text-align:center;')
|
||||
);
|
||||
|
||||
$inputs[5] = array('align' => 'justify');
|
||||
$expect[5] = array('style' => 'text-align:justify;');
|
||||
$this->assertResult(
|
||||
array('align' => 'justify'),
|
||||
array('style' => 'text-align:justify;')
|
||||
);
|
||||
|
||||
// drop garbage value
|
||||
$inputs[6] = array('align' => 'invalid');
|
||||
$expect[6] = array();
|
||||
$this->assertResult(
|
||||
array('align' => 'invalid'),
|
||||
array()
|
||||
);
|
||||
|
||||
// test CSS munging
|
||||
$inputs[7] = array('align' => 'left', 'style' => 'font-weight:bold;');
|
||||
$expect[7] = array('style' => 'text-align:left;font-weight:bold;');
|
||||
$this->assertResult(
|
||||
array('align' => 'left', 'style' => 'font-weight:bold;'),
|
||||
array('style' => 'text-align:left;font-weight:bold;')
|
||||
);
|
||||
|
||||
// test case insensitivity
|
||||
$inputs[8] = array('align' => 'CENTER');
|
||||
$expect[8] = array('style' => 'text-align:center;');
|
||||
|
||||
$this->assertTransform($inputs, $expect);
|
||||
$this->assertResult(
|
||||
array('align' => 'CENTER'),
|
||||
array('style' => 'text-align:center;')
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user