From 146758643060c4ead9f17cdb0f79c3b651763d2a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 20 Dec 2010 19:05:45 +0100 Subject: [PATCH] added some unit tests for previous commit --- test/Twig/Tests/ExpressionParserTest.php | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) 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) -- 1.7.2.5