MakeWellFormed_ErrorsTest.php
2.75 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_MakeWellFormed_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness
{
protected function getStrategy()
{
return new HTMLPurifier_Strategy_MakeWellFormed();
}
public function testUnnecessaryEndTagRemoved()
{
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag removed');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 0));
$this->invoke('</b>');
}
public function testUnnecessaryEndTagToText()
{
$this->config->set('Core.EscapeInvalidTags', true);
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag to text');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 0));
$this->invoke('</b>');
}
public function testTagAutoclose()
{
$this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag auto closed', new HTMLPurifier_Token_Start('p', array(), 1, 0));
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('div', array(), 1, 6));
$this->invoke('<p>Foo<div>Bar</div>');
}
public function testTagCarryOver()
{
$b = new HTMLPurifier_Token_Start('b', array(), 1, 0);
$this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag carryover', $b);
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('div', array(), 1, 6));
$this->invoke('<b>Foo<div>Bar</div>');
}
public function testStrayEndTagRemoved()
{
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag removed');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 3));
$this->invoke('<i></b></i>');
}
public function testStrayEndTagToText()
{
$this->config->set('Core.EscapeInvalidTags', true);
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag to text');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 3));
$this->invoke('<i></b></i>');
}
public function testTagClosedByElementEnd()
{
$this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by element end', new HTMLPurifier_Token_Start('b', array(), 1, 3));
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('i', array(), 1, 12));
$this->invoke('<i><b>Foobar</i>');
}
public function testTagClosedByDocumentEnd()
{
$this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by document end', new HTMLPurifier_Token_Start('b', array(), 1, 0));
$this->invoke('<b>Foobar');
}
}
// vim: et sw=4 sts=4