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-12-06 07:28:20 +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);
|
2008-12-06 07:28:20 +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
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testConstruct()
|
|
|
|
{
|
2006-08-02 02:43:52 +00:00
|
|
|
// standard case
|
|
|
|
$this->assertTokenConstruction('a', array('href' => 'about:blank'));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-02 02:43:52 +00:00
|
|
|
// lowercase the tag's name
|
|
|
|
$this->assertTokenConstruction('A', array('href' => 'about:blank'),
|
|
|
|
'a');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-02 02:43:52 +00:00
|
|
|
// lowercase attributes
|
|
|
|
$this->assertTokenConstruction('a', array('HREF' => 'about:blank'),
|
|
|
|
'a', array('href' => 'about:blank'));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-02 02:43:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-02 02:43:52 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|