From 8a8f22131c28af7bb107277ed7f4633ec2e366f0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 10 Aug 2024 18:25:26 +0200 Subject: [PATCH] Simplify tests --- tests/Node/Expression/CallTest.php | 48 ++++++++++++++---------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/tests/Node/Expression/CallTest.php b/tests/Node/Expression/CallTest.php index 470512076..7f02e68f5 100644 --- a/tests/Node/Expression/CallTest.php +++ b/tests/Node/Expression/CallTest.php @@ -102,6 +102,24 @@ class CallTest extends TestCase $this->getArguments($node, ['', []]); } + public function testResolveArgumentsWithMissingParameterForArbitraryArgumentsOnFunction() + { + $this->expectException(\LogicException::class); + $this->expectExceptionMessageMatches('#^The last parameter of "Twig\\\\Tests\\\\Node\\\\Expression\\\\custom_call_test_function" for function "foo" must be an array with default value, eg\\. "array \\$arg \\= \\[\\]"\\.$#'); + + $node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'foo', 'is_variadic' => true]); + $this->getArguments($node, ['Twig\Tests\Node\Expression\custom_call_test_function', []]); + } + + public function testResolveArgumentsWithMissingParameterForArbitraryArgumentsOnObject() + { + $this->expectException(\LogicException::class); + $this->expectExceptionMessageMatches('#^The last parameter of "Twig\\\\Tests\\\\Node\\\\Expression\\\\CallableTestClass\\:\\:__invoke" for function "foo" must be an array with default value, eg\\. "array \\$arg \\= \\[\\]"\\.$#'); + + $node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'foo', 'is_variadic' => true]); + $this->getArguments($node, [new CallableTestClass(), []]); + } + public static function customStaticFunction($arg1, $arg2 = 'default', $arg3 = []) { } @@ -110,6 +128,10 @@ class CallTest extends TestCase { } + public function customFunctionWithArbitraryArguments() + { + } + private function getArguments($call, $args) { $m = new \ReflectionMethod($call, 'getArguments'); @@ -117,36 +139,10 @@ class CallTest extends TestCase return $m->invokeArgs($call, $args); } - - public function customFunctionWithArbitraryArguments() - { - } - - public function testResolveArgumentsWithMissingParameterForArbitraryArgumentsOnFunction() - { - $this->expectException(\LogicException::class); - $this->expectExceptionMessageMatches('#^The last parameter of "Twig\\\\Tests\\\\Node\\\\Expression\\\\custom_call_test_function" for function "foo" must be an array with default value, eg\\. "array \\$arg \\= \\[\\]"\\.$#'); - - $node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'foo', 'is_variadic' => true]); - $node->getArguments('Twig\Tests\Node\Expression\custom_call_test_function', []); - } - - public function testResolveArgumentsWithMissingParameterForArbitraryArgumentsOnObject() - { - $this->expectException(\LogicException::class); - $this->expectExceptionMessageMatches('#^The last parameter of "Twig\\\\Tests\\\\Node\\\\Expression\\\\CallableTestClass\\:\\:__invoke" for function "foo" must be an array with default value, eg\\. "array \\$arg \\= \\[\\]"\\.$#'); - - $node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'foo', 'is_variadic' => true]); - $node->getArguments(new CallableTestClass(), []); - } } class Node_Expression_Call extends CallExpression { - public function getArguments($callable, $arguments) - { - return parent::getArguments($callable, $arguments); - } } class CallableTestClass