public function addLeaf($branch, array $leaf, $pos = null, $prepend = false) { $this->tree = $this->traverseTree($this->tree, $branch, $leaf, $pos, $prepend); $this->parentLevel = 1; $this->childLevel = 1; return $this; }
public function testAddLeaf() { $_SERVER['REQUEST_URI'] = '/first'; $tree = array(array('name' => 'First Nav Item', 'href' => '/first'), array('name' => 'Second Nav Item', 'href' => '/second')); $n = new Nav($tree); $n->addLeaf('Second Nav Item', array('name' => 'A Brand New Child', 'href' => 'a-brand-new-child')); $navString = <<<NAV <a href="/second">Second Nav Item</a> <ul> <li> <a href="/second/a-brand-new-child">A Brand New Child</a> </li> </ul> NAV; $this->assertContains($navString, (string) $n); }