PhpParser\NodeAbstractTest::testAttributes PHP Method

testAttributes() public method

public testAttributes ( )
    public function testAttributes()
    {
        /** @var $node Node */
        $node = $this->getMockForAbstractClass('PhpParser\\NodeAbstract');
        $this->assertEmpty($node->getAttributes());
        $node->setAttribute('key', 'value');
        $this->assertTrue($node->hasAttribute('key'));
        $this->assertSame('value', $node->getAttribute('key'));
        $this->assertFalse($node->hasAttribute('doesNotExist'));
        $this->assertNull($node->getAttribute('doesNotExist'));
        $this->assertSame('default', $node->getAttribute('doesNotExist', 'default'));
        $node->setAttribute('null', null);
        $this->assertTrue($node->hasAttribute('null'));
        $this->assertNull($node->getAttribute('null'));
        $this->assertNull($node->getAttribute('null', 'default'));
        $this->assertSame(array('key' => 'value', 'null' => null), $node->getAttributes());
    }