/** * Builds the node tree from the given structure. * * @param array $treeStructure * the tree structure as array, may be empty * @param tx_oelib_Visibility_Node $parentNode * the parent node for the current key * * @return void */ private function buildTreeFromArray(array $treeStructure, tx_oelib_Visibility_Node $parentNode) { foreach ($treeStructure as $nodeKey => $nodeContents) { /** @var tx_oelib_Visibility_Node $childNode */ $childNode = t3lib_div::makeInstance('tx_oelib_Visibility_Node'); $parentNode->addChild($childNode); if (is_array($nodeContents)) { $this->buildTreeFromArray($nodeContents, $childNode); } elseif ($nodeContents === TRUE) { $childNode->markAsVisible(); } $this->nodes[$nodeKey] = $childNode; } }
/** * @test */ public function addChildAddsParentToChild() { $childNode = new tx_oelib_Visibility_Node(); $this->subject->addChild($childNode); self::assertSame($this->subject, $childNode->getParent()); }