/** * Tests the move functionality. Includes the get_detail() functionality. */ function testMove() { // Create a new document $randomFile = APIDocumentHelper::createRandomFile(); $this->assertTrue(is_file($randomFile)); $document = $this->root->add_document('testtitle246', 'testname246.txt', 'Default', $randomFile); $this->assertNotError($document); @unlink($randomFile); if (PEAR::isError($document)) { return; } // Add a folder to copy into $newFolder = $this->root->add_folder("New folder"); $this->assertNotError($newFolder); if (PEAR::isError($newFolder)) { return; } // Copy document into the new folder $document->move($newFolder, 'Testing document move'); $detail = $document->get_detail(); $this->assertFalse($detail['folder_id'] == $this->root->get_folderid()); $this->assertTrue($detail['folder_id'] == $newFolder->get_folderid()); // Delete and expunge documents $document->delete('Testing document move'); $document->expunge(); // Delete test folder $newFolder->delete('Testing document move'); }
/** * Test the bulk move functionality */ function testMove() { // Create documents $doc1 = $this->createDocument('Test Doc One', 'testdoc1.txt'); $doc2 = $this->createDocument('Test Doc Two', 'testdoc2.txt'); $doc3 = $this->createDocument('Test Doc Three', 'testdoc3.txt'); $folder1 = $this->root->add_folder("New move folder"); $this->assertNotError($newFolder); if (PEAR::isError($newFolder)) { return; } $doc4 = $this->createDocument('Test Doc Four', 'testdoc4.txt', $folder1); // Add a folder $targetFolder = $this->root->add_folder("New target folder"); $this->assertNotError($newFolder); if (PEAR::isError($newFolder)) { return; } $aItems = array($doc1, $doc2, $doc3, $folder1); // Copy documents and folder into target folder $res = $this->bulk->move($aItems, $targetFolder, 'Testing bulk move'); $this->assertTrue(empty($res)); // Check document has been moved not copied $detail = $doc1->get_detail(); $this->assertFalse($detail['folder_id'] == $this->root->get_folderid()); $this->assertTrue($detail['folder_id'] == $targetFolder->get_folderid()); // Check folder has been moved not copied $this->assertFalse($folder1->get_parent_folder_id() == $this->root->get_folderid()); $this->assertTrue($folder1->get_parent_folder_id() == $targetFolder->get_folderid()); // Check the documents copied $listDocs = $targetFolder->get_listing(1, 'D'); $this->assertTrue(count($listDocs) == 3); // Check the folder copied $listFolders = $targetFolder->get_listing(1, 'F'); $this->assertTrue(count($listFolders) == 1); // Check the document contained in the folder copied $newFolderId = $listFolders[0]['id']; $newFolder = $this->ktapi->get_folder_by_id($newFolderId); $listSubDocs = $newFolder->get_listing(1, 'D'); $this->assertTrue(count($listSubDocs) == 1); // Delete and expunge documents and folder $this->deleteDocument($doc1); $this->deleteDocument($doc2); $this->deleteDocument($doc3); $this->deleteDocument($doc4); $targetFolder->delete('Testing bulk copy'); $folder1->delete('Testing bulk copy'); }