static function () { return '1'; }], 1); $this->assertEquals(<< new TwigFunction('a_function'), 'filter' => new TwigFilter('a_filter'), 'test' => new TwigTest('a_test'), ], 1); $this->assertEquals(<<setNodeTag('tag'); $this->assertEquals(<<setDocumentation("First line\nSecond line"); $this->assertSame(<<<'EOF' Twig\Tests\Node\NodeForTest documentation: First line\nSecond line EOF, (string) $node); } public function testAttributeDeprecationIgnore(): void { $node = new NodeForTest([], ['foo' => false]); $node->deprecateAttribute('foo', new NameDeprecation('foo/bar', '2.0', 'bar')); $this->assertFalse($node->getAttribute('foo', false)); } #[IgnoreDeprecations] public function testAttributeDeprecationWithoutAlternative(): void { $node = new NodeForTest([], ['foo' => false]); $node->deprecateAttribute('foo', new NameDeprecation('foo/bar', '2.0')); $this->expectUserDeprecationMessage('Since foo/bar 2.0: Getting attribute "foo" on a "Twig\Tests\Node\NodeForTest" class is deprecated.'); $this->assertFalse($node->getAttribute('foo')); } #[IgnoreDeprecations] public function testAttributeDeprecationWithAlternative(): void { $node = new NodeForTest([], ['foo' => false]); $node->deprecateAttribute('foo', new NameDeprecation('foo/bar', '2.0', 'bar')); $this->expectUserDeprecationMessage('Since foo/bar 2.0: Getting attribute "foo" on a "Twig\Tests\Node\NodeForTest" class is deprecated, get the "bar" attribute instead.'); $this->assertFalse($node->getAttribute('foo')); } public function testNodeDeprecationIgnore(): void { $node = new NodeForTest(['foo' => $foo = new NodeForTest()]); $node->deprecateNode('foo', new NameDeprecation('foo/bar', '2.0')); $this->assertSame($foo, $node->getNode('foo', false)); } #[IgnoreDeprecations] public function testNodeDeprecationWithoutAlternative(): void { $node = new NodeForTest(['foo' => $foo = new NodeForTest()]); $node->deprecateNode('foo', new NameDeprecation('foo/bar', '2.0')); $this->expectUserDeprecationMessage('Since foo/bar 2.0: Getting node "foo" on a "Twig\Tests\Node\NodeForTest" class is deprecated.'); $this->assertSame($foo, $node->getNode('foo')); } #[IgnoreDeprecations] public function testNodeAttributeDeprecationWithAlternative(): void { $node = new NodeForTest(['foo' => $foo = new NodeForTest()]); $node->deprecateNode('foo', new NameDeprecation('foo/bar', '2.0', 'bar')); $this->expectUserDeprecationMessage('Since foo/bar 2.0: Getting node "foo" on a "Twig\Tests\Node\NodeForTest" class is deprecated, get the "bar" node instead.'); $this->assertSame($foo, $node->getNode('foo')); } } class NodeForTest extends Node { }