Beispiel #1
0
 /**
  * Testing document get, update, actions, delete, shortcuts and detail
  */
 public function testDocumentApiFunctions()
 {
     // Create a folder
     $result1 = $this->ktapi->create_folder(1, 'New test api folder', KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     $folder_id = $result1['results']['id'];
     $this->assertEqual($result1['status_code'], 0);
     // Create a sub folder
     $result2 = $this->ktapi->create_folder($folder_id, 'New test api sub-folder', KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     $folder_id2 = $result2['results']['id'];
     $this->assertEqual($result2['status_code'], 0);
     // Add a document
     global $default;
     $dir = $default->uploadDirectory;
     $tempfilename = $this->createRandomFile('some text', $dir);
     $doc = $this->ktapi->add_document($folder_id, 'New API test doc', 'testdoc1.txt', 'Default', $tempfilename, KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     $doc_id = $doc['results']['document_id'];
     $this->assertEqual($doc['status_code'], 0);
     // Get document detail
     $detail = $this->ktapi->get_document_detail($doc_id);
     //, 'MLTVH');
     $this->assertEqual($detail['status_code'], 0);
     $this->assertEqual($detail['results']['document_type'], 'Default');
     $this->assertEqual($detail['results']['folder_id'], $folder_id);
     // Get document detail - filename
     $detail2 = $this->ktapi->get_document_detail_by_filename($folder_id, 'testdoc1.txt');
     $this->assertEqual($detail2['status_code'], 0);
     $this->assertEqual($detail2['results']['title'], 'New API test doc');
     // Get document detail - title
     $detail3 = $this->ktapi->get_document_detail_by_title($folder_id, 'New API test doc');
     $this->assertEqual($detail3['status_code'], 0);
     $this->assertEqual($detail3['results']['filename'], 'testdoc1.txt');
     // Get document detail - name
     $detail4 = $this->ktapi->get_document_detail_by_name($folder_id, 'New API test doc');
     $this->assertEqual($detail4['status_code'], 0);
     $this->assertEqual($detail4['results']['title'], 'New API test doc');
     // Checkout the document
     $result1 = $this->ktapi->checkout_document($doc_id, 'Testing API', true, KT_TEST_USER, KT_TEST_PASS);
     $this->assertEqual($result1['status_code'], 0);
     $this->assertTrue(!empty($result1['results']));
     // Checkin the document
     $dir = $default->uploadDirectory;
     $tempfilename = $this->createRandomFile('some text', $dir);
     $result2 = $this->ktapi->checkin_document($doc_id, 'testdoc1.txt', 'Testing API', $tempfilename, false, KT_TEST_USER, KT_TEST_PASS);
     $this->assertEqual($result2['status_code'], 0);
     $this->assertEqual($result2['results']['document_id'], $doc_id);
     // Create document shortcut
     $shortcut = $this->ktapi->create_document_shortcut(1, $doc_id, KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     $this->assertEqual($shortcut['status_code'], 0);
     $this->assertEqual($shortcut['results']['title'], 'New API test doc');
     $this->assertEqual($shortcut['results']['folder_id'], $folder_id);
     // Delete the document
     $result3 = $this->ktapi->delete_document($doc_id, 'Testing API', true, KT_TEST_USER, KT_TEST_PASS);
     $this->assertEqual($result3['status_code'], 0);
     // Clean up - delete the folder
     $this->ktapi->delete_folder($folder_id, 'Testing API', KT_TEST_USER, KT_TEST_PASS);
     $detail2 = $this->ktapi->get_folder_detail($folder_id);
     $this->assertNotEqual($detail2['status_code'], 0);
 }
 /**
  * This method tests the processing of the saved search
  *
  */
 public function testRunSavedSearch_KTAPI()
 {
     // create the document object
     $randomFile = $this->createRandomFile();
     $document = $this->root->add_document('title.txt', 'name_1.txt', 'Default', $randomFile);
     @unlink($randomFile);
     $searchID = $this->savedSearch->create('test_search', '(GeneralText contains "title")');
     $response = $this->ktapi->run_saved_search($searchID);
     $this->assertIsA($response, 'array');
     $this->assertEqual($response['status_code'], 0);
     $this->assertNoErrors();
     $document->delete('Testing');
     $document->expunge();
     $this->savedSearch->delete($searchID);
 }
Beispiel #3
0
 function createFolderDocStructure()
 {
     // Create a folder
     $result1 = $this->ktapi->create_folder(1, 'New test api folder', KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     $folder_id = $result1['results']['id'];
     $this->folders[] = $folder_id;
     // Create a sub folder
     $result2 = $this->ktapi->create_folder($folder_id, 'New test api sub-folder', KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     $folder_id2 = $result2['results']['id'];
     $this->subfolders[] = $folder_id2;
     // Add a document to the subfolder
     global $default;
     $dir = $default->uploadDirectory;
     $tempfilename = $this->createRandomFile('some text', $dir);
     $document1 = $this->ktapi->add_document($folder_id2, 'New API test subdoc', 'testsubdoc1.txt', 'Default', $tempfilename, KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     @unlink($tempfilename);
     // Create a second set of folders
     $result1 = $this->ktapi->create_folder(1, 'New test api folder the second', KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     $folder_id = $result1['results']['id'];
     $this->folders[] = $folder_id;
     // Add a single document to the root folder of the second set
     $tempfilename = $this->createRandomFile('some text', $dir);
     $document2 = $this->ktapi->add_document($folder_id, 'New API test subdoc', 'testsubdoc3.txt', 'Default', $tempfilename, KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     @unlink($tempfilename);
     // Create a sub folder
     $result2 = $this->ktapi->create_folder($folder_id, 'New test api sub-folder for the second', KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     $folder_id2 = $result2['results']['id'];
     $this->subfolders[] = $folder_id2;
     // Add a couple of documents to the second subfolder
     $tempfilename = $this->createRandomFile('some text', $dir);
     $document3 = $this->ktapi->add_document($folder_id2, 'New API test subdoc', 'testsubdoc2.txt', 'Default', $tempfilename, KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     @unlink($randomFile);
     $randomFile = $this->createRandomFile();
     $document4 = $this->ktapi->add_document($folder_id2, 'New API test subdoc', 'testsubdoc4.txt', 'Default', $tempfilename, KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     @unlink($tempfilename);
     // add root level docs
     $tempfilename = $this->createRandomFile('some text', $dir);
     $document5 = $this->root->add_document('title_1.txt', 'name_1.txt', 'Default', $randomFile, KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     @unlink($tempfilename);
     $this->docs[] =& $document5;
     // create the document object
     $randomFile = $this->createRandomFile();
     $document6 = $this->root->add_document('title_2.txt', 'name_2.txt', 'Default', $randomFile, KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     @unlink($randomFile);
     $this->docs[] =& $document6;
 }
 /**
  * Testing document get, update, actions, delete, shortcuts and detail
  */
 public function testDocumentApiFunctions()
 {
     // if not enabled, do not run remaining tests
     if (!$this->esig_enabled) {
         return null;
     }
     // Create a folder
     // test without authentication - should fail
     $result1 = $this->ktapi->create_folder(1, 'New test api folder');
     $this->assertEqual($result1['status_code'], 1);
     // test with authentication
     $result2 = $this->ktapi->create_folder(1, 'New test api folder', KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     $folder_id = $result2['results']['id'];
     $this->assertEqual($result2['status_code'], 0);
     // Create a sub folder
     // test without authentication - should fail
     $result3 = $this->ktapi->create_folder($folder_id, 'New test api sub-folder');
     $this->assertEqual($result3['status_code'], 1);
     // test with authentication
     $result4 = $this->ktapi->create_folder($folder_id, 'New test api sub-folder', KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     $folder_id2 = $result4['results']['id'];
     $this->assertEqual($result4['status_code'], 0);
     // Add a document
     global $default;
     $dir = $default->uploadDirectory;
     $tempfilename = $this->createRandomFile('some text', $dir);
     // test without authentication - should fail
     $doc = $this->ktapi->add_document($folder_id, 'New API test doc', 'testdoc1.txt', 'Default', $tempfilename);
     $this->assertEqual($doc['status_code'], 1);
     // test with authentication
     $doc = $this->ktapi->add_document($folder_id, 'New API test doc', 'testdoc1.txt', 'Default', $tempfilename, KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     $this->assertEqual($doc['status_code'], 0);
     $doc_id = $doc['results']['document_id'];
     // Checkout the document
     // test without authentication - should fail
     $result1 = $this->ktapi->checkout_document($doc_id, 'Testing API', true);
     $this->assertEqual($result1['status_code'], 1);
     // test with authentication
     $result2 = $this->ktapi->checkout_document($doc_id, 'Testing API', true, KT_TEST_USER, KT_TEST_PASS);
     $this->assertEqual($doc['status_code'], 0);
     $this->assertTrue(!empty($result2['results']));
     // Checkin the document
     $dir = $default->uploadDirectory;
     $tempfilename = $this->createRandomFile('some text', $dir);
     // test without authentication - should fail
     $result3 = $this->ktapi->checkin_document($doc_id, 'testdoc1.txt', 'Testing API', $tempfilename, false);
     $this->assertEqual($result3['status_code'], 1);
     // test with authentication
     $result4 = $this->ktapi->checkin_document($doc_id, 'testdoc1.txt', 'Testing API', $tempfilename, false, KT_TEST_USER, KT_TEST_PASS);
     $this->assertEqual($result4['status_code'], 0);
     $this->assertEqual($result4['results']['document_id'], $doc_id);
     // Delete the document
     // test without authentication - should fail
     $result5 = $this->ktapi->delete_document($doc_id, 'Testing API');
     $this->assertEqual($result5['status_code'], 1);
     // test with authentication
     $result6 = $this->ktapi->delete_document($doc_id, 'Testing API', true, KT_TEST_USER, KT_TEST_PASS);
     $this->assertEqual($result6['status_code'], 0);
     // Clean up - delete the folder
     // test without authentication - should fail
     $result7 = $this->ktapi->delete_folder($folder_id, 'Testing API');
     $this->assertEqual($result7['status_code'], 1);
     $result8 = $this->ktapi->delete_folder($folder_id, 'Testing API', KT_TEST_USER, KT_TEST_PASS);
     $this->assertEqual($result8['status_code'], 0);
 }
Beispiel #5
0
 function tesRealadd_document()
 {
     $result = $this->ktapi->add_document($folder_id, $title, $filename, $documenttype, $tempfilename, KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     $this->assertIsA($result, 'array');
     $this->assertEqual($result['status_code'], 0);
 }