aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/twig/twig/test/Twig/Tests/Node/Expression
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twig/twig/test/Twig/Tests/Node/Expression')
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/ArrayTest.php49
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/AssignNameTest.php41
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AddTest.php47
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AndTest.php47
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php47
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/DivTest.php47
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php47
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ModTest.php47
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/MulTest.php47
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/OrTest.php47
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/SubTest.php47
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php67
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/ConditionalTest.php50
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/ConstantTest.php42
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php133
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php99
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php62
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php49
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FilterInclude.php6
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FunctionInclude.php6
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/TestInclude.php6
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/ParentTest.php40
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php68
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NegTest.php44
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NotTest.php44
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/PosTest.php44
26 files changed, 1273 insertions, 0 deletions
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/ArrayTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/ArrayTest.php
new file mode 100644
index 00000000..c6a9044b
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/ArrayTest.php
@@ -0,0 +1,49 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_ArrayTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Array::__construct
16 */
17 public function testConstructor()
18 {
19 $elements = array(new Twig_Node_Expression_Constant('foo', 1), $foo = new Twig_Node_Expression_Constant('bar', 1));
20 $node = new Twig_Node_Expression_Array($elements, 1);
21
22 $this->assertEquals($foo, $node->getNode(1));
23 }
24
25 /**
26 * @covers Twig_Node_Expression_Array::compile
27 * @dataProvider getTests
28 */
29 public function testCompile($node, $source, $environment = null)
30 {
31 parent::testCompile($node, $source, $environment);
32 }
33
34 public function getTests()
35 {
36 $elements = array(
37 new Twig_Node_Expression_Constant('foo', 1),
38 new Twig_Node_Expression_Constant('bar', 1),
39
40 new Twig_Node_Expression_Constant('bar', 1),
41 new Twig_Node_Expression_Constant('foo', 1),
42 );
43 $node = new Twig_Node_Expression_Array($elements, 1);
44
45 return array(
46 array($node, 'array("foo" => "bar", "bar" => "foo")'),
47 );
48 }
49}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/AssignNameTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/AssignNameTest.php
new file mode 100644
index 00000000..b156dcc0
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/AssignNameTest.php
@@ -0,0 +1,41 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_AssignNameTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_AssignName::__construct
16 */
17 public function testConstructor()
18 {
19 $node = new Twig_Node_Expression_AssignName('foo', 1);
20
21 $this->assertEquals('foo', $node->getAttribute('name'));
22 }
23
24 /**
25 * @covers Twig_Node_Expression_AssignName::compile
26 * @dataProvider getTests
27 */
28 public function testCompile($node, $source, $environment = null)
29 {
30 parent::testCompile($node, $source, $environment);
31 }
32
33 public function getTests()
34 {
35 $node = new Twig_Node_Expression_AssignName('foo', 1);
36
37 return array(
38 array($node, '$context["foo"]'),
39 );
40 }
41}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AddTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AddTest.php
new file mode 100644
index 00000000..a0f49cb3
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AddTest.php
@@ -0,0 +1,47 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_Binary_AddTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Binary_Add::__construct
16 */
17 public function testConstructor()
18 {
19 $left = new Twig_Node_Expression_Constant(1, 1);
20 $right = new Twig_Node_Expression_Constant(2, 1);
21 $node = new Twig_Node_Expression_Binary_Add($left, $right, 1);
22
23 $this->assertEquals($left, $node->getNode('left'));
24 $this->assertEquals($right, $node->getNode('right'));
25 }
26
27 /**
28 * @covers Twig_Node_Expression_Binary_Add::compile
29 * @covers Twig_Node_Expression_Binary_Add::operator
30 * @dataProvider getTests
31 */
32 public function testCompile($node, $source, $environment = null)
33 {
34 parent::testCompile($node, $source, $environment);
35 }
36
37 public function getTests()
38 {
39 $left = new Twig_Node_Expression_Constant(1, 1);
40 $right = new Twig_Node_Expression_Constant(2, 1);
41 $node = new Twig_Node_Expression_Binary_Add($left, $right, 1);
42
43 return array(
44 array($node, '(1 + 2)'),
45 );
46 }
47}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AndTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AndTest.php
new file mode 100644
index 00000000..50e551a7
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AndTest.php
@@ -0,0 +1,47 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_Binary_AndTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Binary_And::__construct
16 */
17 public function testConstructor()
18 {
19 $left = new Twig_Node_Expression_Constant(1, 1);
20 $right = new Twig_Node_Expression_Constant(2, 1);
21 $node = new Twig_Node_Expression_Binary_And($left, $right, 1);
22
23 $this->assertEquals($left, $node->getNode('left'));
24 $this->assertEquals($right, $node->getNode('right'));
25 }
26
27 /**
28 * @covers Twig_Node_Expression_Binary_And::compile
29 * @covers Twig_Node_Expression_Binary_And::operator
30 * @dataProvider getTests
31 */
32 public function testCompile($node, $source, $environment = null)
33 {
34 parent::testCompile($node, $source, $environment);
35 }
36
37 public function getTests()
38 {
39 $left = new Twig_Node_Expression_Constant(1, 1);
40 $right = new Twig_Node_Expression_Constant(2, 1);
41 $node = new Twig_Node_Expression_Binary_And($left, $right, 1);
42
43 return array(
44 array($node, '(1 && 2)'),
45 );
46 }
47}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php
new file mode 100644
index 00000000..140329fa
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php
@@ -0,0 +1,47 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_Binary_ConcatTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Binary_Concat::__construct
16 */
17 public function testConstructor()
18 {
19 $left = new Twig_Node_Expression_Constant(1, 1);
20 $right = new Twig_Node_Expression_Constant(2, 1);
21 $node = new Twig_Node_Expression_Binary_Concat($left, $right, 1);
22
23 $this->assertEquals($left, $node->getNode('left'));
24 $this->assertEquals($right, $node->getNode('right'));
25 }
26
27 /**
28 * @covers Twig_Node_Expression_Binary_Concat::compile
29 * @covers Twig_Node_Expression_Binary_Concat::operator
30 * @dataProvider getTests
31 */
32 public function testCompile($node, $source, $environment = null)
33 {
34 parent::testCompile($node, $source, $environment);
35 }
36
37 public function getTests()
38 {
39 $left = new Twig_Node_Expression_Constant(1, 1);
40 $right = new Twig_Node_Expression_Constant(2, 1);
41 $node = new Twig_Node_Expression_Binary_Concat($left, $right, 1);
42
43 return array(
44 array($node, '(1 . 2)'),
45 );
46 }
47}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/DivTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/DivTest.php
new file mode 100644
index 00000000..0c1a3c7f
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/DivTest.php
@@ -0,0 +1,47 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_Binary_DivTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Binary_Div::__construct
16 */
17 public function testConstructor()
18 {
19 $left = new Twig_Node_Expression_Constant(1, 1);
20 $right = new Twig_Node_Expression_Constant(2, 1);
21 $node = new Twig_Node_Expression_Binary_Div($left, $right, 1);
22
23 $this->assertEquals($left, $node->getNode('left'));
24 $this->assertEquals($right, $node->getNode('right'));
25 }
26
27 /**
28 * @covers Twig_Node_Expression_Binary_Div::compile
29 * @covers Twig_Node_Expression_Binary_Div::operator
30 * @dataProvider getTests
31 */
32 public function testCompile($node, $source, $environment = null)
33 {
34 parent::testCompile($node, $source, $environment);
35 }
36
37 public function getTests()
38 {
39 $left = new Twig_Node_Expression_Constant(1, 1);
40 $right = new Twig_Node_Expression_Constant(2, 1);
41 $node = new Twig_Node_Expression_Binary_Div($left, $right, 1);
42
43 return array(
44 array($node, '(1 / 2)'),
45 );
46 }
47}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php
new file mode 100644
index 00000000..ead1fde8
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php
@@ -0,0 +1,47 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_Binary_FloorDivTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Binary_FloorDiv::__construct
16 */
17 public function testConstructor()
18 {
19 $left = new Twig_Node_Expression_Constant(1, 1);
20 $right = new Twig_Node_Expression_Constant(2, 1);
21 $node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 1);
22
23 $this->assertEquals($left, $node->getNode('left'));
24 $this->assertEquals($right, $node->getNode('right'));
25 }
26
27 /**
28 * @covers Twig_Node_Expression_Binary_FloorDiv::compile
29 * @covers Twig_Node_Expression_Binary_FloorDiv::operator
30 * @dataProvider getTests
31 */
32 public function testCompile($node, $source, $environment = null)
33 {
34 parent::testCompile($node, $source, $environment);
35 }
36
37 public function getTests()
38 {
39 $left = new Twig_Node_Expression_Constant(1, 1);
40 $right = new Twig_Node_Expression_Constant(2, 1);
41 $node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 1);
42
43 return array(
44 array($node, 'intval(floor((1 / 2)))'),
45 );
46 }
47}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ModTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ModTest.php
new file mode 100644
index 00000000..4fe1a1fc
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ModTest.php
@@ -0,0 +1,47 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_Binary_ModTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Binary_Mod::__construct
16 */
17 public function testConstructor()
18 {
19 $left = new Twig_Node_Expression_Constant(1, 1);
20 $right = new Twig_Node_Expression_Constant(2, 1);
21 $node = new Twig_Node_Expression_Binary_Mod($left, $right, 1);
22
23 $this->assertEquals($left, $node->getNode('left'));
24 $this->assertEquals($right, $node->getNode('right'));
25 }
26
27 /**
28 * @covers Twig_Node_Expression_Binary_Mod::compile
29 * @covers Twig_Node_Expression_Binary_Mod::operator
30 * @dataProvider getTests
31 */
32 public function testCompile($node, $source, $environment = null)
33 {
34 parent::testCompile($node, $source, $environment);
35 }
36
37 public function getTests()
38 {
39 $left = new Twig_Node_Expression_Constant(1, 1);
40 $right = new Twig_Node_Expression_Constant(2, 1);
41 $node = new Twig_Node_Expression_Binary_Mod($left, $right, 1);
42
43 return array(
44 array($node, '(1 % 2)'),
45 );
46 }
47}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/MulTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/MulTest.php
new file mode 100644
index 00000000..12bb35c9
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/MulTest.php
@@ -0,0 +1,47 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_Binary_MulTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Binary_Mul::__construct
16 */
17 public function testConstructor()
18 {
19 $left = new Twig_Node_Expression_Constant(1, 1);
20 $right = new Twig_Node_Expression_Constant(2, 1);
21 $node = new Twig_Node_Expression_Binary_Mul($left, $right, 1);
22
23 $this->assertEquals($left, $node->getNode('left'));
24 $this->assertEquals($right, $node->getNode('right'));
25 }
26
27 /**
28 * @covers Twig_Node_Expression_Binary_Mul::compile
29 * @covers Twig_Node_Expression_Binary_Mul::operator
30 * @dataProvider getTests
31 */
32 public function testCompile($node, $source, $environment = null)
33 {
34 parent::testCompile($node, $source, $environment);
35 }
36
37 public function getTests()
38 {
39 $left = new Twig_Node_Expression_Constant(1, 1);
40 $right = new Twig_Node_Expression_Constant(2, 1);
41 $node = new Twig_Node_Expression_Binary_Mul($left, $right, 1);
42
43 return array(
44 array($node, '(1 * 2)'),
45 );
46 }
47}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/OrTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/OrTest.php
new file mode 100644
index 00000000..9534c41c
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/OrTest.php
@@ -0,0 +1,47 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_Binary_OrTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Binary_Or::__construct
16 */
17 public function testConstructor()
18 {
19 $left = new Twig_Node_Expression_Constant(1, 1);
20 $right = new Twig_Node_Expression_Constant(2, 1);
21 $node = new Twig_Node_Expression_Binary_Or($left, $right, 1);
22
23 $this->assertEquals($left, $node->getNode('left'));
24 $this->assertEquals($right, $node->getNode('right'));
25 }
26
27 /**
28 * @covers Twig_Node_Expression_Binary_Or::compile
29 * @covers Twig_Node_Expression_Binary_Or::operator
30 * @dataProvider getTests
31 */
32 public function testCompile($node, $source, $environment = null)
33 {
34 parent::testCompile($node, $source, $environment);
35 }
36
37 public function getTests()
38 {
39 $left = new Twig_Node_Expression_Constant(1, 1);
40 $right = new Twig_Node_Expression_Constant(2, 1);
41 $node = new Twig_Node_Expression_Binary_Or($left, $right, 1);
42
43 return array(
44 array($node, '(1 || 2)'),
45 );
46 }
47}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/SubTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/SubTest.php
new file mode 100644
index 00000000..9074893b
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/SubTest.php
@@ -0,0 +1,47 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_Binary_SubTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Binary_Sub::__construct
16 */
17 public function testConstructor()
18 {
19 $left = new Twig_Node_Expression_Constant(1, 1);
20 $right = new Twig_Node_Expression_Constant(2, 1);
21 $node = new Twig_Node_Expression_Binary_Sub($left, $right, 1);
22
23 $this->assertEquals($left, $node->getNode('left'));
24 $this->assertEquals($right, $node->getNode('right'));
25 }
26
27 /**
28 * @covers Twig_Node_Expression_Binary_Sub::compile
29 * @covers Twig_Node_Expression_Binary_Sub::operator
30 * @dataProvider getTests
31 */
32 public function testCompile($node, $source, $environment = null)
33 {
34 parent::testCompile($node, $source, $environment);
35 }
36
37 public function getTests()
38 {
39 $left = new Twig_Node_Expression_Constant(1, 1);
40 $right = new Twig_Node_Expression_Constant(2, 1);
41 $node = new Twig_Node_Expression_Binary_Sub($left, $right, 1);
42
43 return array(
44 array($node, '(1 - 2)'),
45 );
46 }
47}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php
new file mode 100644
index 00000000..53b5e6ee
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php
@@ -0,0 +1,67 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_CallTest extends PHPUnit_Framework_TestCase
13{
14 public function testGetArguments()
15 {
16 $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date'));
17 $this->assertEquals(array('U'), $node->getArguments('date', array('format' => 'U')));
18 }
19
20 /**
21 * @expectedException Twig_Error_Syntax
22 * @expectedExceptionMessage Positional arguments cannot be used after named arguments for function "date".
23 */
24 public function testGetArgumentsWhenPositionalArgumentsAfterNamedArguments()
25 {
26 $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date'));
27 $node->getArguments('date', array('timestamp' => 123456, 'Y-m-d'));
28 }
29
30 /**
31 * @expectedException Twig_Error_Syntax
32 * @expectedExceptionMessage Argument "format" is defined twice for function "date".
33 */
34 public function testGetArgumentsWhenArgumentIsDefinedTwice()
35 {
36 $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date'));
37 $node->getArguments('date', array('Y-m-d', 'format' => 'U'));
38 }
39
40 /**
41 * @expectedException Twig_Error_Syntax
42 * @expectedExceptionMessage Unknown argument "unknown" for function "date".
43 */
44 public function testGetArgumentsWithWrongNamedArgumentName()
45 {
46 $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date'));
47 $node->getArguments('date', array('Y-m-d', 'unknown' => ''));
48 }
49
50 /**
51 * @expectedException Twig_Error_Syntax
52 * @expectedExceptionMessage Unknown arguments "unknown1", "unknown2" for function "date".
53 */
54 public function testGetArgumentsWithWrongNamedArgumentNames()
55 {
56 $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date'));
57 $node->getArguments('date', array('Y-m-d', 'unknown1' => '', 'unknown2' => ''));
58 }
59}
60
61class Twig_Tests_Node_Expression_Call extends Twig_Node_Expression_Call
62{
63 public function getArguments($callable, $arguments)
64 {
65 return parent::getArguments($callable, $arguments);
66 }
67}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConditionalTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConditionalTest.php
new file mode 100644
index 00000000..9906d512
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConditionalTest.php
@@ -0,0 +1,50 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_ConditionalTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Conditional::__construct
16 */
17 public function testConstructor()
18 {
19 $expr1 = new Twig_Node_Expression_Constant(1, 1);
20 $expr2 = new Twig_Node_Expression_Constant(2, 1);
21 $expr3 = new Twig_Node_Expression_Constant(3, 1);
22 $node = new Twig_Node_Expression_Conditional($expr1, $expr2, $expr3, 1);
23
24 $this->assertEquals($expr1, $node->getNode('expr1'));
25 $this->assertEquals($expr2, $node->getNode('expr2'));
26 $this->assertEquals($expr3, $node->getNode('expr3'));
27 }
28
29 /**
30 * @covers Twig_Node_Expression_Conditional::compile
31 * @dataProvider getTests
32 */
33 public function testCompile($node, $source, $environment = null)
34 {
35 parent::testCompile($node, $source, $environment);
36 }
37
38 public function getTests()
39 {
40 $tests = array();
41
42 $expr1 = new Twig_Node_Expression_Constant(1, 1);
43 $expr2 = new Twig_Node_Expression_Constant(2, 1);
44 $expr3 = new Twig_Node_Expression_Constant(3, 1);
45 $node = new Twig_Node_Expression_Conditional($expr1, $expr2, $expr3, 1);
46 $tests[] = array($node, '((1) ? (2) : (3))');
47
48 return $tests;
49 }
50}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConstantTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConstantTest.php
new file mode 100644
index 00000000..d0dec531
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConstantTest.php
@@ -0,0 +1,42 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_ConstantTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Constant::__construct
16 */
17 public function testConstructor()
18 {
19 $node = new Twig_Node_Expression_Constant('foo', 1);
20
21 $this->assertEquals('foo', $node->getAttribute('value'));
22 }
23
24 /**
25 * @covers Twig_Node_Expression_Constant::compile
26 * @dataProvider getTests
27 */
28 public function testCompile($node, $source, $environment = null)
29 {
30 parent::testCompile($node, $source, $environment);
31 }
32
33 public function getTests()
34 {
35 $tests = array();
36
37 $node = new Twig_Node_Expression_Constant('foo', 1);
38 $tests[] = array($node, '"foo"');
39
40 return $tests;
41 }
42}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php
new file mode 100644
index 00000000..8089b9cb
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php
@@ -0,0 +1,133 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Filter::__construct
16 */
17 public function testConstructor()
18 {
19 $expr = new Twig_Node_Expression_Constant('foo', 1);
20 $name = new Twig_Node_Expression_Constant('upper', 1);
21 $args = new Twig_Node();
22 $node = new Twig_Node_Expression_Filter($expr, $name, $args, 1);
23
24 $this->assertEquals($expr, $node->getNode('node'));
25 $this->assertEquals($name, $node->getNode('filter'));
26 $this->assertEquals($args, $node->getNode('arguments'));
27 }
28
29 /**
30 * @covers Twig_Node_Expression_Filter::compile
31 * @dataProvider getTests
32 */
33 public function testCompile($node, $source, $environment = null)
34 {
35 parent::testCompile($node, $source, $environment);
36 }
37
38 public function getTests()
39 {
40 $tests = array();
41
42 $expr = new Twig_Node_Expression_Constant('foo', 1);
43 $node = $this->createFilter($expr, 'upper');
44 $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)));
45
46 if (function_exists('mb_get_info')) {
47 $tests[] = array($node, 'twig_number_format_filter($this->env, twig_upper_filter($this->env, "foo"), 2, ".", ",")');
48 } else {
49 $tests[] = array($node, 'twig_number_format_filter($this->env, strtoupper("foo"), 2, ".", ",")');
50 }
51
52 // named arguments
53 $date = new Twig_Node_Expression_Constant(0, 1);
54 $node = $this->createFilter($date, 'date', array(
55 'timezone' => new Twig_Node_Expression_Constant('America/Chicago', 1),
56 'format' => new Twig_Node_Expression_Constant('d/m/Y H:i:s P', 1),
57 ));
58 $tests[] = array($node, 'twig_date_format_filter($this->env, 0, "d/m/Y H:i:s P", "America/Chicago")');
59
60 // skip an optional argument
61 $date = new Twig_Node_Expression_Constant(0, 1);
62 $node = $this->createFilter($date, 'date', array(
63 'timezone' => new Twig_Node_Expression_Constant('America/Chicago', 1),
64 ));
65 $tests[] = array($node, 'twig_date_format_filter($this->env, 0, null, "America/Chicago")');
66
67 // underscores vs camelCase for named arguments
68 $string = new Twig_Node_Expression_Constant('abc', 1);
69 $node = $this->createFilter($string, 'reverse', array(
70 'preserve_keys' => new Twig_Node_Expression_Constant(true, 1),
71 ));
72 $tests[] = array($node, 'twig_reverse_filter($this->env, "abc", true)');
73 $node = $this->createFilter($string, 'reverse', array(
74 'preserveKeys' => new Twig_Node_Expression_Constant(true, 1),
75 ));
76 $tests[] = array($node, 'twig_reverse_filter($this->env, "abc", true)');
77
78 // filter as an anonymous function
79 if (version_compare(phpversion(), '5.3.0', '>=')) {
80 $node = $this->createFilter(new Twig_Node_Expression_Constant('foo', 1), 'anonymous');
81 $tests[] = array($node, 'call_user_func_array($this->env->getFilter(\'anonymous\')->getCallable(), array("foo"))');
82 }
83
84 return $tests;
85 }
86
87 /**
88 * @expectedException Twig_Error_Syntax
89 * @expectedExceptionMessage Unknown argument "foobar" for filter "date".
90 */
91 public function testCompileWithWrongNamedArgumentName()
92 {
93 $date = new Twig_Node_Expression_Constant(0, 1);
94 $node = $this->createFilter($date, 'date', array(
95 'foobar' => new Twig_Node_Expression_Constant('America/Chicago', 1),
96 ));
97
98 $compiler = $this->getCompiler();
99 $compiler->compile($node);
100 }
101
102 /**
103 * @expectedException Twig_Error_Syntax
104 * @expectedExceptionMessage Value for argument "from" is required for filter "replace".
105 */
106 public function testCompileWithMissingNamedArgument()
107 {
108 $value = new Twig_Node_Expression_Constant(0, 1);
109 $node = $this->createFilter($value, 'replace', array(
110 'to' => new Twig_Node_Expression_Constant('foo', 1),
111 ));
112
113 $compiler = $this->getCompiler();
114 $compiler->compile($node);
115 }
116
117 protected function createFilter($node, $name, array $arguments = array())
118 {
119 $name = new Twig_Node_Expression_Constant($name, 1);
120 $arguments = new Twig_Node($arguments);
121
122 return new Twig_Node_Expression_Filter($node, $name, $arguments, 1);
123 }
124
125 protected function getEnvironment()
126 {
127 if (version_compare(phpversion(), '5.3.0', '>=')) {
128 return include 'PHP53/FilterInclude.php';
129 }
130
131 return parent::getEnvironment();
132 }
133}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php
new file mode 100644
index 00000000..431dc387
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php
@@ -0,0 +1,99 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Function::__construct
16 */
17 public function testConstructor()
18 {
19 $name = 'function';
20 $args = new Twig_Node();
21 $node = new Twig_Node_Expression_Function($name, $args, 1);
22
23 $this->assertEquals($name, $node->getAttribute('name'));
24 $this->assertEquals($args, $node->getNode('arguments'));
25 }
26
27 /**
28 * @covers Twig_Node_Expression_Function::compile
29 * @dataProvider getTests
30 */
31 public function testCompile($node, $source, $environment = null)
32 {
33 parent::testCompile($node, $source, $environment);
34 }
35
36 public function getTests()
37 {
38 $environment = new Twig_Environment();
39 $environment->addFunction('foo', new Twig_Function_Function('foo', array()));
40 $environment->addFunction('bar', new Twig_Function_Function('bar', array('needs_environment' => true)));
41 $environment->addFunction('foofoo', new Twig_Function_Function('foofoo', array('needs_context' => true)));
42 $environment->addFunction('foobar', new Twig_Function_Function('foobar', array('needs_environment' => true, 'needs_context' => true)));
43
44 $tests = array();
45
46 $node = $this->createFunction('foo');
47 $tests[] = array($node, 'foo()', $environment);
48
49 $node = $this->createFunction('foo', array(new Twig_Node_Expression_Constant('bar', 1), new Twig_Node_Expression_Constant('foobar', 1)));
50 $tests[] = array($node, 'foo("bar", "foobar")', $environment);
51
52 $node = $this->createFunction('bar');
53 $tests[] = array($node, 'bar($this->env)', $environment);
54
55 $node = $this->createFunction('bar', array(new Twig_Node_Expression_Constant('bar', 1)));
56 $tests[] = array($node, 'bar($this->env, "bar")', $environment);
57
58 $node = $this->createFunction('foofoo');
59 $tests[] = array($node, 'foofoo($context)', $environment);
60
61 $node = $this->createFunction('foofoo', array(new Twig_Node_Expression_Constant('bar', 1)));
62 $tests[] = array($node, 'foofoo($context, "bar")', $environment);
63
64 $node = $this->createFunction('foobar');
65 $tests[] = array($node, 'foobar($this->env, $context)', $environment);
66
67 $node = $this->createFunction('foobar', array(new Twig_Node_Expression_Constant('bar', 1)));
68 $tests[] = array($node, 'foobar($this->env, $context, "bar")', $environment);
69
70 // named arguments
71 $node = $this->createFunction('date', array(
72 'timezone' => new Twig_Node_Expression_Constant('America/Chicago', 1),
73 'date' => new Twig_Node_Expression_Constant(0, 1),
74 ));
75 $tests[] = array($node, 'twig_date_converter($this->env, 0, "America/Chicago")');
76
77 // function as an anonymous function
78 if (version_compare(phpversion(), '5.3.0', '>=')) {
79 $node = $this->createFunction('anonymous', array(new Twig_Node_Expression_Constant('foo', 1)));
80 $tests[] = array($node, 'call_user_func_array($this->env->getFunction(\'anonymous\')->getCallable(), array("foo"))');
81 }
82
83 return $tests;
84 }
85
86 protected function createFunction($name, array $arguments = array())
87 {
88 return new Twig_Node_Expression_Function($name, new Twig_Node($arguments), 1);
89 }
90
91 protected function getEnvironment()
92 {
93 if (version_compare(phpversion(), '5.3.0', '>=')) {
94 return include 'PHP53/FunctionInclude.php';
95 }
96
97 return parent::getEnvironment();
98 }
99}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php
new file mode 100644
index 00000000..6a63cce6
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php
@@ -0,0 +1,62 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_GetAttrTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_GetAttr::__construct
16 */
17 public function testConstructor()
18 {
19 $expr = new Twig_Node_Expression_Name('foo', 1);
20 $attr = new Twig_Node_Expression_Constant('bar', 1);
21 $args = new Twig_Node_Expression_Array(array(), 1);
22 $args->addElement(new Twig_Node_Expression_Name('foo', 1));
23 $args->addElement(new Twig_Node_Expression_Constant('bar', 1));
24 $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ARRAY_CALL, 1);
25
26 $this->assertEquals($expr, $node->getNode('node'));
27 $this->assertEquals($attr, $node->getNode('attribute'));
28 $this->assertEquals($args, $node->getNode('arguments'));
29 $this->assertEquals(Twig_TemplateInterface::ARRAY_CALL, $node->getAttribute('type'));
30 }
31
32 /**
33 * @covers Twig_Node_Expression_GetAttr::compile
34 * @dataProvider getTests
35 */
36 public function testCompile($node, $source, $environment = null)
37 {
38 parent::testCompile($node, $source, $environment);
39 }
40
41 public function getTests()
42 {
43 $tests = array();
44
45 $expr = new Twig_Node_Expression_Name('foo', 1);
46 $attr = new Twig_Node_Expression_Constant('bar', 1);
47 $args = new Twig_Node_Expression_Array(array(), 1);
48 $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ANY_CALL, 1);
49 $tests[] = array($node, sprintf('%s%s, "bar")', $this->getAttributeGetter(), $this->getVariableGetter('foo')));
50
51 $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ARRAY_CALL, 1);
52 $tests[] = array($node, sprintf('%s%s, "bar", array(), "array")', $this->getAttributeGetter(), $this->getVariableGetter('foo')));
53
54 $args = new Twig_Node_Expression_Array(array(), 1);
55 $args->addElement(new Twig_Node_Expression_Name('foo', 1));
56 $args->addElement(new Twig_Node_Expression_Constant('bar', 1));
57 $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::METHOD_CALL, 1);
58 $tests[] = array($node, sprintf('%s%s, "bar", array(0 => %s, 1 => "bar"), "method")', $this->getAttributeGetter(), $this->getVariableGetter('foo'), $this->getVariableGetter('foo')));
59
60 return $tests;
61 }
62}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php
new file mode 100644
index 00000000..76d109b6
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php
@@ -0,0 +1,49 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_NameTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Name::__construct
16 */
17 public function testConstructor()
18 {
19 $node = new Twig_Node_Expression_Name('foo', 1);
20
21 $this->assertEquals('foo', $node->getAttribute('name'));
22 }
23
24 /**
25 * @covers Twig_Node_Expression_Name::compile
26 * @dataProvider getTests
27 */
28 public function testCompile($node, $source, $environment = null)
29 {
30 parent::testCompile($node, $source, $environment);
31 }
32
33 public function getTests()
34 {
35 $node = new Twig_Node_Expression_Name('foo', 1);
36 $self = new Twig_Node_Expression_Name('_self', 1);
37 $context = new Twig_Node_Expression_Name('_context', 1);
38
39 $env = new Twig_Environment(null, array('strict_variables' => true));
40 $env1 = new Twig_Environment(null, array('strict_variables' => false));
41
42 return array(
43 version_compare(PHP_VERSION, '5.4.0') >= 0 ? array($node, '(isset($context["foo"]) ? $context["foo"] : $this->getContext($context, "foo"))', $env) : array($node, '$this->getContext($context, "foo")', $env),
44 array($node, $this->getVariableGetter('foo'), $env1),
45 array($self, '$this'),
46 array($context, '$context'),
47 );
48 }
49}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FilterInclude.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FilterInclude.php
new file mode 100644
index 00000000..15e3aa96
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FilterInclude.php
@@ -0,0 +1,6 @@
1<?php
2
3$env = new Twig_Environment();
4$env->addFilter(new Twig_SimpleFilter('anonymous', function () {}));
5
6return $env;
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FunctionInclude.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FunctionInclude.php
new file mode 100644
index 00000000..d2170ed2
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FunctionInclude.php
@@ -0,0 +1,6 @@
1<?php
2
3$env = new Twig_Environment();
4$env->addFunction(new Twig_SimpleFunction('anonymous', function () {}));
5
6return $env;
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/TestInclude.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/TestInclude.php
new file mode 100644
index 00000000..63662864
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/TestInclude.php
@@ -0,0 +1,6 @@
1<?php
2
3$env = new Twig_Environment();
4$env->addTest(new Twig_SimpleTest('anonymous', function () {}));
5
6return $env;
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/ParentTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/ParentTest.php
new file mode 100644
index 00000000..4d40419b
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/ParentTest.php
@@ -0,0 +1,40 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_ParentTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Parent::__construct
16 */
17 public function testConstructor()
18 {
19 $node = new Twig_Node_Expression_Parent('foo', 1);
20
21 $this->assertEquals('foo', $node->getAttribute('name'));
22 }
23
24 /**
25 * @covers Twig_Node_Expression_Parent::compile
26 * @dataProvider getTests
27 */
28 public function testCompile($node, $source, $environment = null)
29 {
30 parent::testCompile($node, $source, $environment);
31 }
32
33 public function getTests()
34 {
35 $tests = array();
36 $tests[] = array(new Twig_Node_Expression_Parent('foo', 1), '$this->renderParentBlock("foo", $context, $blocks)');
37
38 return $tests;
39 }
40}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php
new file mode 100644
index 00000000..0664150a
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php
@@ -0,0 +1,68 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Test::__construct
16 */
17 public function testConstructor()
18 {
19 $expr = new Twig_Node_Expression_Constant('foo', 1);
20 $name = new Twig_Node_Expression_Constant('null', 1);
21 $args = new Twig_Node();
22 $node = new Twig_Node_Expression_Test($expr, $name, $args, 1);
23
24 $this->assertEquals($expr, $node->getNode('node'));
25 $this->assertEquals($args, $node->getNode('arguments'));
26 $this->assertEquals($name, $node->getAttribute('name'));
27 }
28
29 /**
30 * @covers Twig_Node_Expression_Test::compile
31 * @dataProvider getTests
32 */
33 public function testCompile($node, $source, $environment = null)
34 {
35 parent::testCompile($node, $source, $environment);
36 }
37
38 public function getTests()
39 {
40 $tests = array();
41
42 $expr = new Twig_Node_Expression_Constant('foo', 1);
43 $node = new Twig_Node_Expression_Test_Null($expr, 'null', new Twig_Node(array()), 1);
44 $tests[] = array($node, '(null === "foo")');
45
46 // test as an anonymous function
47 if (version_compare(phpversion(), '5.3.0', '>=')) {
48 $node = $this->createTest(new Twig_Node_Expression_Constant('foo', 1), 'anonymous', array(new Twig_Node_Expression_Constant('foo', 1)));
49 $tests[] = array($node, 'call_user_func_array($this->env->getTest(\'anonymous\')->getCallable(), array("foo", "foo"))');
50 }
51
52 return $tests;
53 }
54
55 protected function createTest($node, $name, array $arguments = array())
56 {
57 return new Twig_Node_Expression_Test($node, $name, new Twig_Node($arguments), 1);
58 }
59
60 protected function getEnvironment()
61 {
62 if (version_compare(phpversion(), '5.3.0', '>=')) {
63 return include 'PHP53/TestInclude.php';
64 }
65
66 return parent::getEnvironment();
67 }
68}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NegTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NegTest.php
new file mode 100644
index 00000000..d55ab333
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NegTest.php
@@ -0,0 +1,44 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_Unary_NegTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Unary_Neg::__construct
16 */
17 public function testConstructor()
18 {
19 $expr = new Twig_Node_Expression_Constant(1, 1);
20 $node = new Twig_Node_Expression_Unary_Neg($expr, 1);
21
22 $this->assertEquals($expr, $node->getNode('node'));
23 }
24
25 /**
26 * @covers Twig_Node_Expression_Unary_Neg::compile
27 * @covers Twig_Node_Expression_Unary_Neg::operator
28 * @dataProvider getTests
29 */
30 public function testCompile($node, $source, $environment = null)
31 {
32 parent::testCompile($node, $source, $environment);
33 }
34
35 public function getTests()
36 {
37 $node = new Twig_Node_Expression_Constant(1, 1);
38 $node = new Twig_Node_Expression_Unary_Neg($node, 1);
39
40 return array(
41 array($node, '(-1)'),
42 );
43 }
44}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NotTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NotTest.php
new file mode 100644
index 00000000..625c2527
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NotTest.php
@@ -0,0 +1,44 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_Unary_NotTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Unary_Not::__construct
16 */
17 public function testConstructor()
18 {
19 $expr = new Twig_Node_Expression_Constant(1, 1);
20 $node = new Twig_Node_Expression_Unary_Not($expr, 1);
21
22 $this->assertEquals($expr, $node->getNode('node'));
23 }
24
25 /**
26 * @covers Twig_Node_Expression_Unary_Not::compile
27 * @covers Twig_Node_Expression_Unary_Not::operator
28 * @dataProvider getTests
29 */
30 public function testCompile($node, $source, $environment = null)
31 {
32 parent::testCompile($node, $source, $environment);
33 }
34
35 public function getTests()
36 {
37 $node = new Twig_Node_Expression_Constant(1, 1);
38 $node = new Twig_Node_Expression_Unary_Not($node, 1);
39
40 return array(
41 array($node, '(!1)'),
42 );
43 }
44}
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/PosTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/PosTest.php
new file mode 100644
index 00000000..047a0977
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/PosTest.php
@@ -0,0 +1,44 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_Unary_PosTest extends Twig_Test_NodeTestCase
13{
14 /**
15 * @covers Twig_Node_Expression_Unary_Pos::__construct
16 */
17 public function testConstructor()
18 {
19 $expr = new Twig_Node_Expression_Constant(1, 1);
20 $node = new Twig_Node_Expression_Unary_Pos($expr, 1);
21
22 $this->assertEquals($expr, $node->getNode('node'));
23 }
24
25 /**
26 * @covers Twig_Node_Expression_Unary_Pos::compile
27 * @covers Twig_Node_Expression_Unary_Pos::operator
28 * @dataProvider getTests
29 */
30 public function testCompile($node, $source, $environment = null)
31 {
32 parent::testCompile($node, $source, $environment);
33 }
34
35 public function getTests()
36 {
37 $node = new Twig_Node_Expression_Constant(1, 1);
38 $node = new Twig_Node_Expression_Unary_Pos($node, 1);
39
40 return array(
41 array($node, '(+1)'),
42 );
43 }
44}