Add Node::setAttributes() (#385)

This commit is contained in:
Wes 2017-05-05 18:18:44 +02:00 committed by Nikita Popov
parent 92275bdfa8
commit b1af3d1f7d
2 changed files with 23 additions and 2 deletions

View File

@ -71,9 +71,16 @@ interface Node
public function &getAttribute(string $key, $default = null);
/**
* Returns all attributes for the given node.
* Returns all the attributes of this node.
*
* @return array
*/
public function getAttributes() : array;
}
/**
* Replaces all the attributes of this node.
*
* @param array $attributes
*/
public function setAttributes(array $attributes);
}

View File

@ -163,6 +163,20 @@ class NodeAbstractTest extends TestCase
),
$node->getAttributes()
);
$node->setAttributes(
array(
'a' => 'b',
'c' => null,
)
);
$this->assertSame(
array(
'a' => 'b',
'c' => null,
),
$node->getAttributes()
);
}
public function testJsonSerialization() {