mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-06 22:26:31 +02:00
[1.2.0] Migrate AttrTransform tests to use the Harness supertype.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@496 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -5,28 +5,36 @@ require_once 'HTMLPurifier/AttrTransform/ImgRequired.php';
|
||||
class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransformHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->obj = new HTMLPurifier_AttrTransform_ImgRequired();
|
||||
}
|
||||
|
||||
function test() {
|
||||
|
||||
$this->transform = new HTMLPurifier_AttrTransform_ImgRequired();
|
||||
$this->assertResult(
|
||||
array(),
|
||||
array('src' => '', 'alt' => 'Invalid image')
|
||||
);
|
||||
|
||||
$inputs = $expect = $config = array();
|
||||
$this->assertResult(
|
||||
array(),
|
||||
array('src' => 'blank.png', 'alt' => 'Pawned!'),
|
||||
array(
|
||||
'Attr.DefaultInvalidImage' => 'blank.png',
|
||||
'Attr.DefaultInvalidImageAlt' => 'Pawned!'
|
||||
)
|
||||
);
|
||||
|
||||
$inputs[0] = array();
|
||||
$expect[0] = array('src' => '', 'alt' => 'Invalid image');
|
||||
$this->assertResult(
|
||||
array('src' => '/path/to/foobar.png'),
|
||||
array('src' => '/path/to/foobar.png', 'alt' => 'foobar.png')
|
||||
);
|
||||
|
||||
$inputs[1] = array();
|
||||
$expect[1] = array('src' => 'blank.png', 'alt' => 'Pawned!');
|
||||
$config[1] = HTMLPurifier_Config::createDefault();
|
||||
$config[1]->set('Attr', 'DefaultInvalidImage', 'blank.png');
|
||||
$config[1]->set('Attr', 'DefaultInvalidImageAlt', 'Pawned!');
|
||||
|
||||
$inputs[2] = array('src' => '/path/to/foobar.png');
|
||||
$expect[2] = array('src' => '/path/to/foobar.png', 'alt' => 'foobar.png');
|
||||
|
||||
$inputs[3] = array('alt' => 'intrigue');
|
||||
$expect[3] = array('src' => '', 'alt' => 'intrigue');
|
||||
|
||||
$this->assertTransform($inputs, $expect, $config);
|
||||
$this->assertResult(
|
||||
array('alt' => 'intrigue'),
|
||||
array('src' => '', 'alt' => 'intrigue')
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user