mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
Fixed exception message in Call
This commit is contained in:
@@ -146,7 +146,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
||||
|
||||
if (array_key_exists($name, $parameters)) {
|
||||
if (array_key_exists($pos, $parameters)) {
|
||||
throw new Twig_Error_Syntax(sprintf('Arguments "%s" is defined twice for %s "%s".', $name, $this->getAttribute('type'), $this->getAttribute('name')));
|
||||
throw new Twig_Error_Syntax(sprintf('Argument "%s" is defined twice for %s "%s".', $name, $this->getAttribute('type'), $this->getAttribute('name')));
|
||||
}
|
||||
|
||||
$arguments[] = $parameters[$name];
|
||||
@@ -164,8 +164,8 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array_keys($parameters) as $name) {
|
||||
throw new Twig_Error_Syntax(sprintf('Unknown argument "%s" for %s "%s".', $name, $this->getAttribute('type'), $this->getAttribute('name')));
|
||||
if (!empty($parameters)) {
|
||||
throw new Twig_Error_Syntax(sprintf('Unknown argument%s "%s" for %s "%s".', count($parameters) > 1 ? 's' : '' , implode('", "', array_keys($parameters)), $this->getAttribute('type'), $this->getAttribute('name')));
|
||||
}
|
||||
|
||||
return $arguments;
|
||||
|
||||
@@ -29,13 +29,33 @@ class Twig_Tests_Node_Expression_CallTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @expectedException Twig_Error_Syntax
|
||||
* @expectedExceptionMessage Arguments "format" is defined twice for function "date".
|
||||
* @expectedExceptionMessage Argument "format" is defined twice for function "date".
|
||||
*/
|
||||
public function testGetArgumentsWhenArgumentIsDefinedTwice()
|
||||
{
|
||||
$node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date'));
|
||||
$node->getArguments('date', array('Y-m-d', 'format' => 'U'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Twig_Error_Syntax
|
||||
* @expectedExceptionMessage Unknown argument "unknown" for function "date".
|
||||
*/
|
||||
public function testGetArgumentsWithWrongNamedArgumentName()
|
||||
{
|
||||
$node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date'));
|
||||
$node->getArguments('date', array('Y-m-d', 'unknown' => ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Twig_Error_Syntax
|
||||
* @expectedExceptionMessage Unknown arguments "unknown1", "unknown2" for function "date".
|
||||
*/
|
||||
public function testGetArgumentsWithWrongNamedArgumentNames()
|
||||
{
|
||||
$node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date'));
|
||||
$node->getArguments('date', array('Y-m-d', 'unknown1' => '', 'unknown2' => ''));
|
||||
}
|
||||
}
|
||||
|
||||
class Twig_Tests_Node_Expression_Call extends Twig_Node_Expression_Call
|
||||
|
||||
Reference in New Issue
Block a user