2007-03-29 23:48:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_AttrTransform_LengthTest extends HTMLPurifier_AttrTransformHarness
|
|
|
|
{
|
|
|
|
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
$this->obj = new HTMLPurifier_AttrTransform_Length('width');
|
|
|
|
}
|
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testEmptyInput() {
|
2007-03-29 23:48:54 +00:00
|
|
|
$this->assertResult( array() );
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testTransformPixel() {
|
2007-03-29 23:48:54 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('width' => '10'),
|
|
|
|
array('style' => 'width:10px;')
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testTransformPercentage() {
|
2007-03-29 23:48:54 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('width' => '10%'),
|
|
|
|
array('style' => 'width:10%;')
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testPrependNewCSS() {
|
2007-03-29 23:48:54 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('width' => '10%', 'style' => 'font-weight:bold'),
|
|
|
|
array('style' => 'width:10%;font-weight:bold')
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testLenientTreatmentOfInvalidInput() {
|
2007-03-29 23:48:54 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('width' => 'asdf'),
|
|
|
|
array('style' => 'width:asdf;')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|