Prepended constants with C_ to avoid reserved words as per https://www.php.net/manual...
[htmlpurifier/darkodev.git] / tests / HTMLPurifier / Lexer / DirectLex_ErrorsTest.php
blob40256c37cfa3861418bea4004ba43e6972e1aa43
1 <?php
3 class HTMLPurifier_Lexer_DirectLex_ErrorsTest extends HTMLPurifier_ErrorsHarness
6 public function invoke($input)
8 $lexer = new HTMLPurifier_Lexer_DirectLex();
9 $lexer->tokenizeHTML($input, $this->config, $this->context);
12 public function invokeAttr($input)
14 $lexer = new HTMLPurifier_Lexer_DirectLex();
15 $lexer->parseAttributeString($input, $this->config, $this->context);
18 public function testExtractBody()
20 $this->expectErrorCollection(E_WARNING, 'Lexer: Extracted body');
21 $this->invoke('<body>foo</body>');
24 public function testUnclosedComment()
26 $this->expectErrorCollection(E_WARNING, 'Lexer: Unclosed comment');
27 $this->expectContext('CurrentLine', 1);
28 $this->invoke('<!-- >');
31 public function testUnescapedLt()
33 $this->expectErrorCollection(E_NOTICE, 'Lexer: Unescaped lt');
34 $this->expectContext('CurrentLine', 1);
35 $this->invoke('< foo>');
38 public function testMissingGt()
40 $this->expectErrorCollection(E_WARNING, 'Lexer: Missing gt');
41 $this->expectContext('CurrentLine', 1);
42 $this->invoke('<a href=""');
45 // these are sub-errors, will only be thrown in context of collector
47 public function testMissingAttributeKey1()
49 $this->expectErrorCollection(E_ERROR, 'Lexer: Missing attribute key');
50 $this->invokeAttr('=""');
53 public function testMissingAttributeKey2()
55 $this->expectErrorCollection(E_ERROR, 'Lexer: Missing attribute key');
56 $this->invokeAttr('foo="bar" =""');
59 public function testMissingEndQuote()
61 $this->expectErrorCollection(E_ERROR, 'Lexer: Missing end quote');
62 $this->invokeAttr('src="foo');
67 // vim: et sw=4 sts=4