public function testLastNode() { $tree = new \Magento\Framework\Data\Tree(); $node1 = new \Magento\Framework\Data\Tree\Node(['id' => 'node1'], 'id', $tree); $this->collection->add($node1); $node2 = new \Magento\Framework\Data\Tree\Node(['id' => 'node2'], 'id', $tree); $this->collection->add($node2); $this->assertSame($this->collection->lastNode(), $node2); $node3 = new \Magento\Framework\Data\Tree\Node(['id' => 'node3'], 'id', $tree); $this->collection->add($node3); $this->assertSame($this->collection->lastNode(), $node3); $this->assertSame($this->collection->lastNode(), $node3); $this->collection->delete($node3); $this->assertSame($this->collection->lastNode(), $node2); $this->assertSame($this->collection->lastNode(), $node2); }
/** * Remove node * * @param Node $node * @return $this */ public function removeNode($node) { $this->_nodes->delete($node); if ($node->getParent()) { $node->getParent()->removeChild($node); } unset($node); return $this; }
/** * @param Node $childNode * @return $this */ public function removeChild($childNode) { $this->_childNodes->delete($childNode); return $this; }