diff --git a/tests/api/testAuto.php b/tests/api/testAuto.php new file mode 100644 index 0000000..1015d23 --- /dev/null +++ b/tests/api/testAuto.php @@ -0,0 +1,427 @@ +ktapi = new KTAPI(); + $this->session = $this->ktapi->start_session('admin', 'admin'); + $this->root = $this->ktapi->get_root_folder(); + $this->assertTrue($this->root instanceof KTAPI_Folder); + } + + /** + * This method emds the KT session + * + */ + public function tearDown() { + $this->session->logout(); + } + + + + function testJunkanonymous_login() { + $result = $this->ktapi->anonymous_login(null); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 1); + } + + function tesRealanonymous_login() { + $result = $this->ktapi->anonymous_login($ip); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + function testJunklogin() { + $result = $this->ktapi->login(null, null, null); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 1); + } + + function tesReallogin() { + $result = $this->ktapi->login($username, $password, $ip); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function testJunkget_folder_detail_by_name() { + $result = $this->ktapi->get_folder_detail_by_name(null); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 1); + } + + function tesRealget_folder_detail_by_name() { + $result = $this->ktapi->get_folder_detail_by_name($folder_name); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + + + function tesRealcreate_document_shortcut() { + $result = $this->ktapi->create_document_shortcut($target_folder_id, $source_document_id); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + + function tesRealdelete_folder() { + $result = $this->ktapi->delete_folder($folder_id, $reason); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + + function tesRealrename_folder() { + $result = $this->ktapi->rename_folder($folder_id, $newname); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealcopy_folder() { + $result = $this->ktapi->copy_folder($source_id, $target_id, $reason); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealmove_folder() { + $result = $this->ktapi->move_folder($source_id, $target_id, $reason); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + function testJunkget_document_types() { + $result = $this->ktapi->get_document_types(null); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + function tesRealget_document_types() { + $result = $this->ktapi->get_document_types($session_id); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + function testJunkget_document_detail_by_filename() { + $result = $this->ktapi->get_document_detail_by_filename(null, null, null); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 1); + } + + function tesRealget_document_detail_by_filename() { + $result = $this->ktapi->get_document_detail_by_filename($folder_id, $filename, $detail); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + function testJunkget_document_detail_by_title() { + $result = $this->ktapi->get_document_detail_by_title(null, null, null); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 1); + } + + function tesRealget_document_detail_by_title() { + $result = $this->ktapi->get_document_detail_by_title($folder_id, $title, $detail); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + function testJunkget_document_detail_by_name() { + $result = $this->ktapi->get_document_detail_by_name(null, null, null, null); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 1); + } + + function tesRealget_document_detail_by_name() { + $result = $this->ktapi->get_document_detail_by_name($folder_id, $document_name, $what, $detail); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealget_document_shortcuts() { + $result = $this->ktapi->get_document_shortcuts($document_id); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + function testJunkadd_document() { + $result = $this->ktapi->add_document(null, null, null, null, null); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 1); + } + + function tesRealadd_document() { + $result = $this->ktapi->add_document($folder_id, $title, $filename, $documenttype, $tempfilename); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + + function tesRealadd_small_document_with_metadata() { + $result = $this->ktapi->add_small_document_with_metadata($folder_id, $title, $filename, $documenttype, $base64, $metadata, $sysdata); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + function testJunkadd_document_with_metadata() { + $result = $this->ktapi->add_document_with_metadata(null, null, null, null, null, null, null); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 1); + } + + function tesRealadd_document_with_metadata() { + $result = $this->ktapi->add_document_with_metadata($folder_id, $title, $filename, $documenttype, $tempfilename, $metadata, $sysdata); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + function tesRealadd_small_document() { + $result = $this->ktapi->add_small_document($folder_id, $title, $filename, $documenttype, $base64); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + function testJunkcheckin_document() { + $result = $this->ktapi->checkin_document(null, null, null, null, null); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 1); + } + + function tesRealcheckin_document() { + $result = $this->ktapi->checkin_document($document_id, $filename, $reason, $tempfilename, $major_update); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealcheckin_small_document_with_metadata() { + $result = $this->ktapi->checkin_small_document_with_metadata($document_id, $filename, $reason, $base64, $major_update, $metadata, $sysdata); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + function tesRealcheckin_document_with_metadata() { + $result = $this->ktapi->checkin_document_with_metadata($document_id, $filename, $reason, $tempfilename, $major_update, $metadata, $sysdata); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + + function tesRealcheckin_small_document() { + $result = $this->ktapi->checkin_small_document($document_id, $filename, $reason, $base64, $major_update); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + + function tesRealcheckout_document() { + $result = $this->ktapi->checkout_document($document_id, $reason, $download); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + + function tesRealcheckout_small_document() { + $result = $this->ktapi->checkout_small_document($document_id, $reason, $download); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealundo_document_checkout() { + $result = $this->ktapi->undo_document_checkout($document_id, $reason); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + + function tesRealdownload_document() { + $result = $this->ktapi->download_document($document_id, $version); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + + function tesRealdownload_small_document() { + $result = $this->ktapi->download_small_document($document_id, $version); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealdelete_document() { + $result = $this->ktapi->delete_document($document_id, $reason); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + + function tesRealchange_document_type() { + $result = $this->ktapi->change_document_type($document_id, $documenttype); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + function tesRealmove_document() { + $result = $this->ktapi->move_document($document_id, $folder_id, $reason, $newtitle, $newfilename); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + + function tesRealrename_document_title() { + $result = $this->ktapi->rename_document_title($document_id, $newtitle); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + + function tesRealrename_document_filename() { + $result = $this->ktapi->rename_document_filename($document_id, $newfilename); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealchange_document_owner() { + $result = $this->ktapi->change_document_owner($document_id, $username, $reason); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealstart_document_workflow() { + $result = $this->ktapi->start_document_workflow($document_id, $workflow); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealdelete_document_workflow() { + $result = $this->ktapi->delete_document_workflow($document_id); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealperform_document_workflow_transition() { + $result = $this->ktapi->perform_document_workflow_transition($document_id, $transition, $reason); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealget_document_metadata() { + $result = $this->ktapi->get_document_metadata($document_id); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealupdate_document_metadata() { + $result = $this->ktapi->update_document_metadata($document_id, $metadata, $sysdata); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealget_document_workflow_state() { + $result = $this->ktapi->get_document_workflow_state($document_id); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealget_document_transaction_history() { + $result = $this->ktapi->get_document_transaction_history($document_id); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealget_document_version_history() { + $result = $this->ktapi->get_document_version_history($document_id); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealget_document_links() { + $result = $this->ktapi->get_document_links($document_id); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + + function tesRealunlink_documents() { + $result = $this->ktapi->unlink_documents($parent_document_id, $child_document_id); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + function tesReallink_documents() { + $result = $this->ktapi->link_documents($parent_document_id, $child_document_id, $type); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + function tesRealget_client_policies() { + $result = $this->ktapi->get_client_policies($client); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + + function testJunksearch() { + $result = $this->ktapi->search(null, null); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 1); + } + + function tesRealsearch() { + $result = $this->ktapi->search($query, $options); + $this->assertIsA($result, 'array'); + $this->assertEqual($result['status_code'], 0); + } + +} +?> \ No newline at end of file diff --git a/tests/api/testFolder.php b/tests/api/testFolder.php index ffe2a51..19323cf 100644 --- a/tests/api/testFolder.php +++ b/tests/api/testFolder.php @@ -186,8 +186,8 @@ class APIFolderTestCase extends KTUnitTestCase { function testPermissions() { $root = $this->ktapi->get_root_folder(); - $folder = $root->add_folder('testX'); - $this->assertEntity($folder, 'KTAPI_Folder'); + $folder = $root->add_folder('testXXXXX'); + $this->assertIsA($folder, 'KTAPI_Folder'); if(PEAR::isError($folder)) return; $permAllocation = $folder->getPermissionAllocation(); @@ -198,7 +198,12 @@ class APIFolderTestCase extends KTUnitTestCase { $this->assertNotNull($roleAllocation); $this->assertEntity($roleAllocation, KTAPI_RoleAllocation); - $folder->delete('Testing'); + $folder->delete('testXXXXX'); + } + + function testTransactionHistory() { + $transactions = $this->ktapi->get_folder_transaction_history(1); + $this->assertIsA($transactions, 'array'); } } ?> diff --git a/tests/runtests.php b/tests/runtests.php index ac91a51..3cbe32c 100644 --- a/tests/runtests.php +++ b/tests/runtests.php @@ -9,6 +9,7 @@ class UnitTests extends TestSuite { // KTAPI $this->addFile('api/testApi.php'); + $this->addFile('api/testAuto.php'); $this->addFile('api/testSavedSearches.php'); $this->addFile('api/testAcl.php'); $this->addFile('api/testAuthentication.php');