Core.EscapeNonASCIICharacters now always works, even if target is UTF-8.
[htmlpurifier.git] / tests / HTMLPurifier / Strategy / MakeWellFormed_ErrorsTest.php
blobe825e2e2aa48ca8cfc9a36cd755f0327aab6f362
1 <?php
3 class HTMLPurifier_Strategy_MakeWellFormed_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness
6 protected function getStrategy() {
7 return new HTMLPurifier_Strategy_MakeWellFormed();
10 function testUnnecessaryEndTagRemoved() {
11 $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag removed');
12 $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 0));
13 $this->invoke('</b>');
16 function testUnnecessaryEndTagToText() {
17 $this->config->set('Core.EscapeInvalidTags', true);
18 $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag to text');
19 $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 0));
20 $this->invoke('</b>');
23 function testTagAutoclose() {
24 $this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag auto closed', new HTMLPurifier_Token_Start('p', array(), 1, 0));
25 $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('div', array(), 1, 6));
26 $this->invoke('<p>Foo<div>Bar</div>');
29 function testTagCarryOver() {
30 $b = new HTMLPurifier_Token_Start('b', array(), 1, 0);
31 $this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag carryover', $b);
32 $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('div', array(), 1, 6));
33 $this->invoke('<b>Foo<div>Bar</div>');
36 function testStrayEndTagRemoved() {
37 $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag removed');
38 $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 3));
39 $this->invoke('<i></b></i>');
42 function testStrayEndTagToText() {
43 $this->config->set('Core.EscapeInvalidTags', true);
44 $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag to text');
45 $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 3));
46 $this->invoke('<i></b></i>');
49 function testTagClosedByElementEnd() {
50 $this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by element end', new HTMLPurifier_Token_Start('b', array(), 1, 3));
51 $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('i', array(), 1, 12));
52 $this->invoke('<i><b>Foobar</i>');
55 function testTagClosedByDocumentEnd() {
56 $this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by document end', new HTMLPurifier_Token_Start('b', array(), 1, 0));
57 $this->invoke('<b>Foobar');
62 // vim: et sw=4 sts=4