aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php')
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php67
1 files changed, 67 insertions, 0 deletions
diff --git a/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php b/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php
new file mode 100644
index 00000000..53b5e6ee
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php
@@ -0,0 +1,67 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12class Twig_Tests_Node_Expression_CallTest extends PHPUnit_Framework_TestCase
13{
14 public function testGetArguments()
15 {
16 $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date'));
17 $this->assertEquals(array('U'), $node->getArguments('date', array('format' => 'U')));
18 }
19
20 /**
21 * @expectedException Twig_Error_Syntax
22 * @expectedExceptionMessage Positional arguments cannot be used after named arguments for function "date".
23 */
24 public function testGetArgumentsWhenPositionalArgumentsAfterNamedArguments()
25 {
26 $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date'));
27 $node->getArguments('date', array('timestamp' => 123456, 'Y-m-d'));
28 }
29
30 /**
31 * @expectedException Twig_Error_Syntax
32 * @expectedExceptionMessage Argument "format" is defined twice for function "date".
33 */
34 public function testGetArgumentsWhenArgumentIsDefinedTwice()
35 {
36 $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date'));
37 $node->getArguments('date', array('Y-m-d', 'format' => 'U'));
38 }
39
40 /**
41 * @expectedException Twig_Error_Syntax
42 * @expectedExceptionMessage Unknown argument "unknown" for function "date".
43 */
44 public function testGetArgumentsWithWrongNamedArgumentName()
45 {
46 $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date'));
47 $node->getArguments('date', array('Y-m-d', 'unknown' => ''));
48 }
49
50 /**
51 * @expectedException Twig_Error_Syntax
52 * @expectedExceptionMessage Unknown arguments "unknown1", "unknown2" for function "date".
53 */
54 public function testGetArgumentsWithWrongNamedArgumentNames()
55 {
56 $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date'));
57 $node->getArguments('date', array('Y-m-d', 'unknown1' => '', 'unknown2' => ''));
58 }
59}
60
61class Twig_Tests_Node_Expression_Call extends Twig_Node_Expression_Call
62{
63 public function getArguments($callable, $arguments)
64 {
65 return parent::getArguments($callable, $arguments);
66 }
67}