Example #1
0
 /**
  * @expectedException              LogicException
  * @expectedExceptionMessageRegExp #^The last parameter of "CallableTestClass\:\:__invoke" for function "foo" must be an array with default value, eg\. "array \$arg \= array\(\)"\.$#
  */
 public function testResolveArgumentsWithMissingParameterForArbitraryArgumentsOnObject()
 {
     $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'foo', 'is_variadic' => true));
     $node->getArguments(new CallableTestClass(), array());
 }
Example #2
0
 /**
  * @expectedException        Twig_Error_Syntax
  * @expectedExceptionMessage Arguments "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'));
 }
Example #3
0
 /**
  * @expectedException        LogicException
  * @expectedExceptionMessage The last parameter of "Twig_Tests_Node_Expression_CallTest::customFunctionWithArbitraryArguments" for function "foo" must be an array with default value, eg. "array $arg = array()".
  */
 public function testResolveArgumentsWithMissingParameterForArbitraryArguments()
 {
     $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'foo', 'is_variadic' => true));
     $node->getArguments(array($this, 'customFunctionWithArbitraryArguments'), array());
 }
Example #4
0
 public function testResolveArgumentsOnlyNecessaryArgumentsForCustomFunction()
 {
     $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'custom_function'));
     $this->assertEquals(array('arg1'), $node->getArguments(array($this, 'customFunction'), array('arg1' => 'arg1')));
 }
Example #5
0
 /**
  * @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', 'timestamp' => null, 'unknown1' => '', 'unknown2' => ''));
 }
 public function testGetArgumentsForStaticMethod()
 {
     $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'custom_static_function'));
     $this->assertEquals(array('arg1'), $node->getArguments(__CLASS__ . '::customStaticFunction', array('arg1' => 'arg1')));
 }