Release 2.0.1, merged in 1181 to HEAD.
[htmlpurifier.git] / tests / HTMLPurifier / Strategy / MakeWellFormed_ErrorsTest.php
blobda20110643dcd4bb5ee7cf3d8a8e0bc2af4ba2f4
1 <?php
3 require_once 'HTMLPurifier/Strategy/ErrorsHarness.php';
4 require_once 'HTMLPurifier/Strategy/MakeWellFormed.php';
6 class HTMLPurifier_Strategy_MakeWellFormed_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness
9 function getStrategy() {
10 return new HTMLPurifier_Strategy_MakeWellFormed();
13 function testUnnecessaryEndTagRemoved() {
14 $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag removed');
15 $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1));
16 $this->invoke('</b>');
19 function testUnnecessaryEndTagToText() {
20 $this->config->set('Core', 'EscapeInvalidTags', true);
21 $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag to text');
22 $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1));
23 $this->invoke('</b>');
26 function testTagAutoClosed() {
27 $this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag auto closed', new HTMLPurifier_Token_Start('b', array(), 1));
28 $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('div', array(), 1));
29 $this->invoke('<b>Foo<div>Bar</div>');
32 function testStrayEndTagRemoved() {
33 $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag removed');
34 $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1));
35 $this->invoke('<i></b></i>');
38 function testStrayEndTagToText() {
39 $this->config->set('Core', 'EscapeInvalidTags', true);
40 $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag to text');
41 $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1));
42 $this->invoke('<i></b></i>');
45 function testTagClosedByElementEnd() {
46 $this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by element end', new HTMLPurifier_Token_Start('b', array(), 1));
47 $this->invoke('<i><b>Foobar</i>');
50 function testTagClosedByDocumentEnd() {
51 $this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by document end', new HTMLPurifier_Token_Start('b', array(), 1));
52 $this->invoke('<b>Foobar');