/** * Adds a property to the node * * @param NodeProperty $property * @return bool */ public function addProperty(NodeProperty $property) { foreach ($this->properties as $prop) { if ($prop->getName() === $property->getName()) { $this->properties->removeElement($prop); } } return $this->properties->add($property); }
function it_should_tell_whether_or_not_the_node_has_a_specified_property(NodeProperty $property) { $property->getName()->willReturn('first_name'); $this->addProperty($property); $this->hasProperty('first_name')->shouldReturn(true); $this->hasProperty('last_name')->shouldReturn(false); }