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(<< false]); $node->deprecateAttribute('foo', new NameDeprecation('foo/bar', '2.0', 'bar')); $this->assertFalse($node->getAttribute('foo', false)); } /** * @group legacy */ public function testAttributeDeprecationWithoutAlternative() { $node = new NodeForTest([], ['foo' => false]); $node->deprecateAttribute('foo', new NameDeprecation('foo/bar', '2.0')); $this->expectDeprecation('Since foo/bar 2.0: Getting attribute "foo" on a "Twig\Tests\Node\NodeForTest" class is deprecated.'); $this->assertFalse($node->getAttribute('foo')); } /** * @group legacy */ public function testAttributeDeprecationWithAlternative() { $node = new NodeForTest([], ['foo' => false]); $node->deprecateAttribute('foo', new NameDeprecation('foo/bar', '2.0', 'bar')); $this->expectDeprecation('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() { $node = new NodeForTest(['foo' => $foo = new NodeForTest()]); $node->deprecateNode('foo', new NameDeprecation('foo/bar', '2.0')); $this->assertSame($foo, $node->getNode('foo', false)); } /** * @group legacy */ public function testNodeDeprecationWithoutAlternative() { $node = new NodeForTest(['foo' => $foo = new NodeForTest()]); $node->deprecateNode('foo', new NameDeprecation('foo/bar', '2.0')); $this->expectDeprecation('Since foo/bar 2.0: Getting node "foo" on a "Twig\Tests\Node\NodeForTest" class is deprecated.'); $this->assertSame($foo, $node->getNode('foo')); } /** * @group legacy */ public function testNodeAttributeDeprecationWithAlternative() { $node = new NodeForTest(['foo' => $foo = new NodeForTest()]); $node->deprecateNode('foo', new NameDeprecation('foo/bar', '2.0', 'bar')); $this->expectDeprecation('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 { }