2008-09-28 01:19:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_AttrTransform_BackgroundTest extends HTMLPurifier_AttrTransformHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-09-28 01:19:35 +00:00
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
$this->obj = new HTMLPurifier_AttrTransform_Background();
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-09-28 01:19:35 +00:00
|
|
|
function testEmptyInput() {
|
|
|
|
$this->assertResult( array() );
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-09-28 01:19:35 +00:00
|
|
|
function testBasicTransform() {
|
|
|
|
$this->assertResult(
|
|
|
|
array('background' => 'logo.png'),
|
|
|
|
array('style' => 'background-image:url(logo.png);')
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-09-28 01:19:35 +00:00
|
|
|
function testPrependNewCSS() {
|
|
|
|
$this->assertResult(
|
|
|
|
array('background' => 'logo.png', 'style' => 'font-weight:bold'),
|
|
|
|
array('style' => 'background-image:url(logo.png);font-weight:bold')
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-09-28 01:19:35 +00:00
|
|
|
function testLenientTreatmentOfInvalidInput() {
|
|
|
|
// notice that we rely on the CSS validator later to fix this invalid
|
|
|
|
// stuff
|
|
|
|
$this->assertResult(
|
|
|
|
array('background' => 'logo.png);foo:('),
|
|
|
|
array('style' => 'background-image:url(logo.png);foo:();')
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-09-28 01:19:35 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|