コード例 #1
0
 /**
  * Testing folder creation and deletion, add document, get folder contents, folder detail
  * Folder shortcuts and actions
  */
 public function testFolderApiFunctions()
 {
     // 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);
     $this->assertTrue($result2['results']['parent_id'] == 1);
     // 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'];
     $this->assertEqual($doc['results']['title'], 'New API test doc');
     // Rename the folder
     // test without authentication - should fail
     $renamed = $this->ktapi->rename_folder($folder_id, 'Renamed test folder');
     $this->assertEqual($renamed['status_code'], 1);
     // test with authentication
     $renamed = $this->ktapi->rename_folder($folder_id, 'Renamed test folder', KT_TEST_USER, KT_TEST_PASS, 'Testing API');
     $this->assertEqual($renamed['status_code'], 0);
     /**
      * Copy and move appear to fail in other parts of the code, so only going to test failure here
      * 
      * Must be VERY careful here with skipping the valid submissions, 3 failed auth attempts in a row locks out the user!
      */
     // Copy folder
     // test without authentication - should fail
     $copied = $this->ktapi->copy_folder($source_id, $target_id, $reason);
     $this->assertEqual($copied['status_code'], 1);
     //        // test with authentication
     //        $copied = $this->ktapi->copy_folder($source_id, $target_id, $reason, KT_TEST_USER, KT_TEST_PASS);
     //        echo $copied['status_code']."sd<BR>";
     //        $this->assertEqual($copied['status_code'], 0);
     // Move folder
     // test without authentication - should fail
     $moved = $this->ktapi->move_folder($source_id, $target_id, $reason);
     $this->assertEqual($moved['status_code'], 1);
     // force reset of the lockout so that remaining tests can run :)
     unset($_SESSION['esignature_attempts']);
     unset($_SESSION['esignature_lock']);
     //        // test with authentication
     //        $moved = $this->ktapi->move_folder($source_id, $target_id, $reason, KT_TEST_USER, KT_TEST_PASS);
     //        $this->assertEqual($moved['status_code'], 0);
     // force reset of the lockout so that remaining tests can run :)
     unset($_SESSION['esignature_attempts']);
     unset($_SESSION['esignature_lock']);
     // Clean up - delete the folder
     // test without authentication - should fail
     $deleted = $this->ktapi->delete_folder($folder_id, 'Testing API');
     $this->assertEqual($deleted['status_code'], 1);
     // test with authentication
     $deleted = $this->ktapi->delete_folder($folder_id, 'Testing API', KT_TEST_USER, KT_TEST_PASS);
     $this->assertEqual($deleted['status_code'], 0);
 }
コード例 #2
0
ファイル: testAuto.php プロジェクト: 5haman/knowledgetree
 function tesRealcopy_folder()
 {
     $result = $this->ktapi->copy_folder($source_id, $target_id, $reason, KT_TEST_USER, KT_TEST_PASS);
     $this->assertIsA($result, 'array');
     $this->assertEqual($result['status_code'], 0);
 }