diff options
Diffstat (limited to 'vendor/twig/twig/test/Twig/Tests/Node')
43 files changed, 2660 insertions, 0 deletions
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/AutoEscapeTest.php b/vendor/twig/twig/test/Twig/Tests/Node/AutoEscapeTest.php new file mode 100644 index 00000000..608446bc --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/AutoEscapeTest.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 | |||
12 | class Twig_Tests_Node_AutoEscapeTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_AutoEscape::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $body = new Twig_Node(array(new Twig_Node_Text('foo', 1))); | ||
20 | $node = new Twig_Node_AutoEscape(true, $body, 1); | ||
21 | |||
22 | $this->assertEquals($body, $node->getNode('body')); | ||
23 | $this->assertEquals(true, $node->getAttribute('value')); | ||
24 | } | ||
25 | |||
26 | /** | ||
27 | * @covers Twig_Node_AutoEscape::compile | ||
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 | $body = new Twig_Node(array(new Twig_Node_Text('foo', 1))); | ||
38 | $node = new Twig_Node_AutoEscape(true, $body, 1); | ||
39 | |||
40 | return array( | ||
41 | array($node, "// line 1\necho \"foo\";"), | ||
42 | ); | ||
43 | } | ||
44 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/BlockReferenceTest.php b/vendor/twig/twig/test/Twig/Tests/Node/BlockReferenceTest.php new file mode 100644 index 00000000..96d0e101 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/BlockReferenceTest.php | |||
@@ -0,0 +1,43 @@ | |||
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 | |||
12 | class Twig_Tests_Node_BlockReferenceTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_BlockReference::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $node = new Twig_Node_BlockReference('foo', 1); | ||
20 | |||
21 | $this->assertEquals('foo', $node->getAttribute('name')); | ||
22 | } | ||
23 | |||
24 | /** | ||
25 | * @covers Twig_Node_BlockReference::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 | return array( | ||
36 | array(new Twig_Node_BlockReference('foo', 1), <<<EOF | ||
37 | // line 1 | ||
38 | \$this->displayBlock('foo', \$context, \$blocks); | ||
39 | EOF | ||
40 | ), | ||
41 | ); | ||
42 | } | ||
43 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/BlockTest.php b/vendor/twig/twig/test/Twig/Tests/Node/BlockTest.php new file mode 100644 index 00000000..024049de --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/BlockTest.php | |||
@@ -0,0 +1,51 @@ | |||
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 | |||
12 | class Twig_Tests_Node_BlockTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_Block::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $body = new Twig_Node_Text('foo', 1); | ||
20 | $node = new Twig_Node_Block('foo', $body, 1); | ||
21 | |||
22 | $this->assertEquals($body, $node->getNode('body')); | ||
23 | $this->assertEquals('foo', $node->getAttribute('name')); | ||
24 | } | ||
25 | |||
26 | /** | ||
27 | * @covers Twig_Node_Block::compile | ||
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 | $body = new Twig_Node_Text('foo', 1); | ||
38 | $node = new Twig_Node_Block('foo', $body, 1); | ||
39 | |||
40 | return array( | ||
41 | array($node, <<<EOF | ||
42 | // line 1 | ||
43 | public function block_foo(\$context, array \$blocks = array()) | ||
44 | { | ||
45 | echo "foo"; | ||
46 | } | ||
47 | EOF | ||
48 | ), | ||
49 | ); | ||
50 | } | ||
51 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/DoTest.php b/vendor/twig/twig/test/Twig/Tests/Node/DoTest.php new file mode 100644 index 00000000..a406e22d --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/DoTest.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 | |||
12 | class Twig_Tests_Node_DoTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_Do::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $expr = new Twig_Node_Expression_Constant('foo', 1); | ||
20 | $node = new Twig_Node_Do($expr, 1); | ||
21 | |||
22 | $this->assertEquals($expr, $node->getNode('expr')); | ||
23 | } | ||
24 | |||
25 | /** | ||
26 | * @covers Twig_Node_Do::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 | $tests = array(); | ||
37 | |||
38 | $expr = new Twig_Node_Expression_Constant('foo', 1); | ||
39 | $node = new Twig_Node_Do($expr, 1); | ||
40 | $tests[] = array($node, "// line 1\n\"foo\";"); | ||
41 | |||
42 | return $tests; | ||
43 | } | ||
44 | } | ||
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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
61 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
6 | return $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 | |||
6 | return $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 | |||
6 | return $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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | |||
12 | class 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 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/ForTest.php b/vendor/twig/twig/test/Twig/Tests/Node/ForTest.php new file mode 100644 index 00000000..21cc84e6 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/ForTest.php | |||
@@ -0,0 +1,203 @@ | |||
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 | |||
12 | class Twig_Tests_Node_ForTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_For::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $keyTarget = new Twig_Node_Expression_AssignName('key', 1); | ||
20 | $valueTarget = new Twig_Node_Expression_AssignName('item', 1); | ||
21 | $seq = new Twig_Node_Expression_Name('items', 1); | ||
22 | $ifexpr = new Twig_Node_Expression_Constant(true, 1); | ||
23 | $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1)), array(), 1); | ||
24 | $else = null; | ||
25 | $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); | ||
26 | $node->setAttribute('with_loop', false); | ||
27 | |||
28 | $this->assertEquals($keyTarget, $node->getNode('key_target')); | ||
29 | $this->assertEquals($valueTarget, $node->getNode('value_target')); | ||
30 | $this->assertEquals($seq, $node->getNode('seq')); | ||
31 | $this->assertTrue($node->getAttribute('ifexpr')); | ||
32 | $this->assertEquals('Twig_Node_If', get_class($node->getNode('body'))); | ||
33 | $this->assertEquals($body, $node->getNode('body')->getNode('tests')->getNode(1)->getNode(0)); | ||
34 | $this->assertEquals(null, $node->getNode('else')); | ||
35 | |||
36 | $else = new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1); | ||
37 | $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); | ||
38 | $node->setAttribute('with_loop', false); | ||
39 | $this->assertEquals($else, $node->getNode('else')); | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * @covers Twig_Node_For::compile | ||
44 | * @dataProvider getTests | ||
45 | */ | ||
46 | public function testCompile($node, $source, $environment = null) | ||
47 | { | ||
48 | parent::testCompile($node, $source, $environment); | ||
49 | } | ||
50 | |||
51 | public function getTests() | ||
52 | { | ||
53 | $tests = array(); | ||
54 | |||
55 | $keyTarget = new Twig_Node_Expression_AssignName('key', 1); | ||
56 | $valueTarget = new Twig_Node_Expression_AssignName('item', 1); | ||
57 | $seq = new Twig_Node_Expression_Name('items', 1); | ||
58 | $ifexpr = null; | ||
59 | $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1)), array(), 1); | ||
60 | $else = null; | ||
61 | $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); | ||
62 | $node->setAttribute('with_loop', false); | ||
63 | |||
64 | $tests[] = array($node, <<<EOF | ||
65 | // line 1 | ||
66 | \$context['_parent'] = (array) \$context; | ||
67 | \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('items')}); | ||
68 | foreach (\$context['_seq'] as \$context["key"] => \$context["item"]) { | ||
69 | echo {$this->getVariableGetter('foo')}; | ||
70 | } | ||
71 | \$_parent = \$context['_parent']; | ||
72 | unset(\$context['_seq'], \$context['_iterated'], \$context['key'], \$context['item'], \$context['_parent'], \$context['loop']); | ||
73 | \$context = array_intersect_key(\$context, \$_parent) + \$_parent; | ||
74 | EOF | ||
75 | ); | ||
76 | |||
77 | $keyTarget = new Twig_Node_Expression_AssignName('k', 1); | ||
78 | $valueTarget = new Twig_Node_Expression_AssignName('v', 1); | ||
79 | $seq = new Twig_Node_Expression_Name('values', 1); | ||
80 | $ifexpr = null; | ||
81 | $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1)), array(), 1); | ||
82 | $else = null; | ||
83 | $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); | ||
84 | $node->setAttribute('with_loop', true); | ||
85 | |||
86 | $tests[] = array($node, <<<EOF | ||
87 | // line 1 | ||
88 | \$context['_parent'] = (array) \$context; | ||
89 | \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')}); | ||
90 | \$context['loop'] = array( | ||
91 | 'parent' => \$context['_parent'], | ||
92 | 'index0' => 0, | ||
93 | 'index' => 1, | ||
94 | 'first' => true, | ||
95 | ); | ||
96 | if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof Countable)) { | ||
97 | \$length = count(\$context['_seq']); | ||
98 | \$context['loop']['revindex0'] = \$length - 1; | ||
99 | \$context['loop']['revindex'] = \$length; | ||
100 | \$context['loop']['length'] = \$length; | ||
101 | \$context['loop']['last'] = 1 === \$length; | ||
102 | } | ||
103 | foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) { | ||
104 | echo {$this->getVariableGetter('foo')}; | ||
105 | ++\$context['loop']['index0']; | ||
106 | ++\$context['loop']['index']; | ||
107 | \$context['loop']['first'] = false; | ||
108 | if (isset(\$context['loop']['length'])) { | ||
109 | --\$context['loop']['revindex0']; | ||
110 | --\$context['loop']['revindex']; | ||
111 | \$context['loop']['last'] = 0 === \$context['loop']['revindex0']; | ||
112 | } | ||
113 | } | ||
114 | \$_parent = \$context['_parent']; | ||
115 | unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']); | ||
116 | \$context = array_intersect_key(\$context, \$_parent) + \$_parent; | ||
117 | EOF | ||
118 | ); | ||
119 | |||
120 | $keyTarget = new Twig_Node_Expression_AssignName('k', 1); | ||
121 | $valueTarget = new Twig_Node_Expression_AssignName('v', 1); | ||
122 | $seq = new Twig_Node_Expression_Name('values', 1); | ||
123 | $ifexpr = new Twig_Node_Expression_Constant(true, 1); | ||
124 | $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1)), array(), 1); | ||
125 | $else = null; | ||
126 | $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); | ||
127 | $node->setAttribute('with_loop', true); | ||
128 | |||
129 | $tests[] = array($node, <<<EOF | ||
130 | // line 1 | ||
131 | \$context['_parent'] = (array) \$context; | ||
132 | \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')}); | ||
133 | \$context['loop'] = array( | ||
134 | 'parent' => \$context['_parent'], | ||
135 | 'index0' => 0, | ||
136 | 'index' => 1, | ||
137 | 'first' => true, | ||
138 | ); | ||
139 | foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) { | ||
140 | if (true) { | ||
141 | echo {$this->getVariableGetter('foo')}; | ||
142 | ++\$context['loop']['index0']; | ||
143 | ++\$context['loop']['index']; | ||
144 | \$context['loop']['first'] = false; | ||
145 | } | ||
146 | } | ||
147 | \$_parent = \$context['_parent']; | ||
148 | unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']); | ||
149 | \$context = array_intersect_key(\$context, \$_parent) + \$_parent; | ||
150 | EOF | ||
151 | ); | ||
152 | |||
153 | $keyTarget = new Twig_Node_Expression_AssignName('k', 1); | ||
154 | $valueTarget = new Twig_Node_Expression_AssignName('v', 1); | ||
155 | $seq = new Twig_Node_Expression_Name('values', 1); | ||
156 | $ifexpr = null; | ||
157 | $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1)), array(), 1); | ||
158 | $else = new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1); | ||
159 | $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); | ||
160 | $node->setAttribute('with_loop', true); | ||
161 | |||
162 | $tests[] = array($node, <<<EOF | ||
163 | // line 1 | ||
164 | \$context['_parent'] = (array) \$context; | ||
165 | \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')}); | ||
166 | \$context['_iterated'] = false; | ||
167 | \$context['loop'] = array( | ||
168 | 'parent' => \$context['_parent'], | ||
169 | 'index0' => 0, | ||
170 | 'index' => 1, | ||
171 | 'first' => true, | ||
172 | ); | ||
173 | if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof Countable)) { | ||
174 | \$length = count(\$context['_seq']); | ||
175 | \$context['loop']['revindex0'] = \$length - 1; | ||
176 | \$context['loop']['revindex'] = \$length; | ||
177 | \$context['loop']['length'] = \$length; | ||
178 | \$context['loop']['last'] = 1 === \$length; | ||
179 | } | ||
180 | foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) { | ||
181 | echo {$this->getVariableGetter('foo')}; | ||
182 | \$context['_iterated'] = true; | ||
183 | ++\$context['loop']['index0']; | ||
184 | ++\$context['loop']['index']; | ||
185 | \$context['loop']['first'] = false; | ||
186 | if (isset(\$context['loop']['length'])) { | ||
187 | --\$context['loop']['revindex0']; | ||
188 | --\$context['loop']['revindex']; | ||
189 | \$context['loop']['last'] = 0 === \$context['loop']['revindex0']; | ||
190 | } | ||
191 | } | ||
192 | if (!\$context['_iterated']) { | ||
193 | echo {$this->getVariableGetter('foo')}; | ||
194 | } | ||
195 | \$_parent = \$context['_parent']; | ||
196 | unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']); | ||
197 | \$context = array_intersect_key(\$context, \$_parent) + \$_parent; | ||
198 | EOF | ||
199 | ); | ||
200 | |||
201 | return $tests; | ||
202 | } | ||
203 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/IfTest.php b/vendor/twig/twig/test/Twig/Tests/Node/IfTest.php new file mode 100644 index 00000000..92fc29dc --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/IfTest.php | |||
@@ -0,0 +1,100 @@ | |||
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 | |||
12 | class Twig_Tests_Node_IfTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_If::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $t = new Twig_Node(array( | ||
20 | new Twig_Node_Expression_Constant(true, 1), | ||
21 | new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1), | ||
22 | ), array(), 1); | ||
23 | $else = null; | ||
24 | $node = new Twig_Node_If($t, $else, 1); | ||
25 | |||
26 | $this->assertEquals($t, $node->getNode('tests')); | ||
27 | $this->assertEquals(null, $node->getNode('else')); | ||
28 | |||
29 | $else = new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 1), 1); | ||
30 | $node = new Twig_Node_If($t, $else, 1); | ||
31 | $this->assertEquals($else, $node->getNode('else')); | ||
32 | } | ||
33 | |||
34 | /** | ||
35 | * @covers Twig_Node_If::compile | ||
36 | * @dataProvider getTests | ||
37 | */ | ||
38 | public function testCompile($node, $source, $environment = null) | ||
39 | { | ||
40 | parent::testCompile($node, $source, $environment); | ||
41 | } | ||
42 | |||
43 | public function getTests() | ||
44 | { | ||
45 | $tests = array(); | ||
46 | |||
47 | $t = new Twig_Node(array( | ||
48 | new Twig_Node_Expression_Constant(true, 1), | ||
49 | new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1), | ||
50 | ), array(), 1); | ||
51 | $else = null; | ||
52 | $node = new Twig_Node_If($t, $else, 1); | ||
53 | |||
54 | $tests[] = array($node, <<<EOF | ||
55 | // line 1 | ||
56 | if (true) { | ||
57 | echo {$this->getVariableGetter('foo')}; | ||
58 | } | ||
59 | EOF | ||
60 | ); | ||
61 | |||
62 | $t = new Twig_Node(array( | ||
63 | new Twig_Node_Expression_Constant(true, 1), | ||
64 | new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1), | ||
65 | new Twig_Node_Expression_Constant(false, 1), | ||
66 | new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 1), 1), | ||
67 | ), array(), 1); | ||
68 | $else = null; | ||
69 | $node = new Twig_Node_If($t, $else, 1); | ||
70 | |||
71 | $tests[] = array($node, <<<EOF | ||
72 | // line 1 | ||
73 | if (true) { | ||
74 | echo {$this->getVariableGetter('foo')}; | ||
75 | } elseif (false) { | ||
76 | echo {$this->getVariableGetter('bar')}; | ||
77 | } | ||
78 | EOF | ||
79 | ); | ||
80 | |||
81 | $t = new Twig_Node(array( | ||
82 | new Twig_Node_Expression_Constant(true, 1), | ||
83 | new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1), | ||
84 | ), array(), 1); | ||
85 | $else = new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 1), 1); | ||
86 | $node = new Twig_Node_If($t, $else, 1); | ||
87 | |||
88 | $tests[] = array($node, <<<EOF | ||
89 | // line 1 | ||
90 | if (true) { | ||
91 | echo {$this->getVariableGetter('foo')}; | ||
92 | } else { | ||
93 | echo {$this->getVariableGetter('bar')}; | ||
94 | } | ||
95 | EOF | ||
96 | ); | ||
97 | |||
98 | return $tests; | ||
99 | } | ||
100 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php b/vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php new file mode 100644 index 00000000..db36581a --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php | |||
@@ -0,0 +1,52 @@ | |||
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 | |||
12 | class Twig_Tests_Node_ImportTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_Import::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $macro = new Twig_Node_Expression_Constant('foo.twig', 1); | ||
20 | $var = new Twig_Node_Expression_AssignName('macro', 1); | ||
21 | $node = new Twig_Node_Import($macro, $var, 1); | ||
22 | |||
23 | $this->assertEquals($macro, $node->getNode('expr')); | ||
24 | $this->assertEquals($var, $node->getNode('var')); | ||
25 | } | ||
26 | |||
27 | /** | ||
28 | * @covers Twig_Node_Import::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 | $tests = array(); | ||
39 | |||
40 | $macro = new Twig_Node_Expression_Constant('foo.twig', 1); | ||
41 | $var = new Twig_Node_Expression_AssignName('macro', 1); | ||
42 | $node = new Twig_Node_Import($macro, $var, 1); | ||
43 | |||
44 | $tests[] = array($node, <<<EOF | ||
45 | // line 1 | ||
46 | \$context["macro"] = \$this->env->loadTemplate("foo.twig"); | ||
47 | EOF | ||
48 | ); | ||
49 | |||
50 | return $tests; | ||
51 | } | ||
52 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php b/vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php new file mode 100644 index 00000000..3b7da6e0 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php | |||
@@ -0,0 +1,96 @@ | |||
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 | |||
12 | class Twig_Tests_Node_IncludeTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_Include::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $expr = new Twig_Node_Expression_Constant('foo.twig', 1); | ||
20 | $node = new Twig_Node_Include($expr, null, false, false, 1); | ||
21 | |||
22 | $this->assertEquals(null, $node->getNode('variables')); | ||
23 | $this->assertEquals($expr, $node->getNode('expr')); | ||
24 | $this->assertFalse($node->getAttribute('only')); | ||
25 | |||
26 | $vars = new Twig_Node_Expression_Array(array(new Twig_Node_Expression_Constant('foo', 1), new Twig_Node_Expression_Constant(true, 1)), 1); | ||
27 | $node = new Twig_Node_Include($expr, $vars, true, false, 1); | ||
28 | $this->assertEquals($vars, $node->getNode('variables')); | ||
29 | $this->assertTrue($node->getAttribute('only')); | ||
30 | } | ||
31 | |||
32 | /** | ||
33 | * @covers Twig_Node_Include::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_Constant('foo.twig', 1); | ||
46 | $node = new Twig_Node_Include($expr, null, false, false, 1); | ||
47 | $tests[] = array($node, <<<EOF | ||
48 | // line 1 | ||
49 | \$this->env->loadTemplate("foo.twig")->display(\$context); | ||
50 | EOF | ||
51 | ); | ||
52 | |||
53 | $expr = new Twig_Node_Expression_Conditional( | ||
54 | new Twig_Node_Expression_Constant(true, 1), | ||
55 | new Twig_Node_Expression_Constant('foo', 1), | ||
56 | new Twig_Node_Expression_Constant('foo', 1), | ||
57 | 0 | ||
58 | ); | ||
59 | $node = new Twig_Node_Include($expr, null, false, false, 1); | ||
60 | $tests[] = array($node, <<<EOF | ||
61 | // line 1 | ||
62 | \$template = \$this->env->resolveTemplate(((true) ? ("foo") : ("foo"))); | ||
63 | \$template->display(\$context); | ||
64 | EOF | ||
65 | ); | ||
66 | |||
67 | $expr = new Twig_Node_Expression_Constant('foo.twig', 1); | ||
68 | $vars = new Twig_Node_Expression_Array(array(new Twig_Node_Expression_Constant('foo', 1), new Twig_Node_Expression_Constant(true, 1)), 1); | ||
69 | $node = new Twig_Node_Include($expr, $vars, false, false, 1); | ||
70 | $tests[] = array($node, <<<EOF | ||
71 | // line 1 | ||
72 | \$this->env->loadTemplate("foo.twig")->display(array_merge(\$context, array("foo" => true))); | ||
73 | EOF | ||
74 | ); | ||
75 | |||
76 | $node = new Twig_Node_Include($expr, $vars, true, false, 1); | ||
77 | $tests[] = array($node, <<<EOF | ||
78 | // line 1 | ||
79 | \$this->env->loadTemplate("foo.twig")->display(array("foo" => true)); | ||
80 | EOF | ||
81 | ); | ||
82 | |||
83 | $node = new Twig_Node_Include($expr, $vars, true, true, 1); | ||
84 | $tests[] = array($node, <<<EOF | ||
85 | // line 1 | ||
86 | try { | ||
87 | \$this->env->loadTemplate("foo.twig")->display(array("foo" => true)); | ||
88 | } catch (Twig_Error_Loader \$e) { | ||
89 | // ignore missing template | ||
90 | } | ||
91 | EOF | ||
92 | ); | ||
93 | |||
94 | return $tests; | ||
95 | } | ||
96 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php b/vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php new file mode 100644 index 00000000..4d2f641b --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php | |||
@@ -0,0 +1,73 @@ | |||
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 | |||
12 | class Twig_Tests_Node_MacroTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_Macro::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $body = new Twig_Node_Text('foo', 1); | ||
20 | $arguments = new Twig_Node(array(new Twig_Node_Expression_Name('foo', 1)), array(), 1); | ||
21 | $node = new Twig_Node_Macro('foo', $body, $arguments, 1); | ||
22 | |||
23 | $this->assertEquals($body, $node->getNode('body')); | ||
24 | $this->assertEquals($arguments, $node->getNode('arguments')); | ||
25 | $this->assertEquals('foo', $node->getAttribute('name')); | ||
26 | } | ||
27 | |||
28 | /** | ||
29 | * @covers Twig_Node_Macro::compile | ||
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 | $body = new Twig_Node_Text('foo', 1); | ||
40 | $arguments = new Twig_Node(array( | ||
41 | 'foo' => new Twig_Node_Expression_Constant(null, 1), | ||
42 | 'bar' => new Twig_Node_Expression_Constant('Foo', 1), | ||
43 | ), array(), 1); | ||
44 | $node = new Twig_Node_Macro('foo', $body, $arguments, 1); | ||
45 | |||
46 | return array( | ||
47 | array($node, <<<EOF | ||
48 | // line 1 | ||
49 | public function getfoo(\$_foo = null, \$_bar = "Foo") | ||
50 | { | ||
51 | \$context = \$this->env->mergeGlobals(array( | ||
52 | "foo" => \$_foo, | ||
53 | "bar" => \$_bar, | ||
54 | )); | ||
55 | |||
56 | \$blocks = array(); | ||
57 | |||
58 | ob_start(); | ||
59 | try { | ||
60 | echo "foo"; | ||
61 | } catch (Exception \$e) { | ||
62 | ob_end_clean(); | ||
63 | |||
64 | throw \$e; | ||
65 | } | ||
66 | |||
67 | return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset()); | ||
68 | } | ||
69 | EOF | ||
70 | ), | ||
71 | ); | ||
72 | } | ||
73 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php b/vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php new file mode 100644 index 00000000..9411e99e --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php | |||
@@ -0,0 +1,196 @@ | |||
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 | |||
12 | class Twig_Tests_Node_ModuleTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_Module::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $body = new Twig_Node_Text('foo', 1); | ||
20 | $parent = new Twig_Node_Expression_Constant('layout.twig', 1); | ||
21 | $blocks = new Twig_Node(); | ||
22 | $macros = new Twig_Node(); | ||
23 | $traits = new Twig_Node(); | ||
24 | $filename = 'foo.twig'; | ||
25 | $node = new Twig_Node_Module($body, $parent, $blocks, $macros, $traits, new Twig_Node(array()), $filename); | ||
26 | |||
27 | $this->assertEquals($body, $node->getNode('body')); | ||
28 | $this->assertEquals($blocks, $node->getNode('blocks')); | ||
29 | $this->assertEquals($macros, $node->getNode('macros')); | ||
30 | $this->assertEquals($parent, $node->getNode('parent')); | ||
31 | $this->assertEquals($filename, $node->getAttribute('filename')); | ||
32 | } | ||
33 | |||
34 | /** | ||
35 | * @covers Twig_Node_Module::compile | ||
36 | * @covers Twig_Node_Module::compileTemplate | ||
37 | * @covers Twig_Node_Module::compileMacros | ||
38 | * @covers Twig_Node_Module::compileClassHeader | ||
39 | * @covers Twig_Node_Module::compileDisplayHeader | ||
40 | * @covers Twig_Node_Module::compileDisplayBody | ||
41 | * @covers Twig_Node_Module::compileDisplayFooter | ||
42 | * @covers Twig_Node_Module::compileClassFooter | ||
43 | * @dataProvider getTests | ||
44 | */ | ||
45 | public function testCompile($node, $source, $environment = null) | ||
46 | { | ||
47 | parent::testCompile($node, $source, $environment); | ||
48 | } | ||
49 | |||
50 | public function getTests() | ||
51 | { | ||
52 | $twig = new Twig_Environment(new Twig_Loader_String()); | ||
53 | |||
54 | $tests = array(); | ||
55 | |||
56 | $body = new Twig_Node_Text('foo', 1); | ||
57 | $extends = null; | ||
58 | $blocks = new Twig_Node(); | ||
59 | $macros = new Twig_Node(); | ||
60 | $traits = new Twig_Node(); | ||
61 | $filename = 'foo.twig'; | ||
62 | |||
63 | $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $filename); | ||
64 | $tests[] = array($node, <<<EOF | ||
65 | <?php | ||
66 | |||
67 | /* foo.twig */ | ||
68 | class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template | ||
69 | { | ||
70 | public function __construct(Twig_Environment \$env) | ||
71 | { | ||
72 | parent::__construct(\$env); | ||
73 | |||
74 | \$this->parent = false; | ||
75 | |||
76 | \$this->blocks = array( | ||
77 | ); | ||
78 | } | ||
79 | |||
80 | protected function doDisplay(array \$context, array \$blocks = array()) | ||
81 | { | ||
82 | // line 1 | ||
83 | echo "foo"; | ||
84 | } | ||
85 | |||
86 | public function getTemplateName() | ||
87 | { | ||
88 | return "foo.twig"; | ||
89 | } | ||
90 | |||
91 | public function getDebugInfo() | ||
92 | { | ||
93 | return array ( 19 => 1,); | ||
94 | } | ||
95 | } | ||
96 | EOF | ||
97 | , $twig); | ||
98 | |||
99 | $import = new Twig_Node_Import(new Twig_Node_Expression_Constant('foo.twig', 1), new Twig_Node_Expression_AssignName('macro', 1), 1); | ||
100 | |||
101 | $body = new Twig_Node(array($import)); | ||
102 | $extends = new Twig_Node_Expression_Constant('layout.twig', 1); | ||
103 | |||
104 | $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $filename); | ||
105 | $tests[] = array($node, <<<EOF | ||
106 | <?php | ||
107 | |||
108 | /* foo.twig */ | ||
109 | class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template | ||
110 | { | ||
111 | public function __construct(Twig_Environment \$env) | ||
112 | { | ||
113 | parent::__construct(\$env); | ||
114 | |||
115 | \$this->parent = \$this->env->loadTemplate("layout.twig"); | ||
116 | |||
117 | \$this->blocks = array( | ||
118 | ); | ||
119 | } | ||
120 | |||
121 | protected function doGetParent(array \$context) | ||
122 | { | ||
123 | return "layout.twig"; | ||
124 | } | ||
125 | |||
126 | protected function doDisplay(array \$context, array \$blocks = array()) | ||
127 | { | ||
128 | // line 1 | ||
129 | \$context["macro"] = \$this->env->loadTemplate("foo.twig"); | ||
130 | \$this->parent->display(\$context, array_merge(\$this->blocks, \$blocks)); | ||
131 | } | ||
132 | |||
133 | public function getTemplateName() | ||
134 | { | ||
135 | return "foo.twig"; | ||
136 | } | ||
137 | |||
138 | public function isTraitable() | ||
139 | { | ||
140 | return false; | ||
141 | } | ||
142 | |||
143 | public function getDebugInfo() | ||
144 | { | ||
145 | return array ( 24 => 1,); | ||
146 | } | ||
147 | } | ||
148 | EOF | ||
149 | , $twig); | ||
150 | |||
151 | $body = new Twig_Node(); | ||
152 | $extends = new Twig_Node_Expression_Conditional( | ||
153 | new Twig_Node_Expression_Constant(true, 1), | ||
154 | new Twig_Node_Expression_Constant('foo', 1), | ||
155 | new Twig_Node_Expression_Constant('foo', 1), | ||
156 | 0 | ||
157 | ); | ||
158 | |||
159 | $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $filename); | ||
160 | $tests[] = array($node, <<<EOF | ||
161 | <?php | ||
162 | |||
163 | /* foo.twig */ | ||
164 | class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template | ||
165 | { | ||
166 | protected function doGetParent(array \$context) | ||
167 | { | ||
168 | return \$this->env->resolveTemplate(((true) ? ("foo") : ("foo"))); | ||
169 | } | ||
170 | |||
171 | protected function doDisplay(array \$context, array \$blocks = array()) | ||
172 | { | ||
173 | \$this->getParent(\$context)->display(\$context, array_merge(\$this->blocks, \$blocks)); | ||
174 | } | ||
175 | |||
176 | public function getTemplateName() | ||
177 | { | ||
178 | return "foo.twig"; | ||
179 | } | ||
180 | |||
181 | public function isTraitable() | ||
182 | { | ||
183 | return false; | ||
184 | } | ||
185 | |||
186 | public function getDebugInfo() | ||
187 | { | ||
188 | return array (); | ||
189 | } | ||
190 | } | ||
191 | EOF | ||
192 | , $twig); | ||
193 | |||
194 | return $tests; | ||
195 | } | ||
196 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/PrintTest.php b/vendor/twig/twig/test/Twig/Tests/Node/PrintTest.php new file mode 100644 index 00000000..6fe43a41 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/PrintTest.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 | |||
12 | class Twig_Tests_Node_PrintTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_Print::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $expr = new Twig_Node_Expression_Constant('foo', 1); | ||
20 | $node = new Twig_Node_Print($expr, 1); | ||
21 | |||
22 | $this->assertEquals($expr, $node->getNode('expr')); | ||
23 | } | ||
24 | |||
25 | /** | ||
26 | * @covers Twig_Node_Print::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 | $tests = array(); | ||
37 | $tests[] = array(new Twig_Node_Print(new Twig_Node_Expression_Constant('foo', 1), 1), "// line 1\necho \"foo\";"); | ||
38 | |||
39 | return $tests; | ||
40 | } | ||
41 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/SandboxTest.php b/vendor/twig/twig/test/Twig/Tests/Node/SandboxTest.php new file mode 100644 index 00000000..db9dbf95 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/SandboxTest.php | |||
@@ -0,0 +1,56 @@ | |||
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 | |||
12 | class Twig_Tests_Node_SandboxTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_Sandbox::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $body = new Twig_Node_Text('foo', 1); | ||
20 | $node = new Twig_Node_Sandbox($body, 1); | ||
21 | |||
22 | $this->assertEquals($body, $node->getNode('body')); | ||
23 | } | ||
24 | |||
25 | /** | ||
26 | * @covers Twig_Node_Sandbox::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 | $tests = array(); | ||
37 | |||
38 | $body = new Twig_Node_Text('foo', 1); | ||
39 | $node = new Twig_Node_Sandbox($body, 1); | ||
40 | |||
41 | $tests[] = array($node, <<<EOF | ||
42 | // line 1 | ||
43 | \$sandbox = \$this->env->getExtension('sandbox'); | ||
44 | if (!\$alreadySandboxed = \$sandbox->isSandboxed()) { | ||
45 | \$sandbox->enableSandbox(); | ||
46 | } | ||
47 | echo "foo"; | ||
48 | if (!\$alreadySandboxed) { | ||
49 | \$sandbox->disableSandbox(); | ||
50 | } | ||
51 | EOF | ||
52 | ); | ||
53 | |||
54 | return $tests; | ||
55 | } | ||
56 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/SandboxedModuleTest.php b/vendor/twig/twig/test/Twig/Tests/Node/SandboxedModuleTest.php new file mode 100644 index 00000000..217e3408 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/SandboxedModuleTest.php | |||
@@ -0,0 +1,173 @@ | |||
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 | |||
12 | class Twig_Tests_Node_SandboxedModuleTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_SandboxedModule::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $body = new Twig_Node_Text('foo', 1); | ||
20 | $parent = new Twig_Node_Expression_Constant('layout.twig', 1); | ||
21 | $blocks = new Twig_Node(); | ||
22 | $macros = new Twig_Node(); | ||
23 | $traits = new Twig_Node(); | ||
24 | $filename = 'foo.twig'; | ||
25 | $node = new Twig_Node_Module($body, $parent, $blocks, $macros, $traits, new Twig_Node(array()), $filename); | ||
26 | $node = new Twig_Node_SandboxedModule($node, array('for'), array('upper'), array('cycle')); | ||
27 | |||
28 | $this->assertEquals($body, $node->getNode('body')); | ||
29 | $this->assertEquals($blocks, $node->getNode('blocks')); | ||
30 | $this->assertEquals($macros, $node->getNode('macros')); | ||
31 | $this->assertEquals($parent, $node->getNode('parent')); | ||
32 | $this->assertEquals($filename, $node->getAttribute('filename')); | ||
33 | } | ||
34 | |||
35 | /** | ||
36 | * @covers Twig_Node_SandboxedModule::compile | ||
37 | * @covers Twig_Node_SandboxedModule::compileDisplayBody | ||
38 | * @covers Twig_Node_SandboxedModule::compileDisplayFooter | ||
39 | * @dataProvider getTests | ||
40 | */ | ||
41 | public function testCompile($node, $source, $environment = null) | ||
42 | { | ||
43 | parent::testCompile($node, $source, $environment); | ||
44 | } | ||
45 | |||
46 | public function getTests() | ||
47 | { | ||
48 | $twig = new Twig_Environment(new Twig_Loader_String()); | ||
49 | |||
50 | $tests = array(); | ||
51 | |||
52 | $body = new Twig_Node_Text('foo', 1); | ||
53 | $extends = null; | ||
54 | $blocks = new Twig_Node(); | ||
55 | $macros = new Twig_Node(); | ||
56 | $traits = new Twig_Node(); | ||
57 | $filename = 'foo.twig'; | ||
58 | |||
59 | $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $filename); | ||
60 | $node = new Twig_Node_SandboxedModule($node, array('for'), array('upper'), array('cycle')); | ||
61 | |||
62 | $tests[] = array($node, <<<EOF | ||
63 | <?php | ||
64 | |||
65 | /* foo.twig */ | ||
66 | class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template | ||
67 | { | ||
68 | public function __construct(Twig_Environment \$env) | ||
69 | { | ||
70 | parent::__construct(\$env); | ||
71 | |||
72 | \$this->parent = false; | ||
73 | |||
74 | \$this->blocks = array( | ||
75 | ); | ||
76 | } | ||
77 | |||
78 | protected function doDisplay(array \$context, array \$blocks = array()) | ||
79 | { | ||
80 | \$this->checkSecurity(); | ||
81 | // line 1 | ||
82 | echo "foo"; | ||
83 | } | ||
84 | |||
85 | protected function checkSecurity() | ||
86 | { | ||
87 | \$this->env->getExtension('sandbox')->checkSecurity( | ||
88 | array('upper'), | ||
89 | array('for'), | ||
90 | array('cycle') | ||
91 | ); | ||
92 | } | ||
93 | |||
94 | public function getTemplateName() | ||
95 | { | ||
96 | return "foo.twig"; | ||
97 | } | ||
98 | |||
99 | public function getDebugInfo() | ||
100 | { | ||
101 | return array ( 20 => 1,); | ||
102 | } | ||
103 | } | ||
104 | EOF | ||
105 | , $twig); | ||
106 | |||
107 | $body = new Twig_Node(); | ||
108 | $extends = new Twig_Node_Expression_Constant('layout.twig', 1); | ||
109 | $blocks = new Twig_Node(); | ||
110 | $macros = new Twig_Node(); | ||
111 | $traits = new Twig_Node(); | ||
112 | $filename = 'foo.twig'; | ||
113 | |||
114 | $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $filename); | ||
115 | $node = new Twig_Node_SandboxedModule($node, array('for'), array('upper'), array('cycle')); | ||
116 | |||
117 | $tests[] = array($node, <<<EOF | ||
118 | <?php | ||
119 | |||
120 | /* foo.twig */ | ||
121 | class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template | ||
122 | { | ||
123 | public function __construct(Twig_Environment \$env) | ||
124 | { | ||
125 | parent::__construct(\$env); | ||
126 | |||
127 | \$this->parent = \$this->env->loadTemplate("layout.twig"); | ||
128 | |||
129 | \$this->blocks = array( | ||
130 | ); | ||
131 | } | ||
132 | |||
133 | protected function doGetParent(array \$context) | ||
134 | { | ||
135 | return "layout.twig"; | ||
136 | } | ||
137 | |||
138 | protected function doDisplay(array \$context, array \$blocks = array()) | ||
139 | { | ||
140 | \$this->checkSecurity(); | ||
141 | \$this->parent->display(\$context, array_merge(\$this->blocks, \$blocks)); | ||
142 | } | ||
143 | |||
144 | protected function checkSecurity() | ||
145 | { | ||
146 | \$this->env->getExtension('sandbox')->checkSecurity( | ||
147 | array('upper'), | ||
148 | array('for'), | ||
149 | array('cycle') | ||
150 | ); | ||
151 | } | ||
152 | |||
153 | public function getTemplateName() | ||
154 | { | ||
155 | return "foo.twig"; | ||
156 | } | ||
157 | |||
158 | public function isTraitable() | ||
159 | { | ||
160 | return false; | ||
161 | } | ||
162 | |||
163 | public function getDebugInfo() | ||
164 | { | ||
165 | return array (); | ||
166 | } | ||
167 | } | ||
168 | EOF | ||
169 | , $twig); | ||
170 | |||
171 | return $tests; | ||
172 | } | ||
173 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/SandboxedPrintTest.php b/vendor/twig/twig/test/Twig/Tests/Node/SandboxedPrintTest.php new file mode 100644 index 00000000..058e02bc --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/SandboxedPrintTest.php | |||
@@ -0,0 +1,45 @@ | |||
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 | |||
12 | class Twig_Tests_Node_SandboxedPrintTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_SandboxedPrint::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $node = new Twig_Node_SandboxedPrint($expr = new Twig_Node_Expression_Constant('foo', 1), 1); | ||
20 | |||
21 | $this->assertEquals($expr, $node->getNode('expr')); | ||
22 | } | ||
23 | |||
24 | /** | ||
25 | * @covers Twig_Node_SandboxedPrint::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 | $tests[] = array(new Twig_Node_SandboxedPrint(new Twig_Node_Expression_Constant('foo', 1), 1), <<<EOF | ||
38 | // line 1 | ||
39 | echo \$this->env->getExtension('sandbox')->ensureToStringAllowed("foo"); | ||
40 | EOF | ||
41 | ); | ||
42 | |||
43 | return $tests; | ||
44 | } | ||
45 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/SetTest.php b/vendor/twig/twig/test/Twig/Tests/Node/SetTest.php new file mode 100644 index 00000000..d64d671a --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/SetTest.php | |||
@@ -0,0 +1,81 @@ | |||
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 | |||
12 | class Twig_Tests_Node_SetTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_Set::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1); | ||
20 | $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 1)), array(), 1); | ||
21 | $node = new Twig_Node_Set(false, $names, $values, 1); | ||
22 | |||
23 | $this->assertEquals($names, $node->getNode('names')); | ||
24 | $this->assertEquals($values, $node->getNode('values')); | ||
25 | $this->assertEquals(false, $node->getAttribute('capture')); | ||
26 | } | ||
27 | |||
28 | /** | ||
29 | * @covers Twig_Node_Set::compile | ||
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 | $tests = array(); | ||
40 | |||
41 | $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1); | ||
42 | $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 1)), array(), 1); | ||
43 | $node = new Twig_Node_Set(false, $names, $values, 1); | ||
44 | $tests[] = array($node, <<<EOF | ||
45 | // line 1 | ||
46 | \$context["foo"] = "foo"; | ||
47 | EOF | ||
48 | ); | ||
49 | |||
50 | $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1); | ||
51 | $values = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Constant('foo', 1), 1)), array(), 1); | ||
52 | $node = new Twig_Node_Set(true, $names, $values, 1); | ||
53 | $tests[] = array($node, <<<EOF | ||
54 | // line 1 | ||
55 | ob_start(); | ||
56 | echo "foo"; | ||
57 | \$context["foo"] = ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset()); | ||
58 | EOF | ||
59 | ); | ||
60 | |||
61 | $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1); | ||
62 | $values = new Twig_Node_Text('foo', 1); | ||
63 | $node = new Twig_Node_Set(true, $names, $values, 1); | ||
64 | $tests[] = array($node, <<<EOF | ||
65 | // line 1 | ||
66 | \$context["foo"] = ('' === \$tmp = "foo") ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset()); | ||
67 | EOF | ||
68 | ); | ||
69 | |||
70 | $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1), new Twig_Node_Expression_AssignName('bar', 1)), array(), 1); | ||
71 | $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 1), new Twig_Node_Expression_Name('bar', 1)), array(), 1); | ||
72 | $node = new Twig_Node_Set(false, $names, $values, 1); | ||
73 | $tests[] = array($node, <<<EOF | ||
74 | // line 1 | ||
75 | list(\$context["foo"], \$context["bar"]) = array("foo", {$this->getVariableGetter('bar')}); | ||
76 | EOF | ||
77 | ); | ||
78 | |||
79 | return $tests; | ||
80 | } | ||
81 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/SpacelessTest.php b/vendor/twig/twig/test/Twig/Tests/Node/SpacelessTest.php new file mode 100644 index 00000000..6735dc31 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/SpacelessTest.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 | |||
12 | class Twig_Tests_Node_SpacelessTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_Spaceless::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 1))); | ||
20 | $node = new Twig_Node_Spaceless($body, 1); | ||
21 | |||
22 | $this->assertEquals($body, $node->getNode('body')); | ||
23 | } | ||
24 | |||
25 | /** | ||
26 | * @covers Twig_Node_Spaceless::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 | $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 1))); | ||
37 | $node = new Twig_Node_Spaceless($body, 1); | ||
38 | |||
39 | return array( | ||
40 | array($node, <<<EOF | ||
41 | // line 1 | ||
42 | ob_start(); | ||
43 | echo "<div> <div> foo </div> </div>"; | ||
44 | echo trim(preg_replace('/>\s+</', '><', ob_get_clean())); | ||
45 | EOF | ||
46 | ), | ||
47 | ); | ||
48 | } | ||
49 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/TextTest.php b/vendor/twig/twig/test/Twig/Tests/Node/TextTest.php new file mode 100644 index 00000000..6f85576e --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Node/TextTest.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 | |||
12 | class Twig_Tests_Node_TextTest extends Twig_Test_NodeTestCase | ||
13 | { | ||
14 | /** | ||
15 | * @covers Twig_Node_Text::__construct | ||
16 | */ | ||
17 | public function testConstructor() | ||
18 | { | ||
19 | $node = new Twig_Node_Text('foo', 1); | ||
20 | |||
21 | $this->assertEquals('foo', $node->getAttribute('data')); | ||
22 | } | ||
23 | |||
24 | /** | ||
25 | * @covers Twig_Node_Text::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_Text('foo', 1), "// line 1\necho \"foo\";"); | ||
37 | |||
38 | return $tests; | ||
39 | } | ||
40 | } | ||