[2.0] Added test that shows AnnotationParser only parses string literals with double quotes, wheras single quotes throw an Syntax Error. Removed debug output on failure for a proper syntax error exception.
This commit is contained in:
parent
1eec9f211b
commit
881eb212d2
@ -31,6 +31,7 @@ namespace Doctrine\Common\Annotations;
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class Parser
|
||||
{
|
||||
@ -165,7 +166,7 @@ class Parser
|
||||
if ($this->_lexer->lookahead === null) {
|
||||
$message .= 'end of string.';
|
||||
} else {
|
||||
$message .= "'{$token['value']}'";
|
||||
$message .= "'{$token['value']}' at position {$token['position']}.";
|
||||
}
|
||||
|
||||
throw AnnotationException::syntaxError($message);
|
||||
@ -357,8 +358,7 @@ class Parser
|
||||
return false;
|
||||
|
||||
default:
|
||||
var_dump($this->_lexer->lookahead);
|
||||
throw new \Exception("Invalid value.");
|
||||
$this->syntaxError('PlainValue');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,24 @@ DOCBLOCK;
|
||||
|
||||
$this->assertEquals(0, count($result));
|
||||
}
|
||||
|
||||
public function testAnnotationDontAcceptSingleQuotes()
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'Doctrine\Common\Annotations\AnnotationException',
|
||||
"[Syntax Error] Expected 'PlainValue', got ''' at position 10."
|
||||
);
|
||||
|
||||
$parser = $this->createTestParser();
|
||||
$parser->parse("@Name(foo='bar')");
|
||||
}
|
||||
|
||||
public function createTestParser()
|
||||
{
|
||||
$parser = new Parser();
|
||||
$parser->setDefaultAnnotationNamespace('Doctrine\Tests\Common\Annotations\\');
|
||||
return $parser;
|
||||
}
|
||||
}
|
||||
|
||||
class Name extends \Doctrine\Common\Annotations\Annotation {
|
||||
|
Loading…
x
Reference in New Issue
Block a user