/** * 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 archive functionality */ function testArchive() { // 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 test folder"); $this->assertNotError($newFolder); if (PEAR::isError($newFolder)) { return; } $doc4 = $this->createDocument('Test Doc Four', 'testdoc4.txt', $folder1); $aItems = array($doc1, $doc2, $doc3, $folder1); // Archive documents and folder $res = $this->bulk->archive($aItems, 'Testing bulk archive'); $this->assertTrue(empty($res)); $document1 = $doc1->getObject(); $this->assertTrue($document1->getStatusID() == 4); // refresh the doc4 document object to reflect changes $doc4 = KTAPI_Document::get($this->ktapi, $doc4->get_documentid()); $document4 = $doc4->getObject(); $this->assertTrue($document4->getStatusID() == 4); // Restore for deletion $doc1->restore(); $doc2->restore(); $doc3->restore(); $doc4->restore(); // Delete and expunge documents and folder $this->deleteDocument($doc1); $this->deleteDocument($doc2); $this->deleteDocument($doc3); $this->deleteDocument($doc4); $folder1->delete('Testing bulk archive'); }