Files
Fabien Potencier 986a765019 Merge branch '3.x' into 4.x
* 3.x:
  Redesign macro calls and argument handling

# Conflicts:
#	CHANGELOG
#	doc/deprecated.rst
#	src/ExpressionParser/Infix/ArgumentsTrait.php
#	src/ExpressionParser/Infix/DotExpressionParser.php
#	src/ExpressionParser/Infix/FunctionExpressionParser.php
#	src/Extension/CoreExtension.php
#	src/Node/Expression/MacroReferenceExpression.php
#	src/Node/Expression/MethodCallExpression.php
#	src/Node/Expression/TempNameExpression.php
#	src/Node/MacroNode.php
#	src/Node/ModuleNode.php
#	src/Template.php
#	tests/Fixtures/macros/call_without_parentheses.legacy.test
#	tests/Node/Expression/MacroReferenceTest.php
#	tests/Node/MacroTest.php
2026-07-30 14:02:30 +02:00

56 lines
1.5 KiB
PHP

<?php
/*
* This file is part of Twig.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Twig\Tests\Node;
/*
* This file is part of Twig.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Twig\Node\Expression\ConstantExpression;
use Twig\Node\Expression\Variable\AssignMacroVariable;
use Twig\Node\Expression\Variable\MacroVariable;
use Twig\Node\ImportNode;
use Twig\Test\NodeTestCase;
class ImportTest extends NodeTestCase
{
public function testConstructor(): void
{
$macro = new ConstantExpression('foo.twig', 1);
$node = new ImportNode($macro, new AssignMacroVariable(new MacroVariable('macro', 1), true), 1);
$this->assertEquals($macro, $node->getNode('expr'));
$this->assertEquals('macro', $node->getNode('var')->getNode('var')->getAttribute('name'));
}
public static function provideTests(): iterable
{
$tests = [];
$macro = new ConstantExpression('foo.twig', 1);
$node = new ImportNode($macro, new AssignMacroVariable(new MacroVariable('macro', 1), true), 1);
$tests[] = [$node, <<<EOF
// line 1
\$macros["macro"] = \$this->macros["macro"] = \$this->load("foo.twig", 1)->unwrap()->getMacroNamespace();
EOF
];
return $tests;
}
}