obj = new HTMLPurifier_Strategy_ValidateAttributes();
}
function test() {
// attribute order is VERY fragile, perhaps we should define
// an ordering scheme!
$this->assertResult('');
// test ids
$this->assertResult(
'
Kill the ID.
',
'Kill the ID.
'
);
$this->assertResult('Preserve the ID.
', true,
array('HTML.EnableAttrID' => true));
$this->assertResult(
'Kill the ID.
',
'Kill the ID.
',
array('HTML.EnableAttrID' => true)
);
// test id accumulator
$this->assertResult(
'Valid
Invalid
',
'Valid
Invalid
',
array('HTML.EnableAttrID' => true)
);
$this->assertResult(
'Bad dir.',
'Bad dir.'
);
// test attribute key case sensitivity
$this->assertResult(
'Convert ID to lowercase.
',
'Convert ID to lowercase.
',
array('HTML.EnableAttrID' => true)
);
// test simple attribute substitution
$this->assertResult(
'Trim whitespace.
',
'Trim whitespace.
',
array('HTML.EnableAttrID' => true)
);
// test configuration id blacklist
$this->assertResult(
'Invalid
',
'Invalid
',
array(
'Attr.IDBlacklist' => array('invalid'),
'HTML.EnableAttrID' => true
)
);
// test classes
$this->assertResult('Valid
');
$this->assertResult(
'Keep valid.
',
'Keep valid.
'
);
// test title
$this->assertResult(
'PHP'
);
// test lang
$this->assertResult(
'La soupe.',
'La soupe.'
);
// test align
$this->assertResult(
'Centered Headline
',
'Centered Headline
'
);
$this->assertResult(
'Right-aligned Headline
',
'Right-aligned Headline
'
);
$this->assertResult(
'Left-aligned Headline
',
'Left-aligned Headline
'
);
$this->assertResult(
'Justified Paragraph
',
'Justified Paragraph
'
);
$this->assertResult(
'Invalid Headline
',
'Invalid Headline
'
);
// test table
$this->assertResult(
'
Fiddly name |
Super-duper-price |
Carrot Humungous |
$500.23 |
Taken off the market |
'
);
// test URI
$this->assertResult('Google');
// test invalid URI
$this->assertResult(
'Google',
'Google'
);
// test required attributes for img
// (this should never happen, as RemoveForeignElements
// should have removed the offending image tag)
$this->assertResult(
'',
''
);
$this->assertResult(
'',
''
);
$this->assertResult(
'',
''
);
// test required attributes for bdo
$this->assertResult(
'Go left.',
'Go left.'
);
$this->assertResult(
'Invalid value!',
'Invalid value!'
);
// see above, behavior is subtly different
$this->assertResult(
'Invalid value!',
'Invalid value!'
);
// test col.span is non-zero
$this->assertResult(
'',
''
);
// mailto in image is not allowed
$this->assertResult(
'',
''
);
// name rewritten as id
$this->assertResult(
'',
'',
array('HTML.EnableAttrID' => true)
);
// lengths
$this->assertResult(
' | |
',
' | |
'
);
// link types
$this->assertResult(
'',
true,
array('Attr.AllowedRel' => 'nofollow')
);
// border
$this->assertResult(
'',
'',
array('Attr.AllowedRel' => 'nofollow')
);
// link targets
$this->assertResult(
'',
true,
array('Attr.AllowedFrameTargets' => '_top')
);
$this->assertResult(
'',
''
);
$this->assertResult(
'',
'',
array('Attr.AllowedFrameTargets' => '_top', 'HTML.Strict' => true)
);
// hr rule transformations
$this->assertResult(
'
',
'
'
);
$this->assertResult(
'
',
'
'
);
// td boolean transformation
$this->assertResult(
' | ',
' | '
);
// test only one lang
$this->assertResult(
'asdf',
'asdf', array('HTML.Doctype' => 'XHTML 1.1')
);
}
}
?>