8 use \Magento\Framework\Data\Tree\Node;
9 use \Magento\Framework\Data\Tree;
15 class TreeTest extends \PHPUnit\Framework\TestCase
24 $this->_tree =
new Tree();
29 $newNode1 =
new Node(
'abc',
'node1', $this->_tree);
30 $this->_tree->addNode($newNode1);
31 $newNode2 =
new Node(
'def',
'node2', $this->_tree);
32 $this->_tree->addNode($newNode2, $newNode1);
33 $newNode3 =
new Node(
'ghi',
'node3', $this->_tree);
34 $this->_tree->addNode($newNode3, $newNode1);
35 $data1 = [
'j',
'k',
'l'];
36 $this->_tree->appendChild($data1, $newNode3);
37 $newNode4 =
new Node(
'mno',
'node4', $this->_tree);
38 $this->_tree->appendChild($newNode4, $newNode3);
40 $this->_tree->removeNode($newNode4);
41 $this->_tree->removeNode($newNode3);
42 $this->_tree->removeNode($newNode2);
43 $this->_tree->removeNode($newNode1);
45 $this->assertEmpty($this->_tree->getNodes()->getNodes());