Make Node::__toString() more readable

This commit is contained in:
Fabien Potencier
2024-08-15 20:14:56 +02:00
parent 72d6d9c9c5
commit b431ecad3a
4 changed files with 29 additions and 2 deletions
+14
View File
@@ -15,6 +15,9 @@ use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Twig\Node\NameDeprecation;
use Twig\Node\Node;
use Twig\TwigFilter;
use Twig\TwigFunction;
use Twig\TwigTest;
class NodeTest extends TestCase
{
@@ -28,6 +31,17 @@ class NodeTest extends TestCase
$this->assertEquals('Twig\Node\Node(value: \Closure)', (string) $node);
}
public function testToStringWithTwigCallables()
{
$node = new Node([], [
'function' => new TwigFunction('a_function'),
'filter' => new TwigFilter('a_filter'),
'test' => new TwigTest('a_test'),
], 1);
$this->assertEquals('Twig\Node\Node(function: Twig\TwigFunction(a_function), filter: Twig\TwigFilter(a_filter), test: Twig\TwigTest(a_test))', (string) $node);
}
public function testAttributeDeprecationIgnore()
{
$node = new Node([], ['foo' => false]);