/**
  * builds a tree from a nested array.
  *
  * @param string $arr 
  * @param string $orgId 
  * @return void
  * @author Brent Shaffer
  */
 public function restoreTreeFromNestedArray($arr, ioDoctrineMenuItem $root)
 {
     if (!$root->getNode()->isRoot()) {
         throw new sfException('ioDoctrineMenuItemTable::restoreTreeFromNestedArray() must be called using a root node.');
     }
     // put the nodes back on
     $this->restoreBranchFromNestedArray(array('menu' => $root, 'children' => $arr));
 }
function root_sanity_check(lime_test $t, ioDoctrineMenuItem $rt)
{
    $t->info('    Testing for correct lft, rgt values');
    $nodeTotal = Doctrine_Query::create()->from('ioDoctrineMenuItem m')->count();
    $t->is($rt->lft, 1, 'rt.lft = 1');
    $rgt = $nodeTotal * 2;
    $t->is($rt->rgt, $rgt, 'rt.rgt = ' . $rgt);
    $children = $rt->getNode()->getChildren();
    $childRgt = 1;
    // fake the previous sibling
    foreach ($children as $child) {
        $child->refresh();
        // just to be sure
        $t->is($child->lft, $childRgt + 1, 'The child node lft value is rgt+1 of its previous sibling');
        $childRgt = $child->rgt;
    }
    $t->is($child->rgt, $rgt - 1, 'The final child.rgt value is one less than the parent.rgt value.');
}