2006-08-05 02:56:57 +00:00
|
|
|
<?php
|
|
|
|
|
2007-05-05 15:48:41 +00:00
|
|
|
class HTMLPurifier_AttrTransform_EnumToCSSTest extends HTMLPurifier_AttrTransformHarness
|
2006-08-05 02:56:57 +00:00
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
2007-05-05 15:48:41 +00:00
|
|
|
$this->obj = new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
|
|
|
|
'left' => 'text-align:left;',
|
|
|
|
'right' => 'text-align:right;'
|
|
|
|
));
|
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 testEmptyInput() {
|
2006-10-22 03:38:32 +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 testPreserveArraysWithoutInterestingAttributes() {
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult( array('style' => 'font-weight:bold;') );
|
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 testConvertAlignLeft() {
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('align' => 'left'),
|
|
|
|
array('style' => 'text-align:left;')
|
|
|
|
);
|
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 testConvertAlignRight() {
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('align' => 'right'),
|
|
|
|
array('style' => 'text-align:right;')
|
|
|
|
);
|
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 testRemoveInvalidAlign() {
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('align' => 'invalid'),
|
|
|
|
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 testPrependNewCSS() {
|
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;')
|
|
|
|
);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-05-05 15:48:41 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-05-05 15:48:41 +00:00
|
|
|
function testCaseInsensitive() {
|
|
|
|
$this->obj = new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
|
|
|
|
'right' => 'text-align:right;'
|
|
|
|
));
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
2007-05-05 15:48:41 +00:00
|
|
|
array('align' => 'RIGHT'),
|
|
|
|
array('style' => 'text-align:right;')
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-05-05 15:48:41 +00:00
|
|
|
function testCaseSensitive() {
|
|
|
|
$this->obj = new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
|
|
|
|
'right' => 'text-align:right;'
|
|
|
|
), true);
|
|
|
|
$this->assertResult(
|
|
|
|
array('align' => 'RIGHT'),
|
|
|
|
array()
|
2006-10-22 03:38:32 +00:00
|
|
|
);
|
2006-08-05 02:56:57 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-05 02:56:57 +00:00
|
|
|
}
|
|
|
|
|