Core.EscapeNonASCIICharacters now always works, even if target is UTF-8.
[htmlpurifier.git] / tests / HTMLPurifier / Lexer / DirectLex_ErrorsTest.php
blob69d3c628d456dcd8615a2c13b5cae3803d4da35f
1 <?php
3 class HTMLPurifier_Lexer_DirectLex_ErrorsTest extends HTMLPurifier_ErrorsHarness
6 function invoke($input) {
7 $lexer = new HTMLPurifier_Lexer_DirectLex();
8 $lexer->tokenizeHTML($input, $this->config, $this->context);
11 function invokeAttr($input) {
12 $lexer = new HTMLPurifier_Lexer_DirectLex();
13 $lexer->parseAttributeString($input, $this->config, $this->context);
16 function testExtractBody() {
17 $this->expectErrorCollection(E_WARNING, 'Lexer: Extracted body');
18 $this->invoke('<body>foo</body>');
21 function testUnclosedComment() {
22 $this->expectErrorCollection(E_WARNING, 'Lexer: Unclosed comment');
23 $this->expectContext('CurrentLine', 1);
24 $this->invoke('<!-- >');
27 function testUnescapedLt() {
28 $this->expectErrorCollection(E_NOTICE, 'Lexer: Unescaped lt');
29 $this->expectContext('CurrentLine', 1);
30 $this->invoke('< foo>');
33 function testMissingGt() {
34 $this->expectErrorCollection(E_WARNING, 'Lexer: Missing gt');
35 $this->expectContext('CurrentLine', 1);
36 $this->invoke('<a href=""');
39 // these are sub-errors, will only be thrown in context of collector
41 function testMissingAttributeKey1() {
42 $this->expectErrorCollection(E_ERROR, 'Lexer: Missing attribute key');
43 $this->invokeAttr('=""');
46 function testMissingAttributeKey2() {
47 $this->expectErrorCollection(E_ERROR, 'Lexer: Missing attribute key');
48 $this->invokeAttr('foo="bar" =""');
51 function testMissingEndQuote() {
52 $this->expectErrorCollection(E_ERROR, 'Lexer: Missing end quote');
53 $this->invokeAttr('src="foo');
58 // vim: et sw=4 sts=4