merged branch kreischweide/fnf-parse-exception (PR #1478)
Commits -------19f5d82
Fix08bbb19
UnitTest Discussion ---------- [CssSelector] Fatal error on invalid selector expression The following usage in a WebTestCase leads to a fatal error and ends phpunit: ``` $client = $this->createClient(); $crawler = $client->request('GET', '/'); $this->assertTrue($crawler->filter('/invalid')->count() > 0); ``` 2 commits made, first one is the UnitTest to check on correct exception throwing, second one to fix the wrong namespace.
This commit is contained in:
commit
fdd92627b7
@ -189,7 +189,7 @@ class Tokenizer
|
|||||||
$matchStart = $match[0][1];
|
$matchStart = $match[0][1];
|
||||||
|
|
||||||
if ($matchStart == $pos) {
|
if ($matchStart == $pos) {
|
||||||
throw new ParseException(sprintf('Unexpected symbol: %s at %s', $s[$pos], $pos));
|
throw new Exception\ParseException(sprintf('Unexpected symbol: %s at %s', $s[$pos], $pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = substr($s, $start, $matchStart - $start);
|
$result = substr($s, $start, $matchStart - $start);
|
||||||
|
@ -36,6 +36,14 @@ class TokenizerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals("foo[class=foo Abar ]", $this->tokensToString($this->tokenizer->tokenize('foo[class="foo \\65 bar"]')), '->tokenize() lexes an input string and returns an array of tokens');
|
$this->assertEquals("foo[class=foo Abar ]", $this->tokensToString($this->tokenizer->tokenize('foo[class="foo \\65 bar"]')), '->tokenize() lexes an input string and returns an array of tokens');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Symfony\Component\CssSelector\Exception\ParseException
|
||||||
|
*/
|
||||||
|
public function testTokenizeInvalidString()
|
||||||
|
{
|
||||||
|
$this->tokensToString($this->tokenizer->tokenize('/invalid'));
|
||||||
|
}
|
||||||
|
|
||||||
public function getCssSelectors()
|
public function getCssSelectors()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
Reference in New Issue
Block a user