/** * Get descendents of the specified folder, up to the depth indicated * * @param string $repositoryId * @param string $folderId * @param boolean $includeAllowableActions * @param boolean $includeRelationships * @param string $typeID * @param int $depth * @param string $filter * @return cmisObjectType[] */ public function getDescendants($repositoryId, $folderId, $includeAllowableActions, $includeRelationships, $depth = 1, $typeID = 'Any', $filter = '') { $result = parent::getDescendants($repositoryId, $folderId, $includeAllowableActions, $includeRelationships, $depth, $typeID, $filter); if ($result['status_code'] == 0) { return $result['results']; } }
function testNavigationService() { $NavigationService = new KTNavigationService($this->ktapi); // set up the folder/doc tree structure with which we will be testing $this->createFolderDocStructure(); $RepositoryService = new KTRepositoryService(); $response = $RepositoryService->getRepositories(); $this->assertEqual($response['status_code'], 0); $this->assertNotNull($response['results'][0]); // we only expect one repository $repository = $response['results'][0]; $repositoryId = $repository['repositoryId']; // TEST 1 // test getting descendants // test descendant functionality on first of created folders, should have depth 2; $folderid = 'F' . $this->folders[1]; // echo "FOLDER: $folderid<BR>"; // $folderid = 'F1'; $depth = 2; $result = $NavigationService->getDescendants($repositoryId, $folderid, false, false, $depth); // echo '<pre>'.print_r($result, true).'</pre>'; // var_dump($result); $this->assertEqual($response['status_code'], 0); $this->assertNotNull($response['results'][0]); $descendants = $result['results']; $this->assertNotNull($descendants); // check depth $dug = $this->array_depth($descendants); // echo "DUG TO $dug (aiming for $depth)<BR>"; // $this->assertEqual($depth, $dug); // test printout $this->printTree($descendants, 'Descendants for Folder ' . $folderid . ' (getDescendants())', $dug); /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ // TEST 2 // test getting direct children, using the second set of folders, should have a folder and a document as children $folderid_2 = 'F' . $this->folders[0]; $result = $NavigationService->getChildren($repositoryId, $folderid_2, false, false); $this->assertNotNull($result['results']); $children = $result['results']; // total child count should be 2, as there is a single folder and a single document //echo '<pre>'.print_r($children, true).'</pre>'; // test printout $this->printTree($children, 'Children for Folder ' . $folderid_2 . ' (getChildren())'); /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ // TEST 3 // test getting folder parent, using first created folder, parent should be root folder // echo "OUTPUT FROM FIRST TEST<BR>"; $ancestry = $NavigationService->getFolderParent($repositoryId, $folderid, false, false, false); $this->assertNotNull($ancestry['results']); // echo "OUTPUT FROM FIRST TEST<BR>"; // echo '<pre>'.print_r($ancestry, true).'</pre>'; // test printout $this->printTree($ancestry['results'], 'Parent for Folder ' . $folderid . ' (getFolderParent())'); // test with one of the subfolders... $subfolder_id = 'F' . $this->subfolders[0]; // echo "OUTPUT FROM SECOND TEST<BR>"; // TODO since here we are testing more than one level up, add check for depth as with testGetDescendants $ancestry = $NavigationService->getFolderParent($repositoryId, $subfolder_id, false, false, true); $this->assertNotNull($ancestry['results']); // echo "OUTPUT FROM SECOND TEST<BR>"; // echo '<pre>'.print_r($ancestry, true).'</pre>'; // NOTE can only send depth here because we know it :) // test printout $this->printTree($ancestry['results'], 'Parent hierarchy (Return To Root) for Folder ' . $subfolder_id . ' (getFolderParent())', 2); /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ // TEST 4 // test getting object parent(s) with a document $objectId = 'D' . $this->docs[0]->get_documentid(); $ancestry = $NavigationService->getObjectParents($repositoryId, $objectId, false, false); $this->assertNotNull($ancestry); // echo '<pre>'.print_r($ancestry, true).'</pre>'; // test printout $this->printTree($ancestry['results'], 'Parent for (Document) Object ' . $objectId . ' (getObjectParents())'); // TEST // test getting object parent(s) with a folder $objectId = 'F' . $this->subfolders[0]; $ancestry = $NavigationService->getObjectParents($repositoryId, $objectId, false, false); $this->assertNotNull($ancestry); // echo '<pre>'.print_r($ancestry, true).'</pre>'; // test printout $this->printTree($ancestry['results'], 'Parent for (Folder) Object ' . $objectId . ' (getObjectParents())'); // TODO test checked out documents listing (not yet implemented) // tear down the folder/doc tree structure with which we were testing $this->cleanupFolderDocStructure(); // test printout if (DEBUG_CMIS) { echo '<div> </div>'; } }