merged branch kreischweide/fnf-parse-exception (PR #1478)

Commits
-------

19f5d82 Fix
08bbb19 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:
Fabien Potencier 2011-06-29 19:09:40 +02:00
commit fdd92627b7
2 changed files with 9 additions and 1 deletions

View File

@ -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);

View File

@ -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(