4 * This file is part of Twig.
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 class Twig_Tests_Node_MacroTest
extends Twig_Test_NodeTestCase
15 * @covers Twig_Node_Macro::__construct
17 public function testConstructor()
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);
23 $this->assertEquals($body, $node->getNode('body'));
24 $this->assertEquals($arguments, $node->getNode('arguments'));
25 $this->assertEquals('foo', $node->getAttribute('name'));
29 * @covers Twig_Node_Macro::compile
30 * @dataProvider getTests
32 public function testCompile($node, $source, $environment = null)
34 parent
::testCompile($node, $source, $environment);
37 public function getTests()
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),
44 $node = new Twig_Node_Macro('foo', $body, $arguments, 1);
49 public function getfoo(\$_foo = null, \$_bar = "Foo")
51 \$context = \$this->env->mergeGlobals(array(
61 } catch (Exception \$e) {
67 return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());