PSR-2 reformatting PHPDoc corrections
[htmlpurifier.git] / tests / HTMLPurifier / Strategy / MakeWellFormed_ErrorsTest.php
blob1265db7aa0b3aadfd144f6b918dcb36708147c55
1 <?php
3 class HTMLPurifier_Strategy_MakeWellFormed_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness
6 protected function getStrategy()
8 return new HTMLPurifier_Strategy_MakeWellFormed();
11 public function testUnnecessaryEndTagRemoved()
13 $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag removed');
14 $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 0));
15 $this->invoke('</b>');
18 public 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, 0));
23 $this->invoke('</b>');
26 public function testTagAutoclose()
28 $this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag auto closed', new HTMLPurifier_Token_Start('p', array(), 1, 0));
29 $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('div', array(), 1, 6));
30 $this->invoke('<p>Foo<div>Bar</div>');
33 public function testTagCarryOver()
35 $b = new HTMLPurifier_Token_Start('b', array(), 1, 0);
36 $this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag carryover', $b);
37 $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('div', array(), 1, 6));
38 $this->invoke('<b>Foo<div>Bar</div>');
41 public function testStrayEndTagRemoved()
43 $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag removed');
44 $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 3));
45 $this->invoke('<i></b></i>');
48 public function testStrayEndTagToText()
50 $this->config->set('Core.EscapeInvalidTags', true);
51 $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag to text');
52 $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 3));
53 $this->invoke('<i></b></i>');
56 public function testTagClosedByElementEnd()
58 $this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by element end', new HTMLPurifier_Token_Start('b', array(), 1, 3));
59 $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('i', array(), 1, 12));
60 $this->invoke('<i><b>Foobar</i>');
63 public function testTagClosedByDocumentEnd()
65 $this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by document end', new HTMLPurifier_Token_Start('b', array(), 1, 0));
66 $this->invoke('<b>Foobar');
71 // vim: et sw=4 sts=4