1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-26 20:04:48 +01:00

Test lexer returning invalid token

This commit is contained in:
Nikita Popov 2015-01-17 23:46:28 +01:00
parent a710f32a6a
commit 0a445c7656

View File

@ -114,4 +114,21 @@ EOC;
'endTokenPos' => 18,
), $var->getAttributes());
}
}
/**
* @expectedException \RangeException
* @expectedExceptionMessage The lexer returned an invalid token (id=999, value=foobar)
*/
public function testInvalidToken() {
$lexer = new InvalidTokenLexer;
$parser = new Parser($lexer);
$parser->parse('dummy');
}
}
class InvalidTokenLexer extends Lexer {
public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) {
$value = 'foobar';
return 999;
}
}