From 3031fe6b95f7a1791ab89beb4fe8c8e469582b78 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 19 Oct 2012 08:48:03 +0200 Subject: [PATCH] changed Node instances line numbers from 0 to 1 in unit tests to better reflect what really happens when using Twig --- test/Twig/Tests/Node/AutoEscapeTest.php | 10 ++-- test/Twig/Tests/Node/BlockReferenceTest.php | 8 ++- test/Twig/Tests/Node/BlockTest.php | 9 ++- test/Twig/Tests/Node/DoTest.php | 10 ++-- test/Twig/Tests/Node/Expression/ArrayTest.php | 14 ++-- test/Twig/Tests/Node/Expression/AssignNameTest.php | 4 +- test/Twig/Tests/Node/Expression/Binary/AddTest.php | 12 ++-- test/Twig/Tests/Node/Expression/Binary/AndTest.php | 12 ++-- .../Tests/Node/Expression/Binary/ConcatTest.php | 12 ++-- test/Twig/Tests/Node/Expression/Binary/DivTest.php | 12 ++-- .../Tests/Node/Expression/Binary/FloorDivTest.php | 12 ++-- test/Twig/Tests/Node/Expression/Binary/ModTest.php | 12 ++-- test/Twig/Tests/Node/Expression/Binary/MulTest.php | 12 ++-- test/Twig/Tests/Node/Expression/Binary/OrTest.php | 12 ++-- test/Twig/Tests/Node/Expression/Binary/SubTest.php | 12 ++-- .../Twig/Tests/Node/Expression/ConditionalTest.php | 16 +++--- test/Twig/Tests/Node/Expression/ConstantTest.php | 4 +- test/Twig/Tests/Node/Expression/FilterTest.php | 24 ++++---- test/Twig/Tests/Node/Expression/FunctionTest.php | 14 ++-- test/Twig/Tests/Node/Expression/GetAttrTest.php | 30 +++++----- test/Twig/Tests/Node/Expression/NameTest.php | 8 +- test/Twig/Tests/Node/Expression/ParentTest.php | 4 +- test/Twig/Tests/Node/Expression/TestTest.php | 16 +++--- test/Twig/Tests/Node/Expression/Unary/NegTest.php | 8 +- test/Twig/Tests/Node/Expression/Unary/NotTest.php | 8 +- test/Twig/Tests/Node/Expression/Unary/PosTest.php | 8 +- test/Twig/Tests/Node/ForTest.php | 64 ++++++++++--------- test/Twig/Tests/Node/IfTest.php | 45 +++++++------- test/Twig/Tests/Node/ImportTest.php | 18 ++++-- test/Twig/Tests/Node/IncludeTest.php | 50 ++++++++++------ test/Twig/Tests/Node/MacroTest.php | 13 ++-- test/Twig/Tests/Node/ModuleTest.php | 22 ++++--- test/Twig/Tests/Node/PrintTest.php | 6 +- test/Twig/Tests/Node/SandboxTest.php | 9 ++- test/Twig/Tests/Node/SandboxedModuleTest.php | 11 ++-- test/Twig/Tests/Node/SandboxedPrintTest.php | 5 +- test/Twig/Tests/Node/SetTest.php | 44 ++++++++----- test/Twig/Tests/Node/SpacelessTest.php | 9 ++- test/Twig/Tests/Node/TextTest.php | 4 +- test/Twig/Tests/ParserTest.php | 48 +++++++------- test/Twig/Tests/TokenStreamTest.php | 16 +++--- 41 files changed, 357 insertions(+), 310 deletions(-) diff --git a/test/Twig/Tests/Node/AutoEscapeTest.php b/test/Twig/Tests/Node/AutoEscapeTest.php index 129feb2..1a5ffd3 100644 --- a/test/Twig/Tests/Node/AutoEscapeTest.php +++ b/test/Twig/Tests/Node/AutoEscapeTest.php @@ -17,8 +17,8 @@ class Twig_Tests_Node_AutoEscapeTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $body = new Twig_Node(array(new Twig_Node_Text('foo', 0))); - $node = new Twig_Node_AutoEscape(true, $body, 0); + $body = new Twig_Node(array(new Twig_Node_Text('foo', 1))); + $node = new Twig_Node_AutoEscape(true, $body, 1); $this->assertEquals($body, $node->getNode('body')); $this->assertEquals(true, $node->getAttribute('value')); @@ -35,11 +35,11 @@ class Twig_Tests_Node_AutoEscapeTest extends Twig_Test_NodeTestCase public function getTests() { - $body = new Twig_Node(array(new Twig_Node_Text('foo', 0))); - $node = new Twig_Node_AutoEscape(true, $body, 0); + $body = new Twig_Node(array(new Twig_Node_Text('foo', 1))); + $node = new Twig_Node_AutoEscape(true, $body, 1); return array( - array($node, 'echo "foo";'), + array($node, "// line 1\necho \"foo\";"), ); } } diff --git a/test/Twig/Tests/Node/BlockReferenceTest.php b/test/Twig/Tests/Node/BlockReferenceTest.php index d775683..b4f545d 100644 --- a/test/Twig/Tests/Node/BlockReferenceTest.php +++ b/test/Twig/Tests/Node/BlockReferenceTest.php @@ -17,7 +17,7 @@ class Twig_Tests_Node_BlockReferenceTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $node = new Twig_Node_BlockReference('foo', 0); + $node = new Twig_Node_BlockReference('foo', 1); $this->assertEquals('foo', $node->getAttribute('name')); } @@ -34,7 +34,11 @@ class Twig_Tests_Node_BlockReferenceTest extends Twig_Test_NodeTestCase public function getTests() { return array( - array(new Twig_Node_BlockReference('foo', 0), '$this->displayBlock(\'foo\', $context, $blocks);'), + array(new Twig_Node_BlockReference('foo', 1), <<displayBlock('foo', \$context, \$blocks); +EOF + ), ); } } diff --git a/test/Twig/Tests/Node/BlockTest.php b/test/Twig/Tests/Node/BlockTest.php index ea3e324..f8de55a 100644 --- a/test/Twig/Tests/Node/BlockTest.php +++ b/test/Twig/Tests/Node/BlockTest.php @@ -17,8 +17,8 @@ class Twig_Tests_Node_BlockTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $body = new Twig_Node_Text('foo', 0); - $node = new Twig_Node_Block('foo', $body, 0); + $body = new Twig_Node_Text('foo', 1); + $node = new Twig_Node_Block('foo', $body, 1); $this->assertEquals($body, $node->getNode('body')); $this->assertEquals('foo', $node->getAttribute('name')); @@ -35,11 +35,12 @@ class Twig_Tests_Node_BlockTest extends Twig_Test_NodeTestCase public function getTests() { - $body = new Twig_Node_Text('foo', 0); - $node = new Twig_Node_Block('foo', $body, 0); + $body = new Twig_Node_Text('foo', 1); + $node = new Twig_Node_Block('foo', $body, 1); return array( array($node, <<assertEquals($expr, $node->getNode('expr')); } @@ -36,9 +36,9 @@ class Twig_Tests_Node_DoTest extends Twig_Test_NodeTestCase { $tests = array(); - $expr = new Twig_Node_Expression_Constant('foo', 0); - $node = new Twig_Node_Do($expr, 0); - $tests[] = array($node, '"foo";'); + $expr = new Twig_Node_Expression_Constant('foo', 1); + $node = new Twig_Node_Do($expr, 1); + $tests[] = array($node, "// line 1\n\"foo\";"); return $tests; } diff --git a/test/Twig/Tests/Node/Expression/ArrayTest.php b/test/Twig/Tests/Node/Expression/ArrayTest.php index 7bf878a..c6a9044 100644 --- a/test/Twig/Tests/Node/Expression/ArrayTest.php +++ b/test/Twig/Tests/Node/Expression/ArrayTest.php @@ -16,8 +16,8 @@ class Twig_Tests_Node_Expression_ArrayTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $elements = array(new Twig_Node_Expression_Constant('foo', 0), $foo = new Twig_Node_Expression_Constant('bar', 0)); - $node = new Twig_Node_Expression_Array($elements, 0); + $elements = array(new Twig_Node_Expression_Constant('foo', 1), $foo = new Twig_Node_Expression_Constant('bar', 1)); + $node = new Twig_Node_Expression_Array($elements, 1); $this->assertEquals($foo, $node->getNode(1)); } @@ -34,13 +34,13 @@ class Twig_Tests_Node_Expression_ArrayTest extends Twig_Test_NodeTestCase public function getTests() { $elements = array( - new Twig_Node_Expression_Constant('foo', 0), - new Twig_Node_Expression_Constant('bar', 0), + new Twig_Node_Expression_Constant('foo', 1), + new Twig_Node_Expression_Constant('bar', 1), - new Twig_Node_Expression_Constant('bar', 0), - new Twig_Node_Expression_Constant('foo', 0), + new Twig_Node_Expression_Constant('bar', 1), + new Twig_Node_Expression_Constant('foo', 1), ); - $node = new Twig_Node_Expression_Array($elements, 0); + $node = new Twig_Node_Expression_Array($elements, 1); return array( array($node, 'array("foo" => "bar", "bar" => "foo")'), diff --git a/test/Twig/Tests/Node/Expression/AssignNameTest.php b/test/Twig/Tests/Node/Expression/AssignNameTest.php index 7103f23..b156dcc 100644 --- a/test/Twig/Tests/Node/Expression/AssignNameTest.php +++ b/test/Twig/Tests/Node/Expression/AssignNameTest.php @@ -16,7 +16,7 @@ class Twig_Tests_Node_Expression_AssignNameTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $node = new Twig_Node_Expression_AssignName('foo', 0); + $node = new Twig_Node_Expression_AssignName('foo', 1); $this->assertEquals('foo', $node->getAttribute('name')); } @@ -32,7 +32,7 @@ class Twig_Tests_Node_Expression_AssignNameTest extends Twig_Test_NodeTestCase public function getTests() { - $node = new Twig_Node_Expression_AssignName('foo', 0); + $node = new Twig_Node_Expression_AssignName('foo', 1); return array( array($node, '$context["foo"]'), diff --git a/test/Twig/Tests/Node/Expression/Binary/AddTest.php b/test/Twig/Tests/Node/Expression/Binary/AddTest.php index 5066ae2..a0f49cb 100644 --- a/test/Twig/Tests/Node/Expression/Binary/AddTest.php +++ b/test/Twig/Tests/Node/Expression/Binary/AddTest.php @@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_AddTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Add($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Add($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -36,9 +36,9 @@ class Twig_Tests_Node_Expression_Binary_AddTest extends Twig_Test_NodeTestCase public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Add($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Add($left, $right, 1); return array( array($node, '(1 + 2)'), diff --git a/test/Twig/Tests/Node/Expression/Binary/AndTest.php b/test/Twig/Tests/Node/Expression/Binary/AndTest.php index 8f8bd3f..50e551a 100644 --- a/test/Twig/Tests/Node/Expression/Binary/AndTest.php +++ b/test/Twig/Tests/Node/Expression/Binary/AndTest.php @@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_AndTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_And($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_And($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -36,9 +36,9 @@ class Twig_Tests_Node_Expression_Binary_AndTest extends Twig_Test_NodeTestCase public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_And($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_And($left, $right, 1); return array( array($node, '(1 && 2)'), diff --git a/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php b/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php index 815c430..140329f 100644 --- a/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php +++ b/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php @@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_ConcatTest extends Twig_Test_NodeTestCas */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Concat($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Concat($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -36,9 +36,9 @@ class Twig_Tests_Node_Expression_Binary_ConcatTest extends Twig_Test_NodeTestCas public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Concat($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Concat($left, $right, 1); return array( array($node, '(1 . 2)'), diff --git a/test/Twig/Tests/Node/Expression/Binary/DivTest.php b/test/Twig/Tests/Node/Expression/Binary/DivTest.php index ce27b07..0c1a3c7 100644 --- a/test/Twig/Tests/Node/Expression/Binary/DivTest.php +++ b/test/Twig/Tests/Node/Expression/Binary/DivTest.php @@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_DivTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Div($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Div($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -36,9 +36,9 @@ class Twig_Tests_Node_Expression_Binary_DivTest extends Twig_Test_NodeTestCase public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Div($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Div($left, $right, 1); return array( array($node, '(1 / 2)'), diff --git a/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php b/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php index b5720ae..ead1fde 100644 --- a/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php +++ b/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php @@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_FloorDivTest extends Twig_Test_NodeTestC */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -36,9 +36,9 @@ class Twig_Tests_Node_Expression_Binary_FloorDivTest extends Twig_Test_NodeTestC public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 1); return array( array($node, 'intval(floor((1 / 2)))'), diff --git a/test/Twig/Tests/Node/Expression/Binary/ModTest.php b/test/Twig/Tests/Node/Expression/Binary/ModTest.php index a16f21b..4fe1a1f 100644 --- a/test/Twig/Tests/Node/Expression/Binary/ModTest.php +++ b/test/Twig/Tests/Node/Expression/Binary/ModTest.php @@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_ModTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Mod($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Mod($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -36,9 +36,9 @@ class Twig_Tests_Node_Expression_Binary_ModTest extends Twig_Test_NodeTestCase public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Mod($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Mod($left, $right, 1); return array( array($node, '(1 % 2)'), diff --git a/test/Twig/Tests/Node/Expression/Binary/MulTest.php b/test/Twig/Tests/Node/Expression/Binary/MulTest.php index f46a8ca..12bb35c 100644 --- a/test/Twig/Tests/Node/Expression/Binary/MulTest.php +++ b/test/Twig/Tests/Node/Expression/Binary/MulTest.php @@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_MulTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Mul($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Mul($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -36,9 +36,9 @@ class Twig_Tests_Node_Expression_Binary_MulTest extends Twig_Test_NodeTestCase public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Mul($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Mul($left, $right, 1); return array( array($node, '(1 * 2)'), diff --git a/test/Twig/Tests/Node/Expression/Binary/OrTest.php b/test/Twig/Tests/Node/Expression/Binary/OrTest.php index 1d60943..9534c41 100644 --- a/test/Twig/Tests/Node/Expression/Binary/OrTest.php +++ b/test/Twig/Tests/Node/Expression/Binary/OrTest.php @@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_OrTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Or($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Or($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -36,9 +36,9 @@ class Twig_Tests_Node_Expression_Binary_OrTest extends Twig_Test_NodeTestCase public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Or($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Or($left, $right, 1); return array( array($node, '(1 || 2)'), diff --git a/test/Twig/Tests/Node/Expression/Binary/SubTest.php b/test/Twig/Tests/Node/Expression/Binary/SubTest.php index a8487d9..9074893 100644 --- a/test/Twig/Tests/Node/Expression/Binary/SubTest.php +++ b/test/Twig/Tests/Node/Expression/Binary/SubTest.php @@ -16,9 +16,9 @@ class Twig_Tests_Node_Expression_Binary_SubTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Sub($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Sub($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -36,9 +36,9 @@ class Twig_Tests_Node_Expression_Binary_SubTest extends Twig_Test_NodeTestCase public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Sub($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Sub($left, $right, 1); return array( array($node, '(1 - 2)'), diff --git a/test/Twig/Tests/Node/Expression/ConditionalTest.php b/test/Twig/Tests/Node/Expression/ConditionalTest.php index 3a9d1f5..9906d51 100644 --- a/test/Twig/Tests/Node/Expression/ConditionalTest.php +++ b/test/Twig/Tests/Node/Expression/ConditionalTest.php @@ -16,10 +16,10 @@ class Twig_Tests_Node_Expression_ConditionalTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $expr1 = new Twig_Node_Expression_Constant(1, 0); - $expr2 = new Twig_Node_Expression_Constant(2, 0); - $expr3 = new Twig_Node_Expression_Constant(3, 0); - $node = new Twig_Node_Expression_Conditional($expr1, $expr2, $expr3, 0); + $expr1 = new Twig_Node_Expression_Constant(1, 1); + $expr2 = new Twig_Node_Expression_Constant(2, 1); + $expr3 = new Twig_Node_Expression_Constant(3, 1); + $node = new Twig_Node_Expression_Conditional($expr1, $expr2, $expr3, 1); $this->assertEquals($expr1, $node->getNode('expr1')); $this->assertEquals($expr2, $node->getNode('expr2')); @@ -39,10 +39,10 @@ class Twig_Tests_Node_Expression_ConditionalTest extends Twig_Test_NodeTestCase { $tests = array(); - $expr1 = new Twig_Node_Expression_Constant(1, 0); - $expr2 = new Twig_Node_Expression_Constant(2, 0); - $expr3 = new Twig_Node_Expression_Constant(3, 0); - $node = new Twig_Node_Expression_Conditional($expr1, $expr2, $expr3, 0); + $expr1 = new Twig_Node_Expression_Constant(1, 1); + $expr2 = new Twig_Node_Expression_Constant(2, 1); + $expr3 = new Twig_Node_Expression_Constant(3, 1); + $node = new Twig_Node_Expression_Conditional($expr1, $expr2, $expr3, 1); $tests[] = array($node, '((1) ? (2) : (3))'); return $tests; diff --git a/test/Twig/Tests/Node/Expression/ConstantTest.php b/test/Twig/Tests/Node/Expression/ConstantTest.php index 4ceb53a..d0dec53 100644 --- a/test/Twig/Tests/Node/Expression/ConstantTest.php +++ b/test/Twig/Tests/Node/Expression/ConstantTest.php @@ -16,7 +16,7 @@ class Twig_Tests_Node_Expression_ConstantTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $node = new Twig_Node_Expression_Constant('foo', 0); + $node = new Twig_Node_Expression_Constant('foo', 1); $this->assertEquals('foo', $node->getAttribute('value')); } @@ -34,7 +34,7 @@ class Twig_Tests_Node_Expression_ConstantTest extends Twig_Test_NodeTestCase { $tests = array(); - $node = new Twig_Node_Expression_Constant('foo', 0); + $node = new Twig_Node_Expression_Constant('foo', 1); $tests[] = array($node, '"foo"'); return $tests; diff --git a/test/Twig/Tests/Node/Expression/FilterTest.php b/test/Twig/Tests/Node/Expression/FilterTest.php index a84fda1..d37dd22 100644 --- a/test/Twig/Tests/Node/Expression/FilterTest.php +++ b/test/Twig/Tests/Node/Expression/FilterTest.php @@ -16,10 +16,10 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $expr = new Twig_Node_Expression_Constant('foo', 0); - $name = new Twig_Node_Expression_Constant('upper', 0); + $expr = new Twig_Node_Expression_Constant('foo', 1); + $name = new Twig_Node_Expression_Constant('upper', 1); $args = new Twig_Node(); - $node = new Twig_Node_Expression_Filter($expr, $name, $args, 0); + $node = new Twig_Node_Expression_Filter($expr, $name, $args, 1); $this->assertEquals($expr, $node->getNode('node')); $this->assertEquals($name, $node->getNode('filter')); @@ -38,12 +38,12 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase /** * @covers Twig_Node_Expression_Filter::compile * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage The filter "lowe" does not exist. Did you mean "lower" at line 0 + * @expectedExceptionMessage The filter "lowe" does not exist. Did you mean "lower" at line 1 */ public function testCompileUnknownFilter() { - $expr = new Twig_Node_Expression_Constant('foo', 0); - $node = $this->createFilter($expr, 'lowe', array(new Twig_Node_Expression_Constant('bar', 0), new Twig_Node_Expression_Constant('foobar', 0))); + $expr = new Twig_Node_Expression_Constant('foo', 1); + $node = $this->createFilter($expr, 'lowe', array(new Twig_Node_Expression_Constant('bar', 1), new Twig_Node_Expression_Constant('foobar', 1))); $node->compile($this->getCompiler()); } @@ -52,9 +52,9 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase { $tests = array(); - $expr = new Twig_Node_Expression_Constant('foo', 0); + $expr = new Twig_Node_Expression_Constant('foo', 1); $node = $this->createFilter($expr, 'upper'); - $node = $this->createFilter($node, 'number_format', array(new Twig_Node_Expression_Constant(2, 0), new Twig_Node_Expression_Constant('.', 0), new Twig_Node_Expression_Constant(',', 0))); + $node = $this->createFilter($node, 'number_format', array(new Twig_Node_Expression_Constant(2, 1), new Twig_Node_Expression_Constant('.', 1), new Twig_Node_Expression_Constant(',', 1))); if (function_exists('mb_get_info')) { $tests[] = array($node, 'twig_number_format_filter($this->env, twig_upper_filter($this->env, "foo"), 2, ".", ",")'); @@ -68,19 +68,19 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase /** * @covers Twig_Node_Expression_Filter::compile * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage The filter "uppe" does not exist. Did you mean "upper" at line 0 + * @expectedExceptionMessage The filter "uppe" does not exist. Did you mean "upper" at line 1 */ public function testUnknownFilter() { - $node = $this->createFilter(new Twig_Node_Expression_Constant('foo', 0), 'uppe'); + $node = $this->createFilter(new Twig_Node_Expression_Constant('foo', 1), 'uppe'); $node->compile($this->getCompiler()); } protected function createFilter($node, $name, array $arguments = array()) { - $name = new Twig_Node_Expression_Constant($name, 0); + $name = new Twig_Node_Expression_Constant($name, 1); $arguments = new Twig_Node($arguments); - return new Twig_Node_Expression_Filter($node, $name, $arguments, 0); + return new Twig_Node_Expression_Filter($node, $name, $arguments, 1); } } diff --git a/test/Twig/Tests/Node/Expression/FunctionTest.php b/test/Twig/Tests/Node/Expression/FunctionTest.php index 2733309..13f4823 100644 --- a/test/Twig/Tests/Node/Expression/FunctionTest.php +++ b/test/Twig/Tests/Node/Expression/FunctionTest.php @@ -18,7 +18,7 @@ class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase { $name = 'function'; $args = new Twig_Node(); - $node = new Twig_Node_Expression_Function($name, $args, 0); + $node = new Twig_Node_Expression_Function($name, $args, 1); $this->assertEquals($name, $node->getAttribute('name')); $this->assertEquals($args, $node->getNode('arguments')); @@ -36,7 +36,7 @@ class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase /** * @covers Twig_Node_Expression_Filter::compile * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage The function "cycl" does not exist. Did you mean "cycle" at line 0 + * @expectedExceptionMessage The function "cycl" does not exist. Did you mean "cycle" at line 1 */ public function testUnknownFunction() { @@ -57,25 +57,25 @@ class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase $node = $this->createFunction('foo'); $tests[] = array($node, 'foo()', $environment); - $node = $this->createFunction('foo', array(new Twig_Node_Expression_Constant('bar', 0), new Twig_Node_Expression_Constant('foobar', 0))); + $node = $this->createFunction('foo', array(new Twig_Node_Expression_Constant('bar', 1), new Twig_Node_Expression_Constant('foobar', 1))); $tests[] = array($node, 'foo("bar", "foobar")', $environment); $node = $this->createFunction('bar'); $tests[] = array($node, 'bar($this->env)', $environment); - $node = $this->createFunction('bar', array(new Twig_Node_Expression_Constant('bar', 0))); + $node = $this->createFunction('bar', array(new Twig_Node_Expression_Constant('bar', 1))); $tests[] = array($node, 'bar($this->env, "bar")', $environment); $node = $this->createFunction('foofoo'); $tests[] = array($node, 'foofoo($context)', $environment); - $node = $this->createFunction('foofoo', array(new Twig_Node_Expression_Constant('bar', 0))); + $node = $this->createFunction('foofoo', array(new Twig_Node_Expression_Constant('bar', 1))); $tests[] = array($node, 'foofoo($context, "bar")', $environment); $node = $this->createFunction('foobar'); $tests[] = array($node, 'foobar($this->env, $context)', $environment); - $node = $this->createFunction('foobar', array(new Twig_Node_Expression_Constant('bar', 0))); + $node = $this->createFunction('foobar', array(new Twig_Node_Expression_Constant('bar', 1))); $tests[] = array($node, 'foobar($this->env, $context, "bar")', $environment); return $tests; @@ -83,6 +83,6 @@ class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase protected function createFunction($name, array $arguments = array()) { - return new Twig_Node_Expression_Function($name, new Twig_Node($arguments), 0); + return new Twig_Node_Expression_Function($name, new Twig_Node($arguments), 1); } } diff --git a/test/Twig/Tests/Node/Expression/GetAttrTest.php b/test/Twig/Tests/Node/Expression/GetAttrTest.php index a1c36b7..6a63cce 100644 --- a/test/Twig/Tests/Node/Expression/GetAttrTest.php +++ b/test/Twig/Tests/Node/Expression/GetAttrTest.php @@ -16,12 +16,12 @@ class Twig_Tests_Node_Expression_GetAttrTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $expr = new Twig_Node_Expression_Name('foo', 0); - $attr = new Twig_Node_Expression_Constant('bar', 0); - $args = new Twig_Node_Expression_Array(array(), 0); - $args->addElement(new Twig_Node_Expression_Name('foo', 0)); - $args->addElement(new Twig_Node_Expression_Constant('bar', 0)); - $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ARRAY_CALL, 0); + $expr = new Twig_Node_Expression_Name('foo', 1); + $attr = new Twig_Node_Expression_Constant('bar', 1); + $args = new Twig_Node_Expression_Array(array(), 1); + $args->addElement(new Twig_Node_Expression_Name('foo', 1)); + $args->addElement(new Twig_Node_Expression_Constant('bar', 1)); + $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ARRAY_CALL, 1); $this->assertEquals($expr, $node->getNode('node')); $this->assertEquals($attr, $node->getNode('attribute')); @@ -42,19 +42,19 @@ class Twig_Tests_Node_Expression_GetAttrTest extends Twig_Test_NodeTestCase { $tests = array(); - $expr = new Twig_Node_Expression_Name('foo', 0); - $attr = new Twig_Node_Expression_Constant('bar', 0); - $args = new Twig_Node_Expression_Array(array(), 0); - $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ANY_CALL, 0); + $expr = new Twig_Node_Expression_Name('foo', 1); + $attr = new Twig_Node_Expression_Constant('bar', 1); + $args = new Twig_Node_Expression_Array(array(), 1); + $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ANY_CALL, 1); $tests[] = array($node, sprintf('%s%s, "bar")', $this->getAttributeGetter(), $this->getVariableGetter('foo'))); - $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ARRAY_CALL, 0); + $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ARRAY_CALL, 1); $tests[] = array($node, sprintf('%s%s, "bar", array(), "array")', $this->getAttributeGetter(), $this->getVariableGetter('foo'))); - $args = new Twig_Node_Expression_Array(array(), 0); - $args->addElement(new Twig_Node_Expression_Name('foo', 0)); - $args->addElement(new Twig_Node_Expression_Constant('bar', 0)); - $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::METHOD_CALL, 0); + $args = new Twig_Node_Expression_Array(array(), 1); + $args->addElement(new Twig_Node_Expression_Name('foo', 1)); + $args->addElement(new Twig_Node_Expression_Constant('bar', 1)); + $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::METHOD_CALL, 1); $tests[] = array($node, sprintf('%s%s, "bar", array(0 => %s, 1 => "bar"), "method")', $this->getAttributeGetter(), $this->getVariableGetter('foo'), $this->getVariableGetter('foo'))); return $tests; diff --git a/test/Twig/Tests/Node/Expression/NameTest.php b/test/Twig/Tests/Node/Expression/NameTest.php index d333f83..945bd9f 100644 --- a/test/Twig/Tests/Node/Expression/NameTest.php +++ b/test/Twig/Tests/Node/Expression/NameTest.php @@ -16,7 +16,7 @@ class Twig_Tests_Node_Expression_NameTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $node = new Twig_Node_Expression_Name('foo', 0); + $node = new Twig_Node_Expression_Name('foo', 1); $this->assertEquals('foo', $node->getAttribute('name')); } @@ -32,9 +32,9 @@ class Twig_Tests_Node_Expression_NameTest extends Twig_Test_NodeTestCase public function getTests() { - $node = new Twig_Node_Expression_Name('foo', 0); - $self = new Twig_Node_Expression_Name('_self', 0); - $context = new Twig_Node_Expression_Name('_context', 0); + $node = new Twig_Node_Expression_Name('foo', 1); + $self = new Twig_Node_Expression_Name('_self', 1); + $context = new Twig_Node_Expression_Name('_context', 1); $env = new Twig_Environment(null, array('strict_variables' => true)); $env1 = new Twig_Environment(null, array('strict_variables' => false)); diff --git a/test/Twig/Tests/Node/Expression/ParentTest.php b/test/Twig/Tests/Node/Expression/ParentTest.php index 0f5d7b4..4d40419 100644 --- a/test/Twig/Tests/Node/Expression/ParentTest.php +++ b/test/Twig/Tests/Node/Expression/ParentTest.php @@ -16,7 +16,7 @@ class Twig_Tests_Node_Expression_ParentTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $node = new Twig_Node_Expression_Parent('foo', 0); + $node = new Twig_Node_Expression_Parent('foo', 1); $this->assertEquals('foo', $node->getAttribute('name')); } @@ -33,7 +33,7 @@ class Twig_Tests_Node_Expression_ParentTest extends Twig_Test_NodeTestCase public function getTests() { $tests = array(); - $tests[] = array(new Twig_Node_Expression_Parent('foo', 0), '$this->renderParentBlock("foo", $context, $blocks)'); + $tests[] = array(new Twig_Node_Expression_Parent('foo', 1), '$this->renderParentBlock("foo", $context, $blocks)'); return $tests; } diff --git a/test/Twig/Tests/Node/Expression/TestTest.php b/test/Twig/Tests/Node/Expression/TestTest.php index d89db60..4d0cf41 100644 --- a/test/Twig/Tests/Node/Expression/TestTest.php +++ b/test/Twig/Tests/Node/Expression/TestTest.php @@ -16,10 +16,10 @@ class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $expr = new Twig_Node_Expression_Constant('foo', 0); - $name = new Twig_Node_Expression_Constant('null', 0); + $expr = new Twig_Node_Expression_Constant('foo', 1); + $name = new Twig_Node_Expression_Constant('null', 1); $args = new Twig_Node(); - $node = new Twig_Node_Expression_Test($expr, $name, $args, 0); + $node = new Twig_Node_Expression_Test($expr, $name, $args, 1); $this->assertEquals($expr, $node->getNode('node')); $this->assertEquals($args, $node->getNode('arguments')); @@ -39,8 +39,8 @@ class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase { $tests = array(); - $expr = new Twig_Node_Expression_Constant('foo', 0); - $node = new Twig_Node_Expression_Test_Null($expr, 'null', new Twig_Node(array()), 0); + $expr = new Twig_Node_Expression_Constant('foo', 1); + $node = new Twig_Node_Expression_Test_Null($expr, 'null', new Twig_Node(array()), 1); $tests[] = array($node, '(null === "foo")'); @@ -50,16 +50,16 @@ class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase /** * @covers Twig_Node_Expression_Filter::compile * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage The test "nul" does not exist. Did you mean "null" at line 0 + * @expectedExceptionMessage The test "nul" does not exist. Did you mean "null" at line 1 */ public function testUnknownTest() { - $node = $this->createTest(new Twig_Node_Expression_Constant('foo', 0), 'nul'); + $node = $this->createTest(new Twig_Node_Expression_Constant('foo', 1), 'nul'); $node->compile($this->getCompiler()); } protected function createTest($node, $name, array $arguments = array()) { - return new Twig_Node_Expression_Test($node, $name, new Twig_Node($arguments), 0); + return new Twig_Node_Expression_Test($node, $name, new Twig_Node($arguments), 1); } } diff --git a/test/Twig/Tests/Node/Expression/Unary/NegTest.php b/test/Twig/Tests/Node/Expression/Unary/NegTest.php index 05187c2..d55ab33 100644 --- a/test/Twig/Tests/Node/Expression/Unary/NegTest.php +++ b/test/Twig/Tests/Node/Expression/Unary/NegTest.php @@ -16,8 +16,8 @@ class Twig_Tests_Node_Expression_Unary_NegTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $expr = new Twig_Node_Expression_Constant(1, 0); - $node = new Twig_Node_Expression_Unary_Neg($expr, 0); + $expr = new Twig_Node_Expression_Constant(1, 1); + $node = new Twig_Node_Expression_Unary_Neg($expr, 1); $this->assertEquals($expr, $node->getNode('node')); } @@ -34,8 +34,8 @@ class Twig_Tests_Node_Expression_Unary_NegTest extends Twig_Test_NodeTestCase public function getTests() { - $node = new Twig_Node_Expression_Constant(1, 0); - $node = new Twig_Node_Expression_Unary_Neg($node, 0); + $node = new Twig_Node_Expression_Constant(1, 1); + $node = new Twig_Node_Expression_Unary_Neg($node, 1); return array( array($node, '(-1)'), diff --git a/test/Twig/Tests/Node/Expression/Unary/NotTest.php b/test/Twig/Tests/Node/Expression/Unary/NotTest.php index 74815a9..625c252 100644 --- a/test/Twig/Tests/Node/Expression/Unary/NotTest.php +++ b/test/Twig/Tests/Node/Expression/Unary/NotTest.php @@ -16,8 +16,8 @@ class Twig_Tests_Node_Expression_Unary_NotTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $expr = new Twig_Node_Expression_Constant(1, 0); - $node = new Twig_Node_Expression_Unary_Not($expr, 0); + $expr = new Twig_Node_Expression_Constant(1, 1); + $node = new Twig_Node_Expression_Unary_Not($expr, 1); $this->assertEquals($expr, $node->getNode('node')); } @@ -34,8 +34,8 @@ class Twig_Tests_Node_Expression_Unary_NotTest extends Twig_Test_NodeTestCase public function getTests() { - $node = new Twig_Node_Expression_Constant(1, 0); - $node = new Twig_Node_Expression_Unary_Not($node, 0); + $node = new Twig_Node_Expression_Constant(1, 1); + $node = new Twig_Node_Expression_Unary_Not($node, 1); return array( array($node, '(!1)'), diff --git a/test/Twig/Tests/Node/Expression/Unary/PosTest.php b/test/Twig/Tests/Node/Expression/Unary/PosTest.php index 04cf38c..047a097 100644 --- a/test/Twig/Tests/Node/Expression/Unary/PosTest.php +++ b/test/Twig/Tests/Node/Expression/Unary/PosTest.php @@ -16,8 +16,8 @@ class Twig_Tests_Node_Expression_Unary_PosTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $expr = new Twig_Node_Expression_Constant(1, 0); - $node = new Twig_Node_Expression_Unary_Pos($expr, 0); + $expr = new Twig_Node_Expression_Constant(1, 1); + $node = new Twig_Node_Expression_Unary_Pos($expr, 1); $this->assertEquals($expr, $node->getNode('node')); } @@ -34,8 +34,8 @@ class Twig_Tests_Node_Expression_Unary_PosTest extends Twig_Test_NodeTestCase public function getTests() { - $node = new Twig_Node_Expression_Constant(1, 0); - $node = new Twig_Node_Expression_Unary_Pos($node, 0); + $node = new Twig_Node_Expression_Constant(1, 1); + $node = new Twig_Node_Expression_Unary_Pos($node, 1); return array( array($node, '(+1)'), diff --git a/test/Twig/Tests/Node/ForTest.php b/test/Twig/Tests/Node/ForTest.php index 273df7b..23441fc 100644 --- a/test/Twig/Tests/Node/ForTest.php +++ b/test/Twig/Tests/Node/ForTest.php @@ -17,13 +17,13 @@ class Twig_Tests_Node_ForTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $keyTarget = new Twig_Node_Expression_AssignName('key', 0); - $valueTarget = new Twig_Node_Expression_AssignName('item', 0); - $seq = new Twig_Node_Expression_Name('items', 0); - $ifexpr = new Twig_Node_Expression_Constant(true, 0); - $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0)), array(), 0); + $keyTarget = new Twig_Node_Expression_AssignName('key', 1); + $valueTarget = new Twig_Node_Expression_AssignName('item', 1); + $seq = new Twig_Node_Expression_Name('items', 1); + $ifexpr = new Twig_Node_Expression_Constant(true, 1); + $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1)), array(), 1); $else = null; - $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 0); + $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); $node->setAttribute('with_loop', false); $this->assertEquals($keyTarget, $node->getNode('key_target')); @@ -34,8 +34,8 @@ class Twig_Tests_Node_ForTest extends Twig_Test_NodeTestCase $this->assertEquals($body, $node->getNode('body')->getNode('tests')->getNode(1)->getNode(0)); $this->assertEquals(null, $node->getNode('else')); - $else = new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0); - $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 0); + $else = new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1); + $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); $node->setAttribute('with_loop', false); $this->assertEquals($else, $node->getNode('else')); } @@ -53,16 +53,17 @@ class Twig_Tests_Node_ForTest extends Twig_Test_NodeTestCase { $tests = array(); - $keyTarget = new Twig_Node_Expression_AssignName('key', 0); - $valueTarget = new Twig_Node_Expression_AssignName('item', 0); - $seq = new Twig_Node_Expression_Name('items', 0); + $keyTarget = new Twig_Node_Expression_AssignName('key', 1); + $valueTarget = new Twig_Node_Expression_AssignName('item', 1); + $seq = new Twig_Node_Expression_Name('items', 1); $ifexpr = null; - $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0)), array(), 0); + $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1)), array(), 1); $else = null; - $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 0); + $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); $node->setAttribute('with_loop', false); $tests[] = array($node, <<getVariableGetter('items')}); foreach (\$context['_seq'] as \$context["key"] => \$context["item"]) { @@ -74,16 +75,17 @@ unset(\$context['_seq'], \$context['_iterated'], \$context['key'], \$context['it EOF ); - $keyTarget = new Twig_Node_Expression_AssignName('k', 0); - $valueTarget = new Twig_Node_Expression_AssignName('v', 0); - $seq = new Twig_Node_Expression_Name('values', 0); + $keyTarget = new Twig_Node_Expression_AssignName('k', 1); + $valueTarget = new Twig_Node_Expression_AssignName('v', 1); + $seq = new Twig_Node_Expression_Name('values', 1); $ifexpr = null; - $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0)), array(), 0); + $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1)), array(), 1); $else = null; - $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 0); + $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); $node->setAttribute('with_loop', true); $tests[] = array($node, <<getVariableGetter('values')}); \$context['loop'] = array( @@ -116,16 +118,17 @@ unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], EOF ); - $keyTarget = new Twig_Node_Expression_AssignName('k', 0); - $valueTarget = new Twig_Node_Expression_AssignName('v', 0); - $seq = new Twig_Node_Expression_Name('values', 0); - $ifexpr = new Twig_Node_Expression_Constant(true, 0); - $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0)), array(), 0); + $keyTarget = new Twig_Node_Expression_AssignName('k', 1); + $valueTarget = new Twig_Node_Expression_AssignName('v', 1); + $seq = new Twig_Node_Expression_Name('values', 1); + $ifexpr = new Twig_Node_Expression_Constant(true, 1); + $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1)), array(), 1); $else = null; - $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 0); + $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); $node->setAttribute('with_loop', true); $tests[] = array($node, <<getVariableGetter('values')}); \$context['loop'] = array( @@ -148,16 +151,17 @@ unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], EOF ); - $keyTarget = new Twig_Node_Expression_AssignName('k', 0); - $valueTarget = new Twig_Node_Expression_AssignName('v', 0); - $seq = new Twig_Node_Expression_Name('values', 0); + $keyTarget = new Twig_Node_Expression_AssignName('k', 1); + $valueTarget = new Twig_Node_Expression_AssignName('v', 1); + $seq = new Twig_Node_Expression_Name('values', 1); $ifexpr = null; - $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0)), array(), 0); - $else = new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0); - $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 0); + $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1)), array(), 1); + $else = new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1); + $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); $node->setAttribute('with_loop', true); $tests[] = array($node, <<getVariableGetter('values')}); \$context['_iterated'] = false; diff --git a/test/Twig/Tests/Node/IfTest.php b/test/Twig/Tests/Node/IfTest.php index ce68bc3..99b76f8 100644 --- a/test/Twig/Tests/Node/IfTest.php +++ b/test/Twig/Tests/Node/IfTest.php @@ -18,17 +18,17 @@ class Twig_Tests_Node_IfTest extends Twig_Test_NodeTestCase public function testConstructor() { $t = new Twig_Node(array( - new Twig_Node_Expression_Constant(true, 0), - new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0), - ), array(), 0); + new Twig_Node_Expression_Constant(true, 1), + new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1), + ), array(), 1); $else = null; - $node = new Twig_Node_If($t, $else, 0); + $node = new Twig_Node_If($t, $else, 1); $this->assertEquals($t, $node->getNode('tests')); $this->assertEquals(null, $node->getNode('else')); - $else = new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 0), 0); - $node = new Twig_Node_If($t, $else, 0); + $else = new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 1), 1); + $node = new Twig_Node_If($t, $else, 1); $this->assertEquals($else, $node->getNode('else')); } @@ -46,13 +46,14 @@ class Twig_Tests_Node_IfTest extends Twig_Test_NodeTestCase $tests = array(); $t = new Twig_Node(array( - new Twig_Node_Expression_Constant(true, 0), - new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0), - ), array(), 0); + new Twig_Node_Expression_Constant(true, 1), + new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1), + ), array(), 1); $else = null; - $node = new Twig_Node_If($t, $else, 0); + $node = new Twig_Node_If($t, $else, 1); $tests[] = array($node, <<getVariableGetter('foo')}; } @@ -60,15 +61,16 @@ EOF ); $t = new Twig_Node(array( - new Twig_Node_Expression_Constant(true, 0), - new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0), - new Twig_Node_Expression_Constant(false, 0), - new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 0), 0), - ), array(), 0); + new Twig_Node_Expression_Constant(true, 1), + new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1), + new Twig_Node_Expression_Constant(false, 1), + new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 1), 1), + ), array(), 1); $else = null; - $node = new Twig_Node_If($t, $else, 0); + $node = new Twig_Node_If($t, $else, 1); $tests[] = array($node, <<getVariableGetter('foo')}; } elseif (false) { @@ -78,13 +80,14 @@ EOF ); $t = new Twig_Node(array( - new Twig_Node_Expression_Constant(true, 0), - new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0), - ), array(), 0); - $else = new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 0), 0); - $node = new Twig_Node_If($t, $else, 0); + new Twig_Node_Expression_Constant(true, 1), + new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1), + ), array(), 1); + $else = new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 1), 1); + $node = new Twig_Node_If($t, $else, 1); $tests[] = array($node, <<getVariableGetter('foo')}; } else { diff --git a/test/Twig/Tests/Node/ImportTest.php b/test/Twig/Tests/Node/ImportTest.php index 64286b8..99ddeda 100644 --- a/test/Twig/Tests/Node/ImportTest.php +++ b/test/Twig/Tests/Node/ImportTest.php @@ -17,9 +17,9 @@ class Twig_Tests_Node_ImportTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $macro = new Twig_Node_Expression_Constant('foo.twig', 0); - $var = new Twig_Node_Expression_AssignName('macro', 0); - $node = new Twig_Node_Import($macro, $var, 0); + $macro = new Twig_Node_Expression_Constant('foo.twig', 1); + $var = new Twig_Node_Expression_AssignName('macro', 1); + $node = new Twig_Node_Import($macro, $var, 1); $this->assertEquals($macro, $node->getNode('expr')); $this->assertEquals($var, $node->getNode('var')); @@ -38,11 +38,15 @@ class Twig_Tests_Node_ImportTest extends Twig_Test_NodeTestCase { $tests = array(); - $macro = new Twig_Node_Expression_Constant('foo.twig', 0); - $var = new Twig_Node_Expression_AssignName('macro', 0); - $node = new Twig_Node_Import($macro, $var, 0); + $macro = new Twig_Node_Expression_Constant('foo.twig', 1); + $var = new Twig_Node_Expression_AssignName('macro', 1); + $node = new Twig_Node_Import($macro, $var, 1); - $tests[] = array($node, '$context["macro"] = $this->env->loadTemplate("foo.twig");'); + $tests[] = array($node, <<env->loadTemplate("foo.twig"); +EOF + ); return $tests; } diff --git a/test/Twig/Tests/Node/IncludeTest.php b/test/Twig/Tests/Node/IncludeTest.php index 7e1db64..e6c2bfa 100644 --- a/test/Twig/Tests/Node/IncludeTest.php +++ b/test/Twig/Tests/Node/IncludeTest.php @@ -17,15 +17,15 @@ class Twig_Tests_Node_IncludeTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $expr = new Twig_Node_Expression_Constant('foo.twig', 0); - $node = new Twig_Node_Include($expr, null, false, false, 0); + $expr = new Twig_Node_Expression_Constant('foo.twig', 1); + $node = new Twig_Node_Include($expr, null, false, false, 1); $this->assertEquals(null, $node->getNode('variables')); $this->assertEquals($expr, $node->getNode('expr')); $this->assertFalse($node->getAttribute('only')); - $vars = new Twig_Node_Expression_Array(array(new Twig_Node_Expression_Constant('foo', 0), new Twig_Node_Expression_Constant(true, 0)), 0); - $node = new Twig_Node_Include($expr, $vars, true, false, 0); + $vars = new Twig_Node_Expression_Array(array(new Twig_Node_Expression_Constant('foo', 1), new Twig_Node_Expression_Constant(true, 1)), 1); + $node = new Twig_Node_Include($expr, $vars, true, false, 1); $this->assertEquals($vars, $node->getNode('variables')); $this->assertTrue($node->getAttribute('only')); } @@ -43,33 +43,47 @@ class Twig_Tests_Node_IncludeTest extends Twig_Test_NodeTestCase { $tests = array(); - $expr = new Twig_Node_Expression_Constant('foo.twig', 0); - $node = new Twig_Node_Include($expr, null, false, false, 0); - $tests[] = array($node, '$this->env->loadTemplate("foo.twig")->display($context);'); + $expr = new Twig_Node_Expression_Constant('foo.twig', 1); + $node = new Twig_Node_Include($expr, null, false, false, 1); + $tests[] = array($node, <<env->loadTemplate("foo.twig")->display(\$context); +EOF + ); $expr = new Twig_Node_Expression_Conditional( - new Twig_Node_Expression_Constant(true, 0), - new Twig_Node_Expression_Constant('foo', 0), - new Twig_Node_Expression_Constant('foo', 0), + new Twig_Node_Expression_Constant(true, 1), + new Twig_Node_Expression_Constant('foo', 1), + new Twig_Node_Expression_Constant('foo', 1), 0 ); - $node = new Twig_Node_Include($expr, null, false, false, 0); + $node = new Twig_Node_Include($expr, null, false, false, 1); $tests[] = array($node, <<env->resolveTemplate(((true) ? ("foo") : ("foo"))); \$template->display(\$context); EOF ); - $expr = new Twig_Node_Expression_Constant('foo.twig', 0); - $vars = new Twig_Node_Expression_Array(array(new Twig_Node_Expression_Constant('foo', 0), new Twig_Node_Expression_Constant(true, 0)), 0); - $node = new Twig_Node_Include($expr, $vars, false, false, 0); - $tests[] = array($node, '$this->env->loadTemplate("foo.twig")->display(array_merge($context, array("foo" => true)));'); + $expr = new Twig_Node_Expression_Constant('foo.twig', 1); + $vars = new Twig_Node_Expression_Array(array(new Twig_Node_Expression_Constant('foo', 1), new Twig_Node_Expression_Constant(true, 1)), 1); + $node = new Twig_Node_Include($expr, $vars, false, false, 1); + $tests[] = array($node, <<env->loadTemplate("foo.twig")->display(array_merge(\$context, array("foo" => true))); +EOF + ); - $node = new Twig_Node_Include($expr, $vars, true, false, 0); - $tests[] = array($node, '$this->env->loadTemplate("foo.twig")->display(array("foo" => true));'); + $node = new Twig_Node_Include($expr, $vars, true, false, 1); + $tests[] = array($node, <<env->loadTemplate("foo.twig")->display(array("foo" => true)); +EOF + ); - $node = new Twig_Node_Include($expr, $vars, true, true, 0); + $node = new Twig_Node_Include($expr, $vars, true, true, 1); $tests[] = array($node, <<env->loadTemplate("foo.twig")->display(array("foo" => true)); } catch (Twig_Error_Loader \$e) { diff --git a/test/Twig/Tests/Node/MacroTest.php b/test/Twig/Tests/Node/MacroTest.php index 4af1005..260bd75 100644 --- a/test/Twig/Tests/Node/MacroTest.php +++ b/test/Twig/Tests/Node/MacroTest.php @@ -17,9 +17,9 @@ class Twig_Tests_Node_MacroTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $body = new Twig_Node_Text('foo', 0); - $arguments = new Twig_Node(array(new Twig_Node_Expression_Name('foo', 0)), array(), 0); - $node = new Twig_Node_Macro('foo', $body, $arguments, 0); + $body = new Twig_Node_Text('foo', 1); + $arguments = new Twig_Node(array(new Twig_Node_Expression_Name('foo', 1)), array(), 1); + $node = new Twig_Node_Macro('foo', $body, $arguments, 1); $this->assertEquals($body, $node->getNode('body')); $this->assertEquals($arguments, $node->getNode('arguments')); @@ -37,12 +37,13 @@ class Twig_Tests_Node_MacroTest extends Twig_Test_NodeTestCase public function getTests() { - $body = new Twig_Node_Text('foo', 0); - $arguments = new Twig_Node(array(new Twig_Node_Expression_Name('foo', 0)), array(), 0); - $node = new Twig_Node_Macro('foo', $body, $arguments, 0); + $body = new Twig_Node_Text('foo', 1); + $arguments = new Twig_Node(array(new Twig_Node_Expression_Name('foo', 1)), array(), 1); + $node = new Twig_Node_Macro('foo', $body, $arguments, 1); return array( array($node, <<env->mergeGlobals(array( diff --git a/test/Twig/Tests/Node/ModuleTest.php b/test/Twig/Tests/Node/ModuleTest.php index 1a8fea8..9ef8d45 100644 --- a/test/Twig/Tests/Node/ModuleTest.php +++ b/test/Twig/Tests/Node/ModuleTest.php @@ -17,8 +17,8 @@ class Twig_Tests_Node_ModuleTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $body = new Twig_Node_Text('foo', 0); - $parent = new Twig_Node_Expression_Constant('layout.twig', 0); + $body = new Twig_Node_Text('foo', 1); + $parent = new Twig_Node_Expression_Constant('layout.twig', 1); $blocks = new Twig_Node(); $macros = new Twig_Node(); $traits = new Twig_Node(); @@ -54,7 +54,7 @@ class Twig_Tests_Node_ModuleTest extends Twig_Test_NodeTestCase $tests = array(); - $body = new Twig_Node_Text('foo', 0); + $body = new Twig_Node_Text('foo', 1); $extends = null; $blocks = new Twig_Node(); $macros = new Twig_Node(); @@ -80,6 +80,7 @@ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template protected function doDisplay(array \$context, array \$blocks = array()) { + // line 1 echo "foo"; } @@ -90,16 +91,16 @@ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template public function getDebugInfo() { - return array (); + return array ( 17 => 1,); } } EOF , $twig); - $import = new Twig_Node_Import(new Twig_Node_Expression_Constant('foo.twig', 0), new Twig_Node_Expression_AssignName('macro', 0), 0); + $import = new Twig_Node_Import(new Twig_Node_Expression_Constant('foo.twig', 1), new Twig_Node_Expression_AssignName('macro', 1), 1); $body = new Twig_Node(array($import)); - $extends = new Twig_Node_Expression_Constant('layout.twig', 0); + $extends = new Twig_Node_Expression_Constant('layout.twig', 1); $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $filename); $tests[] = array($node, <<env->loadTemplate("foo.twig"); \$this->parent->display(\$context, array_merge(\$this->blocks, \$blocks)); } @@ -141,7 +143,7 @@ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template public function getDebugInfo() { - return array (); + return array ( 22 => 1,); } } EOF @@ -149,9 +151,9 @@ EOF $body = new Twig_Node(); $extends = new Twig_Node_Expression_Conditional( - new Twig_Node_Expression_Constant(true, 0), - new Twig_Node_Expression_Constant('foo', 0), - new Twig_Node_Expression_Constant('foo', 0), + new Twig_Node_Expression_Constant(true, 1), + new Twig_Node_Expression_Constant('foo', 1), + new Twig_Node_Expression_Constant('foo', 1), 0 ); diff --git a/test/Twig/Tests/Node/PrintTest.php b/test/Twig/Tests/Node/PrintTest.php index 3df6ac7..1294260 100644 --- a/test/Twig/Tests/Node/PrintTest.php +++ b/test/Twig/Tests/Node/PrintTest.php @@ -17,8 +17,8 @@ class Twig_Tests_Node_PrintTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $expr = new Twig_Node_Expression_Constant('foo', 0); - $node = new Twig_Node_Print($expr, 0); + $expr = new Twig_Node_Expression_Constant('foo', 1); + $node = new Twig_Node_Print($expr, 1); $this->assertEquals($expr, $node->getNode('expr')); } @@ -35,7 +35,7 @@ class Twig_Tests_Node_PrintTest extends Twig_Test_NodeTestCase public function getTests() { $tests = array(); - $tests[] = array(new Twig_Node_Print(new Twig_Node_Expression_Constant('foo', 0), 0), 'echo "foo";'); + $tests[] = array(new Twig_Node_Print(new Twig_Node_Expression_Constant('foo', 1), 1), "// line 1\necho \"foo\";"); return $tests; } diff --git a/test/Twig/Tests/Node/SandboxTest.php b/test/Twig/Tests/Node/SandboxTest.php index 7b57f6b..2ca75ff 100644 --- a/test/Twig/Tests/Node/SandboxTest.php +++ b/test/Twig/Tests/Node/SandboxTest.php @@ -17,8 +17,8 @@ class Twig_Tests_Node_SandboxTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $body = new Twig_Node_Text('foo', 0); - $node = new Twig_Node_Sandbox($body, 0); + $body = new Twig_Node_Text('foo', 1); + $node = new Twig_Node_Sandbox($body, 1); $this->assertEquals($body, $node->getNode('body')); } @@ -36,10 +36,11 @@ class Twig_Tests_Node_SandboxTest extends Twig_Test_NodeTestCase { $tests = array(); - $body = new Twig_Node_Text('foo', 0); - $node = new Twig_Node_Sandbox($body, 0); + $body = new Twig_Node_Text('foo', 1); + $node = new Twig_Node_Sandbox($body, 1); $tests[] = array($node, <<env->getExtension('sandbox'); if (!\$alreadySandboxed = \$sandbox->isSandboxed()) { \$sandbox->enableSandbox(); diff --git a/test/Twig/Tests/Node/SandboxedModuleTest.php b/test/Twig/Tests/Node/SandboxedModuleTest.php index 24d879e..b944cc3 100644 --- a/test/Twig/Tests/Node/SandboxedModuleTest.php +++ b/test/Twig/Tests/Node/SandboxedModuleTest.php @@ -17,8 +17,8 @@ class Twig_Tests_Node_SandboxedModuleTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $body = new Twig_Node_Text('foo', 0); - $parent = new Twig_Node_Expression_Constant('layout.twig', 0); + $body = new Twig_Node_Text('foo', 1); + $parent = new Twig_Node_Expression_Constant('layout.twig', 1); $blocks = new Twig_Node(); $macros = new Twig_Node(); $traits = new Twig_Node(); @@ -50,7 +50,7 @@ class Twig_Tests_Node_SandboxedModuleTest extends Twig_Test_NodeTestCase $tests = array(); - $body = new Twig_Node_Text('foo', 0); + $body = new Twig_Node_Text('foo', 1); $extends = null; $blocks = new Twig_Node(); $macros = new Twig_Node(); @@ -79,6 +79,7 @@ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template protected function doDisplay(array \$context, array \$blocks = array()) { \$this->checkSecurity(); + // line 1 echo "foo"; } @@ -97,14 +98,14 @@ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template public function getDebugInfo() { - return array (); + return array ( 18 => 1,); } } EOF , $twig); $body = new Twig_Node(); - $extends = new Twig_Node_Expression_Constant('layout.twig', 0); + $extends = new Twig_Node_Expression_Constant('layout.twig', 1); $blocks = new Twig_Node(); $macros = new Twig_Node(); $traits = new Twig_Node(); diff --git a/test/Twig/Tests/Node/SandboxedPrintTest.php b/test/Twig/Tests/Node/SandboxedPrintTest.php index 1837aa5..11fe361 100644 --- a/test/Twig/Tests/Node/SandboxedPrintTest.php +++ b/test/Twig/Tests/Node/SandboxedPrintTest.php @@ -17,7 +17,7 @@ class Twig_Tests_Node_SandboxedPrintTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $node = new Twig_Node_SandboxedPrint($expr = new Twig_Node_Expression_Constant('foo', 0), 0); + $node = new Twig_Node_SandboxedPrint($expr = new Twig_Node_Expression_Constant('foo', 1), 1); $this->assertEquals($expr, $node->getNode('expr')); } @@ -35,7 +35,8 @@ class Twig_Tests_Node_SandboxedPrintTest extends Twig_Test_NodeTestCase { $tests = array(); - $tests[] = array(new Twig_Node_SandboxedPrint(new Twig_Node_Expression_Constant('foo', 0), 0), <<env->getExtension('sandbox')->ensureToStringAllowed("foo"); EOF ); diff --git a/test/Twig/Tests/Node/SetTest.php b/test/Twig/Tests/Node/SetTest.php index 6bc9ccd..276e020 100644 --- a/test/Twig/Tests/Node/SetTest.php +++ b/test/Twig/Tests/Node/SetTest.php @@ -17,9 +17,9 @@ class Twig_Tests_Node_SetTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 0)), array(), 0); - $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 0)), array(), 0); - $node = new Twig_Node_Set(false, $names, $values, 0); + $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1); + $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 1)), array(), 1); + $node = new Twig_Node_Set(false, $names, $values, 1); $this->assertEquals($names, $node->getNode('names')); $this->assertEquals($values, $node->getNode('values')); @@ -39,30 +39,40 @@ class Twig_Tests_Node_SetTest extends Twig_Test_NodeTestCase { $tests = array(); - $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 0)), array(), 0); - $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 0)), array(), 0); - $node = new Twig_Node_Set(false, $names, $values, 0); - $tests[] = array($node, '$context["foo"] = "foo";'); + $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1); + $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 1)), array(), 1); + $node = new Twig_Node_Set(false, $names, $values, 1); + $tests[] = array($node, <<env->getCharset()); EOF ); - $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 0)), array(), 0); - $values = new Twig_Node_Text('foo', 0); - $node = new Twig_Node_Set(true, $names, $values, 0); - $tests[] = array($node, '$context["foo"] = (\'\' === $tmp = "foo") ? \'\' : new Twig_Markup($tmp, $this->env->getCharset());'); + $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1); + $values = new Twig_Node_Text('foo', 1); + $node = new Twig_Node_Set(true, $names, $values, 1); + $tests[] = array($node, <<env->getCharset()); +EOF + ); - $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 0), new Twig_Node_Expression_AssignName('bar', 0)), array(), 0); - $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 0), new Twig_Node_Expression_Name('bar', 0)), array(), 0); - $node = new Twig_Node_Set(false, $names, $values, 0); + $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1), new Twig_Node_Expression_AssignName('bar', 1)), array(), 1); + $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 1), new Twig_Node_Expression_Name('bar', 1)), array(), 1); + $node = new Twig_Node_Set(false, $names, $values, 1); $tests[] = array($node, <<getVariableGetter('bar')}); EOF ); diff --git a/test/Twig/Tests/Node/SpacelessTest.php b/test/Twig/Tests/Node/SpacelessTest.php index eef3fbe..a19c010 100644 --- a/test/Twig/Tests/Node/SpacelessTest.php +++ b/test/Twig/Tests/Node/SpacelessTest.php @@ -17,8 +17,8 @@ class Twig_Tests_Node_SpacelessTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $body = new Twig_Node(array(new Twig_Node_Text('
foo
', 0))); - $node = new Twig_Node_Spaceless($body, 0); + $body = new Twig_Node(array(new Twig_Node_Text('
foo
', 1))); + $node = new Twig_Node_Spaceless($body, 1); $this->assertEquals($body, $node->getNode('body')); } @@ -34,11 +34,12 @@ class Twig_Tests_Node_SpacelessTest extends Twig_Test_NodeTestCase public function getTests() { - $body = new Twig_Node(array(new Twig_Node_Text('
foo
', 0))); - $node = new Twig_Node_Spaceless($body, 0); + $body = new Twig_Node(array(new Twig_Node_Text('
foo
', 1))); + $node = new Twig_Node_Spaceless($body, 1); return array( array($node, <<
foo
"; echo trim(preg_replace('/>\s+<', ob_get_clean())); diff --git a/test/Twig/Tests/Node/TextTest.php b/test/Twig/Tests/Node/TextTest.php index f5e3f8c..764b12d 100644 --- a/test/Twig/Tests/Node/TextTest.php +++ b/test/Twig/Tests/Node/TextTest.php @@ -17,7 +17,7 @@ class Twig_Tests_Node_TextTest extends Twig_Test_NodeTestCase */ public function testConstructor() { - $node = new Twig_Node_Text('foo', 0); + $node = new Twig_Node_Text('foo', 1); $this->assertEquals('foo', $node->getAttribute('data')); } @@ -34,7 +34,7 @@ class Twig_Tests_Node_TextTest extends Twig_Test_NodeTestCase public function getTests() { $tests = array(); - $tests[] = array(new Twig_Node_Text('foo', 0), 'echo "foo";'); + $tests[] = array(new Twig_Node_Text('foo', 1), "// line 1\necho \"foo\";"); return $tests; } diff --git a/test/Twig/Tests/ParserTest.php b/test/Twig/Tests/ParserTest.php index 1e773a6..b0facf7 100644 --- a/test/Twig/Tests/ParserTest.php +++ b/test/Twig/Tests/ParserTest.php @@ -21,15 +21,15 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase /** * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unknown tag name "foo". Did you mean "for" at line 0 + * @expectedExceptionMessage Unknown tag name "foo". Did you mean "for" at line 1 */ public function testUnkownTag() { $stream = new Twig_TokenStream(array( - new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', 0), - new Twig_Token(Twig_Token::NAME_TYPE, 'foo', 0), - new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 0), - new Twig_Token(Twig_Token::EOF_TYPE, '', 0), + new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', 1), + new Twig_Token(Twig_Token::NAME_TYPE, 'foo', 1), + new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 1), + new Twig_Token(Twig_Token::EOF_TYPE, '', 1), )); $parser = new Twig_Parser(new Twig_Environment()); $parser->parse($stream); @@ -49,15 +49,15 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase { return array( array( - new Twig_Node(array(new Twig_Node_Text(' ', 0))), + new Twig_Node(array(new Twig_Node_Text(' ', 1))), new Twig_Node(array()), ), array( - $input = new Twig_Node(array(new Twig_Node_Set(false, new Twig_Node(), new Twig_Node(), 0))), + $input = new Twig_Node(array(new Twig_Node_Set(false, new Twig_Node(), new Twig_Node(), 1))), $input, ), array( - $input = new Twig_Node(array(new Twig_Node_Set(true, new Twig_Node(), new Twig_Node(array(new Twig_Node(array(new Twig_Node_Text('foo', 0))))), 0))), + $input = new Twig_Node(array(new Twig_Node_Set(true, new Twig_Node(), new Twig_Node(array(new Twig_Node(array(new Twig_Node_Text('foo', 1))))), 1))), $input, ), ); @@ -77,19 +77,19 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase public function getFilterBodyNodesDataThrowsException() { return array( - array(new Twig_Node_Text('foo', 0)), - array(new Twig_Node(array(new Twig_Node(array(new Twig_Node_Text('foo', 0)))))), + array(new Twig_Node_Text('foo', 1)), + array(new Twig_Node(array(new Twig_Node(array(new Twig_Node_Text('foo', 1)))))), ); } /** * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage A template that extends another one cannot have a body but a byte order mark (BOM) has been detected; it must be removed at line 0. + * @expectedExceptionMessage A template that extends another one cannot have a body but a byte order mark (BOM) has been detected; it must be removed at line 1. */ public function testFilterBodyNodesWithBOM() { $parser = $this->getParserForFilterBodyNodes(); - $parser->filterBodyNodes(new Twig_Node_Text(chr(0xEF).chr(0xBB).chr(0xBF), 0)); + $parser->filterBodyNodes(new Twig_Node_Text(chr(0xEF).chr(0xBB).chr(0xBF), 1)); } public function testParseIsReentrant() @@ -103,13 +103,13 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase $parser = new Twig_Parser($twig); $parser->parse(new Twig_TokenStream(array( - new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', 0), - new Twig_Token(Twig_Token::NAME_TYPE, 'test', 0), - new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 0), - new Twig_Token(Twig_Token::VAR_START_TYPE, '', 0), - new Twig_Token(Twig_Token::NAME_TYPE, 'foo', 0), - new Twig_Token(Twig_Token::VAR_END_TYPE, '', 0), - new Twig_Token(Twig_Token::EOF_TYPE, '', 0), + new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', 1), + new Twig_Token(Twig_Token::NAME_TYPE, 'test', 1), + new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 1), + new Twig_Token(Twig_Token::VAR_START_TYPE, '', 1), + new Twig_Token(Twig_Token::NAME_TYPE, 'foo', 1), + new Twig_Token(Twig_Token::VAR_END_TYPE, '', 1), + new Twig_Token(Twig_Token::EOF_TYPE, '', 1), ))); $this->assertEquals(null, $parser->getParent()); @@ -161,11 +161,11 @@ class TestTokenParser extends Twig_TokenParser { // simulate the parsing of another template right in the middle of the parsing of the current template $this->parser->parse(new Twig_TokenStream(array( - new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', 0), - new Twig_Token(Twig_Token::NAME_TYPE, 'extends', 0), - new Twig_Token(Twig_Token::STRING_TYPE, 'base', 0), - new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 0), - new Twig_Token(Twig_Token::EOF_TYPE, '', 0), + new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', 1), + new Twig_Token(Twig_Token::NAME_TYPE, 'extends', 1), + new Twig_Token(Twig_Token::STRING_TYPE, 'base', 1), + new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 1), + new Twig_Token(Twig_Token::EOF_TYPE, '', 1), ))); $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); diff --git a/test/Twig/Tests/TokenStreamTest.php b/test/Twig/Tests/TokenStreamTest.php index 794a037..e2a1fbc 100644 --- a/test/Twig/Tests/TokenStreamTest.php +++ b/test/Twig/Tests/TokenStreamTest.php @@ -16,14 +16,14 @@ class Twig_Tests_TokenStreamTest extends PHPUnit_Framework_TestCase public function setUp() { self::$tokens = array( - new Twig_Token(Twig_Token::TEXT_TYPE, 1, 0), - new Twig_Token(Twig_Token::TEXT_TYPE, 2, 0), - new Twig_Token(Twig_Token::TEXT_TYPE, 3, 0), - new Twig_Token(Twig_Token::TEXT_TYPE, 4, 0), - new Twig_Token(Twig_Token::TEXT_TYPE, 5, 0), - new Twig_Token(Twig_Token::TEXT_TYPE, 6, 0), - new Twig_Token(Twig_Token::TEXT_TYPE, 7, 0), - new Twig_Token(Twig_Token::EOF_TYPE, 0, 0), + new Twig_Token(Twig_Token::TEXT_TYPE, 1, 1), + new Twig_Token(Twig_Token::TEXT_TYPE, 2, 1), + new Twig_Token(Twig_Token::TEXT_TYPE, 3, 1), + new Twig_Token(Twig_Token::TEXT_TYPE, 4, 1), + new Twig_Token(Twig_Token::TEXT_TYPE, 5, 1), + new Twig_Token(Twig_Token::TEXT_TYPE, 6, 1), + new Twig_Token(Twig_Token::TEXT_TYPE, 7, 1), + new Twig_Token(Twig_Token::EOF_TYPE, 0, 1), ); } -- 1.7.2.5