2006-08-02 02:43:52 +00:00
|
|
|
<?php
|
|
|
|
|
2007-08-01 14:06:59 +00:00
|
|
|
class HTMLPurifier_TokenTest extends HTMLPurifier_Harness
|
2006-08-02 02:43:52 +00:00
|
|
|
{
|
|
|
|
|
2008-04-21 15:24:18 +00:00
|
|
|
protected function assertTokenConstruction($name, $attr,
|
2006-12-06 22:29:08 +00:00
|
|
|
$expect_name = null, $expect_attr = null
|
2006-08-02 02:43:52 +00:00
|
|
|
) {
|
|
|
|
if ($expect_name === null) $expect_name = $name;
|
2006-12-06 22:29:08 +00:00
|
|
|
if ($expect_attr === null) $expect_attr = $attr;
|
|
|
|
$token = new HTMLPurifier_Token_Start($name, $attr);
|
2006-08-02 02:43:52 +00:00
|
|
|
|
2007-05-05 20:17:04 +00:00
|
|
|
$this->assertIdentical($expect_name, $token->name);
|
|
|
|
$this->assertIdentical($expect_attr, $token->attr);
|
2006-08-02 02:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testConstruct() {
|
|
|
|
|
|
|
|
// standard case
|
|
|
|
$this->assertTokenConstruction('a', array('href' => 'about:blank'));
|
|
|
|
|
|
|
|
// lowercase the tag's name
|
|
|
|
$this->assertTokenConstruction('A', array('href' => 'about:blank'),
|
|
|
|
'a');
|
|
|
|
|
|
|
|
// lowercase attributes
|
|
|
|
$this->assertTokenConstruction('a', array('HREF' => 'about:blank'),
|
|
|
|
'a', array('href' => 'about:blank'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|