2007-04-30 19:39:42 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_AttrTransform_ImgSpaceTest extends HTMLPurifier_AttrTransformHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-04-30 19:39:42 +00:00
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
2007-08-06 06:22:23 +00:00
|
|
|
$this->obj = new HTMLPurifier_AttrTransform_ImgSpace('vspace');
|
2007-04-30 19:39:42 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testEmptyInput() {
|
2007-04-30 19:39:42 +00:00
|
|
|
$this->assertResult( array() );
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testVerticalBasicUsage() {
|
2007-04-30 19:39:42 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('vspace' => '1'),
|
|
|
|
array('style' => 'margin-top:1px;margin-bottom:1px;')
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testLenientHandlingOfInvalidInput() {
|
2007-04-30 19:39:42 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('vspace' => '10%'),
|
|
|
|
array('style' => 'margin-top:10%px;margin-bottom:10%px;')
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testPrependNewCSS() {
|
2007-04-30 19:39:42 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('vspace' => '23', 'style' => 'font-weight:bold;'),
|
|
|
|
array('style' => 'margin-top:23px;margin-bottom:23px;font-weight:bold;')
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testHorizontalBasicUsage() {
|
2007-04-30 19:39:42 +00:00
|
|
|
$this->obj = new HTMLPurifier_AttrTransform_ImgSpace('hspace');
|
|
|
|
$this->assertResult(
|
|
|
|
array('hspace' => '1'),
|
|
|
|
array('style' => 'margin-left:1px;margin-right:1px;')
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testInvalidConstructionParameter() {
|
2007-04-30 19:39:42 +00:00
|
|
|
$this->expectError('ispace is not valid space attribute');
|
|
|
|
$this->obj = new HTMLPurifier_AttrTransform_ImgSpace('ispace');
|
|
|
|
$this->assertResult(
|
|
|
|
array('ispace' => '1'),
|
|
|
|
array()
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-04-30 19:39:42 +00:00
|
|
|
}
|
|
|
|
|