2006-08-14 23:11:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransformHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-10-22 03:38:32 +00:00
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
$this->obj = new HTMLPurifier_AttrTransform_ImgRequired();
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testAddMissingAttr() {
|
|
|
|
$this->config->set('Core', 'RemoveInvalidImg', false);
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array(),
|
2007-08-06 06:22:23 +00:00
|
|
|
array('src' => '', 'alt' => 'Invalid image')
|
2006-10-22 03:38:32 +00:00
|
|
|
);
|
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 testAlternateDefaults() {
|
|
|
|
$this->config->set('Attr', 'DefaultInvalidImage', 'blank.png');
|
|
|
|
$this->config->set('Attr', 'DefaultInvalidImageAlt', 'Pawned!');
|
2008-10-06 18:51:03 +00:00
|
|
|
$this->config->set('Attr', 'DefaultImageAlt', 'not pawned');
|
2007-08-06 06:22:23 +00:00
|
|
|
$this->config->set('Core', 'RemoveInvalidImg', false);
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array(),
|
2007-08-06 06:22:23 +00:00
|
|
|
array('src' => 'blank.png', 'alt' => 'Pawned!')
|
2006-10-22 03:38:32 +00:00
|
|
|
);
|
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 testGenerateAlt() {
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('src' => '/path/to/foobar.png'),
|
|
|
|
array('src' => '/path/to/foobar.png', 'alt' => 'foobar.png')
|
|
|
|
);
|
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 testAddDefaultSrc() {
|
|
|
|
$this->config->set('Core', 'RemoveInvalidImg', false);
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('alt' => 'intrigue'),
|
2007-08-06 06:22:23 +00:00
|
|
|
array('alt' => 'intrigue', 'src' => '')
|
2006-10-22 03:38:32 +00:00
|
|
|
);
|
2006-08-14 23:11:28 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-10-06 18:51:03 +00:00
|
|
|
function testAddDefaultAlt() {
|
|
|
|
$this->config->set('Attr', 'DefaultImageAlt', 'default');
|
|
|
|
$this->assertResult(
|
|
|
|
array('src' => ''),
|
|
|
|
array('src' => '', 'alt' => 'default')
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-14 23:11:28 +00:00
|
|
|
}
|
|
|
|
|