From: Fabien Potencier Date: Mon, 20 Dec 2010 18:05:45 +0000 (+0100) Subject: added some unit tests for previous commit X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=146758643060c4ead9f17cdb0f79c3b651763d2a;p=web%2Fkonrad%2Ftwig.git added some unit tests for previous commit --- diff --git a/test/Twig/Tests/ExpressionParserTest.php b/test/Twig/Tests/ExpressionParserTest.php index eb81477..a6ec00b 100644 --- a/test/Twig/Tests/ExpressionParserTest.php +++ b/test/Twig/Tests/ExpressionParserTest.php @@ -12,6 +12,30 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase { /** + * @expectedException Twig_Error_Syntax + * @dataProvider getFailingTestsForAssignment + */ + public function testCanOnlyAssignToNames($template) + { + $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false)); + $parser = new Twig_Parser($env); + + $parser->parse($env->tokenize($template, 'index')); + } + + public function getFailingTestsForAssignment() + { + return array( + array('{% set false = "foo" %}'), + array('{% set true = "foo" %}'), + array('{% set none = "foo" %}'), + array('{% set 3 = "foo" %}'), + array('{% set 1 + 2 = "foo" %}'), + array('{% set "bar" = "foo" %}'), + ); + } + + /** * @dataProvider getTestsForArray */ public function testArrayExpression($template, $expected)