2006-08-05 02:56:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/AttrTransform/TextAlign.php';
|
|
|
|
|
|
|
|
class HTMLPurifier_AttrTransform_TextAlignTest extends HTMLPurifier_AttrTransformHarness
|
|
|
|
{
|
|
|
|
|
2006-10-22 03:38:32 +00:00
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
$this->obj = new HTMLPurifier_AttrTransform_TextAlign();
|
|
|
|
}
|
|
|
|
|
2006-08-05 02:56:57 +00:00
|
|
|
function test() {
|
|
|
|
|
|
|
|
// leave empty arrays alone
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult( array() );
|
2006-08-05 02:56:57 +00:00
|
|
|
|
|
|
|
// leave arrays without interesting stuff alone
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult( array('style' => 'font-weight:bold;') );
|
2006-08-05 02:56:57 +00:00
|
|
|
|
|
|
|
// test each of the conversions
|
|
|
|
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('align' => 'left'),
|
|
|
|
array('style' => 'text-align:left;')
|
|
|
|
);
|
2006-08-05 02:56:57 +00:00
|
|
|
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('align' => 'right'),
|
|
|
|
array('style' => 'text-align:right;')
|
|
|
|
);
|
2006-08-05 02:56:57 +00:00
|
|
|
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('align' => 'center'),
|
|
|
|
array('style' => 'text-align:center;')
|
|
|
|
);
|
2006-08-05 02:56:57 +00:00
|
|
|
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('align' => 'justify'),
|
|
|
|
array('style' => 'text-align:justify;')
|
|
|
|
);
|
2006-08-05 02:56:57 +00:00
|
|
|
|
|
|
|
// drop garbage value
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('align' => 'invalid'),
|
|
|
|
array()
|
|
|
|
);
|
2006-08-05 02:56:57 +00:00
|
|
|
|
|
|
|
// test CSS munging
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('align' => 'left', 'style' => 'font-weight:bold;'),
|
|
|
|
array('style' => 'text-align:left;font-weight:bold;')
|
|
|
|
);
|
2006-08-05 02:56:57 +00:00
|
|
|
|
|
|
|
// test case insensitivity
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('align' => 'CENTER'),
|
|
|
|
array('style' => 'text-align:center;')
|
|
|
|
);
|
2006-08-05 02:56:57 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|