Beispiel #1
0
 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());
 }
Beispiel #2
0
 /**
  * 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.');
 }
Beispiel #3
0
 /**
  * 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;
 }