public function testCanRemoveChild() { $node = new Node(Tree::ROOT_NODE_ID); $child = new Node('node', $node); $node->addChild($child); $node->removeChild($child); $this->assertTrue(0 === $node->getChildren()->count()); }
/** * Will throw an exception if the node is a root node * * @param Node $node * * @throws Exception\OperationNotAllowedException */ private function assertIsNotRoot(Node $node) { if (!$node->isRoot()) { return; } throw new OperationNotAllowedException('Could not perform operation on root node.'); }
/** * This class does not use the $index part of this method * * {@inheritdoc} */ public function add(Node $node, $index = null) { $this->nodes[$node->getId()] = $node; return $this; }