2007-03-29 23:48:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_AttrTransform_LengthTest extends HTMLPurifier_AttrTransformHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function setUp()
|
|
|
|
{
|
2007-03-29 23:48:54 +00:00
|
|
|
parent::setUp();
|
|
|
|
$this->obj = new HTMLPurifier_AttrTransform_Length('width');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testEmptyInput()
|
|
|
|
{
|
2007-03-29 23:48:54 +00:00
|
|
|
$this->assertResult( array() );
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public 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
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public 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
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public 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
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testLenientTreatmentOfInvalidInput()
|
|
|
|
{
|
2007-03-29 23:48:54 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('width' => 'asdf'),
|
|
|
|
array('style' => 'width:asdf;')
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-03-29 23:48:54 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|