ValidateAttributes_IDTest.php
1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
class HTMLPurifier_Strategy_ValidateAttributes_IDTest extends HTMLPurifier_StrategyHarness
{
    public function setUp()
    {
        parent::setUp();
        $this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
        $this->config->set('Attr.EnableID', true);
    }
    public function testPreserveIDWhenEnabled()
    {
        $this->assertResult('<div id="valid">Preserve the ID.</div>');
    }
    public function testRemoveInvalidID()
    {
        $this->assertResult(
            '<div id="0invalid">Kill the ID.</div>',
            '<div>Kill the ID.</div>'
        );
    }
    public function testRemoveDuplicateID()
    {
        $this->assertResult(
            '<div id="valid">Valid</div><div id="valid">Invalid</div>',
            '<div id="valid">Valid</div><div>Invalid</div>'
        );
    }
    public function testAttributeKeyCaseInsensitivity()
    {
        $this->assertResult(
            '<div ID="valid">Convert ID to lowercase.</div>',
            '<div id="valid">Convert ID to lowercase.</div>'
        );
    }
    public function testTrimWhitespace()
    {
        $this->assertResult(
            '<div id=" valid ">Trim whitespace.</div>',
            '<div id="valid">Trim whitespace.</div>'
        );
    }
    public function testIDBlacklist()
    {
        $this->config->set('Attr.IDBlacklist', array('invalid'));
        $this->assertResult(
            '<div id="invalid">Invalid</div>',
            '<div>Invalid</div>'
        );
    }
    public function testNameConvertedToID()
    {
        $this->config->set('HTML.TidyLevel', 'heavy');
        $this->assertResult(
            '<a name="foobar" />',
            '<a id="foobar" />'
        );
    }
}
// vim: et sw=4 sts=4
