*/
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'));
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\";"),
);
}
}
*/
public function testConstructor()
{
- $node = new Twig_Node_BlockReference('foo', 0);
+ $node = new Twig_Node_BlockReference('foo', 1);
$this->assertEquals('foo', $node->getAttribute('name'));
}
public function getTests()
{
return array(
- array(new Twig_Node_BlockReference('foo', 0), '$this->displayBlock(\'foo\', $context, $blocks);'),
+ array(new Twig_Node_BlockReference('foo', 1), <<<EOF
+// line 1
+\$this->displayBlock('foo', \$context, \$blocks);
+EOF
+ ),
);
}
}
*/
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'));
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, <<<EOF
+// line 1
public function block_foo(\$context, array \$blocks = array())
{
echo "foo";
*/
public function testConstructor()
{
- $expr = new Twig_Node_Expression_Constant('foo', 0);
- $node = new Twig_Node_Do($expr, 0);
+ $expr = new Twig_Node_Expression_Constant('foo', 1);
+ $node = new Twig_Node_Do($expr, 1);
$this->assertEquals($expr, $node->getNode('expr'));
}
{
$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;
}
*/
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));
}
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")'),
*/
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'));
}
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"]'),
*/
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'));
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)'),
*/
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'));
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)'),
*/
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'));
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)'),
*/
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'));
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)'),
*/
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'));
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)))'),
*/
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'));
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)'),
*/
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'));
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)'),
*/
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'));
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)'),
*/
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'));
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)'),
*/
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'));
{
$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;
*/
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'));
}
{
$tests = array();
- $node = new Twig_Node_Expression_Constant('foo', 0);
+ $node = new Twig_Node_Expression_Constant('foo', 1);
$tests[] = array($node, '"foo"');
return $tests;
*/
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'));
/**
* @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());
}
{
$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, ".", ",")');
/**
* @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);
}
}
{
$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'));
/**
* @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()
{
$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;
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);
}
}
*/
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'));
{
$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;
*/
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'));
}
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));
*/
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'));
}
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;
}
*/
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'));
{
$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")');
/**
* @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);
}
}
*/
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'));
}
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)'),
*/
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'));
}
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)'),
*/
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'));
}
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)'),
*/
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'));
$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'));
}
{
$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, <<<EOF
+// line 1
\$context['_parent'] = (array) \$context;
\$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('items')});
foreach (\$context['_seq'] as \$context["key"] => \$context["item"]) {
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, <<<EOF
+// line 1
\$context['_parent'] = (array) \$context;
\$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')});
\$context['loop'] = array(
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, <<<EOF
+// line 1
\$context['_parent'] = (array) \$context;
\$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')});
\$context['loop'] = array(
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, <<<EOF
+// line 1
\$context['_parent'] = (array) \$context;
\$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')});
\$context['_iterated'] = false;
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'));
}
$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, <<<EOF
+// line 1
if (true) {
echo {$this->getVariableGetter('foo')};
}
);
$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, <<<EOF
+// line 1
if (true) {
echo {$this->getVariableGetter('foo')};
} elseif (false) {
);
$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, <<<EOF
+// line 1
if (true) {
echo {$this->getVariableGetter('foo')};
} else {
*/
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'));
{
$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, <<<EOF
+// line 1
+\$context["macro"] = \$this->env->loadTemplate("foo.twig");
+EOF
+ );
return $tests;
}
*/
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'));
}
{
$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, <<<EOF
+// line 1
+\$this->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, <<<EOF
+// line 1
\$template = \$this->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, <<<EOF
+// line 1
+\$this->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, <<<EOF
+// line 1
+\$this->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, <<<EOF
+// line 1
try {
\$this->env->loadTemplate("foo.twig")->display(array("foo" => true));
} catch (Twig_Error_Loader \$e) {
*/
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'));
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, <<<EOF
+// line 1
public function getfoo(\$foo = null)
{
\$context = \$this->env->mergeGlobals(array(
*/
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();
$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();
protected function doDisplay(array \$context, array \$blocks = array())
{
+ // line 1
echo "foo";
}
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, <<<EOF
protected function doDisplay(array \$context, array \$blocks = array())
{
+ // line 1
\$context["macro"] = \$this->env->loadTemplate("foo.twig");
\$this->parent->display(\$context, array_merge(\$this->blocks, \$blocks));
}
public function getDebugInfo()
{
- return array ();
+ return array ( 22 => 1,);
}
}
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
);
*/
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'));
}
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;
}
*/
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'));
}
{
$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, <<<EOF
+// line 1
\$sandbox = \$this->env->getExtension('sandbox');
if (!\$alreadySandboxed = \$sandbox->isSandboxed()) {
\$sandbox->enableSandbox();
*/
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();
$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();
protected function doDisplay(array \$context, array \$blocks = array())
{
\$this->checkSecurity();
+ // line 1
echo "foo";
}
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();
*/
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'));
}
{
$tests = array();
- $tests[] = array(new Twig_Node_SandboxedPrint(new Twig_Node_Expression_Constant('foo', 0), 0), <<<EOF
+ $tests[] = array(new Twig_Node_SandboxedPrint(new Twig_Node_Expression_Constant('foo', 1), 1), <<<EOF
+// line 1
echo \$this->env->getExtension('sandbox')->ensureToStringAllowed("foo");
EOF
);
*/
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'));
{
$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, <<<EOF
+// line 1
+\$context["foo"] = "foo";
+EOF
+ );
- $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 0)), array(), 0);
- $values = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Constant('foo', 0), 0)), array(), 0);
- $node = new Twig_Node_Set(true, $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_Print(new Twig_Node_Expression_Constant('foo', 1), 1)), array(), 1);
+ $node = new Twig_Node_Set(true, $names, $values, 1);
$tests[] = array($node, <<<EOF
+// line 1
ob_start();
echo "foo";
\$context["foo"] = ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->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, <<<EOF
+// line 1
+\$context["foo"] = ('' === \$tmp = "foo") ? '' : new Twig_Markup(\$tmp, \$this->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, <<<EOF
+// line 1
list(\$context["foo"], \$context["bar"]) = array("foo", {$this->getVariableGetter('bar')});
EOF
);
*/
public function testConstructor()
{
- $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 0)));
- $node = new Twig_Node_Spaceless($body, 0);
+ $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 1)));
+ $node = new Twig_Node_Spaceless($body, 1);
$this->assertEquals($body, $node->getNode('body'));
}
public function getTests()
{
- $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 0)));
- $node = new Twig_Node_Spaceless($body, 0);
+ $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 1)));
+ $node = new Twig_Node_Spaceless($body, 1);
return array(
array($node, <<<EOF
+// line 1
ob_start();
echo "<div> <div> foo </div> </div>";
echo trim(preg_replace('/>\s+</', '><', ob_get_clean()));
*/
public function testConstructor()
{
- $node = new Twig_Node_Text('foo', 0);
+ $node = new Twig_Node_Text('foo', 1);
$this->assertEquals('foo', $node->getAttribute('data'));
}
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;
}
/**
* @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);
{
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,
),
);
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()
$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());
{
// 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);
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),
);
}