示例#1
0
 public function testNodeListToTree()
 {
     $nodes = array();
     $tree = Trees::nodeListToTree($nodes);
     $this->assertNull($tree);
     $nodes = array(0 => array(0));
     $tree = Trees::nodeListToTree($nodes);
     $this->assertNull($tree);
     $nodes = array(0 => array(1));
     $tree = Trees::nodeListToTree($nodes);
     $this->assertEqual(array(0 => array(1 => null)), $tree);
     //     0
     //    / \
     //   1   2
     //  /   / \
     // 3   4   5
     $nodes = array(0 => array(1, 2), 1 => array(3), 2 => array(4, 5));
     $tree = Trees::nodeListToTree($nodes);
     $this->assertEqual(array(0 => array(1 => array(3 => null), 2 => array(4 => null, 5 => null))), $tree);
 }
 /**
  * Converts an array of items as returned by the SOAP function getDocmanTreeInfo to a tree of IDs
  */
 private function buildDistantTreeFromSoapArray()
 {
     $listOfNodes = array();
     foreach ($this->remoteItems as $id => $itemInfo) {
         $listOfNodes[$itemInfo->parent_id][] = $id;
     }
     // Tree of ids
     $tree = Trees::nodeListToTree($listOfNodes);
     return $tree;
 }