mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-06 14:16:32 +02:00
Implement attribute transforms for required attributes. I can now confidently say that output will always be valid.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@256 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
35
tests/HTMLPurifier/AttrTransform/ImgRequiredTest.php
Normal file
35
tests/HTMLPurifier/AttrTransform/ImgRequiredTest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier/AttrTransform/ImgRequired.php';
|
||||
|
||||
class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransformHarness
|
||||
{
|
||||
|
||||
function test() {
|
||||
|
||||
$this->transform = new HTMLPurifier_AttrTransform_ImgRequired();
|
||||
|
||||
$inputs = $expect = $config = array();
|
||||
|
||||
$inputs[0] = array();
|
||||
$expect[0] = array('src' => '', 'alt' => 'Invalid image');
|
||||
|
||||
$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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user