diff --git a/ktapi/KTAPIDocument.inc.php b/ktapi/KTAPIDocument.inc.php index 571f832..dd2c39b 100644 --- a/ktapi/KTAPIDocument.inc.php +++ b/ktapi/KTAPIDocument.inc.php @@ -2285,7 +2285,7 @@ class KTAPI_Document extends KTAPI_FolderItem * * @author KnowledgeTree Team * @access public - * @return bool TRUE if subscribed | FALSE if not + * @return bool $result TRUE if subscribed | FALSE if not */ public function isSubscribed() { @@ -2293,7 +2293,8 @@ class KTAPI_Document extends KTAPI_FolderItem $user = $this->ktapi->get_user(); $document = $this->document; - return Subscription::exists($user->getId(), $document->getId(), $subscriptionType); + $result = Subscription::exists($user->getId(), $document->getId(), $subscriptionType); + return $result; } /** @@ -2301,12 +2302,13 @@ class KTAPI_Document extends KTAPI_FolderItem * * @author KnowledgeTree Team * @access public + * @return boolean|object $result SUCCESS Boolean result of operation | FAILURE - a pear error object */ public function unsubscribe() { if (!$this->isSubscribed()) { - return; + return TRUE; } $subscriptionType = SubscriptionEvent::subTypes('Document'); @@ -2314,7 +2316,16 @@ class KTAPI_Document extends KTAPI_FolderItem $document = $this->document; $subscription = & Subscription::getByIDs($user->getId(), $document->getId(), $subscriptionType); - $subscription->delete(); + $result = $subscription->delete(); + + if(PEAR::isError($result)){ + return $result->getMessage(); + } + if($result){ + return $result; + } + + return $_SESSION['errorMessage']; } /** @@ -2322,12 +2333,13 @@ class KTAPI_Document extends KTAPI_FolderItem * * @author KnowledgeTree Team * @access public + * @return boolean|object $result SUCCESS Boolean result of operation | FAILURE - a pear error object */ public function subscribe() { if ($this->isSubscribed()) { - return; + return TRUE; } $subscriptionType = SubscriptionEvent::subTypes('Document'); @@ -2335,7 +2347,16 @@ class KTAPI_Document extends KTAPI_FolderItem $document = $this->document; $subscription = new Subscription($user->getId(), $document->getId(), $subscriptionType); - $subscription->create(); + $result = $subscription->create(); + + if(PEAR::isError($result)){ + return $result->getMessage(); + } + if($result){ + return $result; + } + + return $_SESSION['errorMessage']; } /** @@ -2456,4 +2477,4 @@ class KTAPI_Document extends KTAPI_FolderItem } } -?> +?> \ No newline at end of file diff --git a/ktapi/KTAPIFolder.inc.php b/ktapi/KTAPIFolder.inc.php index edba600..4cb3415 100644 --- a/ktapi/KTAPIFolder.inc.php +++ b/ktapi/KTAPIFolder.inc.php @@ -1192,7 +1192,8 @@ class KTAPI_Folder extends KTAPI_FolderItem $user = $this->ktapi->get_user(); $folder = $this->folder; - return Subscription::exists($user->getId(), $folder->getId(), $subscriptionType); + $result = Subscription::exists($user->getId(), $folder->getId(), $subscriptionType); + return $result; } /** @@ -1205,7 +1206,7 @@ class KTAPI_Folder extends KTAPI_FolderItem { if (!$this->isSubscribed()) { - return; + return TRUE; } $subscriptionType = SubscriptionEvent::subTypes('Folder'); @@ -1213,7 +1214,16 @@ class KTAPI_Folder extends KTAPI_FolderItem $folder = $this->folder; $subscription = & Subscription::getByIDs($user->getId(), $folder->getId(), $subscriptionType); - $subscription->delete(); + $result = $subscription->delete(); + + if(PEAR::isError($result)){ + return $result->getMessage(); + } + if($result){ + return $result; + } + + return $_SESSION['errorMessage']; } /** @@ -1227,17 +1237,24 @@ class KTAPI_Folder extends KTAPI_FolderItem { if ($this->isSubscribed()) { - return; + return TRUE; } - - $subscriptionType = SubscriptionEvent::subTypes('Folder '); + $subscriptionType = SubscriptionEvent::subTypes('Folder'); $user = $this->ktapi->get_user(); $folder = $this->folder; $subscription = new Subscription($user->getId(), $folder->getId(), $subscriptionType); - $subscription->create(); - } + $result = $subscription->create(); + if(PEAR::isError($result)){ + return $result->getMessage(); + } + if($result){ + return $result; + } + + return $_SESSION['errorMessage']; + } } -?> +?> \ No newline at end of file diff --git a/ktapi/ktapi.inc.php b/ktapi/ktapi.inc.php index 5ce4026..2292c94 100644 --- a/ktapi/ktapi.inc.php +++ b/ktapi/ktapi.inc.php @@ -298,6 +298,39 @@ class KTAPI ); } + + /** + * Returns folder permissions + * + * @access public + * @param string + * @param int + * + */ + public function get_document_permissions($username, $document_id) { + if (is_null($this->session)) + { + return array( + "status_code" => 1, + "message" => "Your session is not active" + ); + } + /* We need to create a new instance of KTAPI to get another user */ + $user_ktapi = new KTAPI(); + $user_ktapi->start_system_session($username); + + $document = KTAPI_Document::get($user_ktapi, $document_id); + + $permissions = $document->getPermissionAllocation(); + + $user_ktapi->session_logout(); + + return array( + "status_code" => 0, + "results" => $permissions->permissions + ); + + } /** * Add folder permission @@ -3978,7 +4011,7 @@ class KTAPI * @param string $query The saved search query * @return array $response The formatted response array */ - public function createSavedSearch($name, $query) + public function create_saved_search($name, $query) { $savedSearch = new savedSearches($this); if(PEAR::isError($savedSearch)){ @@ -4009,7 +4042,7 @@ class KTAPI * @param string $searchID The id of the saved search * @return array $response The formatted response array */ - public function getSavedSearch($searchID) + public function get_saved_search($searchID) { $savedSearch = new savedSearches($this); if(PEAR::isError($savedSearch)){ @@ -4018,7 +4051,7 @@ class KTAPI return $response; } - $result = $savedSearch->getSavedSearch($searchID); + $result = $savedSearch->get_saved_search($searchID); if(PEAR::isError($result)){ $response['status_code'] = 1; $response['message'] = $result->getMessage(); @@ -4045,7 +4078,7 @@ class KTAPI * @access public * @return array $response The formatted response array */ - public function getSavedSearchList() + public function get_saved_search_list() { $savedSearch = new savedSearches($this); if(PEAR::isError($savedSearch)){ @@ -4054,7 +4087,7 @@ class KTAPI return $response; } - $result = $savedSearch->getList(); + $result = $savedSearch->get_list(); if(PEAR::isError($result)){ $response['status_code'] = 1; $response['message'] = $result->getMessage(); @@ -4082,7 +4115,7 @@ class KTAPI * @param string $searchID The id of the saved search to delete * @return array $response The formatted response array */ - public function deleteSavedSearch($searchID) + public function delete_saved_search($searchID) { $savedSearch = new savedSearches($this); if(PEAR::isError($savedSearch)){ @@ -4112,7 +4145,7 @@ class KTAPI * @param string $searchID The id of the saved search to delete * @return array $response The formatted response array */ - public function runSavedSearch($searchID) + public function run_saved_search($searchID) { $savedSearch = new savedSearches($this); if(PEAR::isError($savedSearch)){ @@ -4121,7 +4154,7 @@ class KTAPI return $response; } - $results = $savedSearch->runSavedSearch($searchID); + $results = $savedSearch->run_saved_search($searchID); if(PEAR::isError($results)){ $response['status_code'] = 1; $response['message'] = $results->getMessage(); @@ -4137,6 +4170,298 @@ class KTAPI return $response; } + + /** + * Method to get the details of a user + * + * @author KnowledgeTree Team + * @access private + * @param object $oUser The user object + * @return array $results The user details in an array + */ + private function _get_user_details($oUser) + { + $results['user_id'] = $oUser->getId(); + $results['username'] = $oUser->getUsername(); + $results['name'] = $oUser->getName(); + $results['email'] = $oUser->getEmail(); + + return $results; + } + + /** + * Method to return a user based on the userID + * + * @author KnowledgeTree Team + * @access public + * @param string $userID The id of the user + * @return array $response The formatted response array + */ + public function get_user_by_id($userID) + { + $user = KTAPI_User::getById($userID); + if(PEAR::isError($user)){ + $response['status_code'] = 1; + $response['message'] = $user->getMessage(); + return $response; + } + + $results = $this->_get_user_details($user); + $response['message'] = ''; + $response['status_code'] = 0; + $response['results'] = $results; + + return $response; + } + + /** + * Method to return a user based on the username + * + * @author KnowledgeTree Team + * @access public + * @param string $username The username of the user + * @return array $response The formatted response array + */ + public function get_user_by_username($username) + { + $user = KTAPI_User::getByUsername($username); + if(PEAR::isError($user)){ + $response['status_code'] = 1; + $response['message'] = $user->getMessage(); + return $response; + } + + $results = $this->_get_user_details($user); + $response['message'] = ''; + $response['status_code'] = 0; + $response['results'] = $results; + + return $response; + } + + /** + * Method to return a user based on the name + * + * @author KnowledgeTree Team + * @access public + * @param string $name The name of the user + * @return array $response The formatted response array + */ + public function get_user_by_name($name) + { + $user = KTAPI_User::getByName($name); + if(PEAR::isError($user)){ + $response['status_code'] = 1; + $response['message'] = $user->getMessage(); + return $response; + } + + $results = $this->_get_user_details($user); + $response['message'] = ''; + $response['status_code'] = 0; + $response['results'] = $results; + + return $response; + } + + /** + * Method to return a list of users matching the filter criteria + * + * @author KnowledgeTree Team + * @access public + * @param string $filter + * @param string $options + * @return array $response The formatted response array + */ + public function get_user_list($filter = NULL, $options = NULL) + { + $users = KTAPI_User::getList($filter, $options); + if(PEAR::isError($users)){ + $response['status_code'] = 1; + $response['message'] = $users->getMessage(); + return $response; + } + foreach($users as $user){ + $results[] = $this->_get_user_details($user); + } + $response['message'] = ''; + $response['status_code'] = 0; + $response['results'] = $results; + + return $response; + } + + /** + * Method to check if a document is subscribed + * + * @author KnowledgeTree Team + * @access public + * @param string $documentID The id of the document + * @return array $response The formatted response array + */ + public function is_document_subscribed($documentID) + { + $document = $this->get_document_by_id($documentID); + if(PEAR::isError($document)){ + $response['message'] = $document->getMessage(); + $response['status_code'] = 1; + return $response; + } + + $result = $document->isSubscribed(); + $response['message'] = ''; + $response['status_code'] = 0; + if($result){ + $response['results']['subscribed'] = 'TRUE'; + }else{ + $response['results']['subscribed'] = 'FALSE'; + } + return $response; + } + + /** + * Method to subscribe to a document + * + * @author KnowledgeTree Team + * @access public + * @param string $documentID The id of the document + * @return array $response The formatted response array + */ + public function subscribe_to_document($documentID) + { + $document = $this->get_document_by_id($documentID); + if(PEAR::isError($document)){ + $response['message'] = $document->getMessage(); + $response['status_code'] = 1; + return $response; + } + + $result = $document->subscribe(); + if($result === TRUE){ + $response['message'] = ''; + $response['status_code'] = 0; + $response['results']['action_result'] = 'TRUE'; + }else{ + $response['message'] = $result; + $response['status_code'] = 1; + } + return $response; + } + + /** + * Method to unsubscribe from a document + * + * @author KnowledgeTree Team + * @access public + * @param string $documentID The id of the document + * @return array $response The formatted response array + */ + public function unsubscribe_from_document($documentID) + { + $document = $this->get_document_by_id($documentID); + if(PEAR::isError($document)){ + $response['message'] = $document->getMessage(); + $response['status_code'] = 1; + return $response; + } + + $result = $document->unsubscribe(); + if($result === TRUE){ + $response['message'] = ''; + $response['status_code'] = 0; + $response['results']['action_result'] = 'TRUE'; + }else{ + $response['message'] = $result; + $response['status_code'] = 1; + } + return $response; + } + + /** + * Method to check if a folder is subscribed + * + * @author KnowledgeTree Team + * @access public + * @param string $folderID The id of the folder + * @return array $response The formatted response array + */ + public function is_folder_subscribed($folderID) + { + $folder = $this->get_folder_by_id($folderID); + if(PEAR::isError($folder)){ + $response['message'] = $folder->getMessage(); + $response['status_code'] = 1; + return $response; + } + + $result = $folder->isSubscribed(); + $response['message'] = ''; + $response['status_code'] = 0; + if($result){ + $response['results']['subscribed'] = 'TRUE'; + }else{ + $response['results']['subscribed'] = 'FALSE'; + } + return $response; + } + + /** + * Method to subscribe to a folder + * + * @author KnowledgeTree Team + * @access public + * @param string $folderID The id of the folder + * @return array $response The formatted response array + */ + public function subscribe_to_folder($folderID) + { + $folder = $this->get_folder_by_id($folderID); + if(PEAR::isError($folder)){ + $response['message'] = $folder->getMessage(); + $response['status_code'] = 1; + return $response; + } + + $result = $folder->subscribe(); + if($result === TRUE){ + $response['message'] = ''; + $response['status_code'] = 0; + $response['results']['action_result'] = 'TRUE'; + }else{ + $response['message'] = $result; + $response['status_code'] = 1; + } + return $response; + } + + /** + * Method to unsubscribe from a folder + * + * @author KnowledgeTree Team + * @access public + * @param string $folderID The id of the folder + * @return array $response The formatted response array + */ + public function unsubscribe_from_folder($folderID) + { + $folder = $this->get_folder_by_id($folderID); + if(PEAR::isError($folder)){ + $response['message'] = $folder->getMessage(); + $response['status_code'] = 1; + return $response; + } + + $result = $folder->unsubscribe(); + if($result === TRUE){ + $response['message'] = ''; + $response['status_code'] = 0; + $response['results']['action_result'] = 'TRUE'; + }else{ + $response['message'] = $result; + $response['status_code'] = 1; + } + return $response; + } } @@ -4200,7 +4525,7 @@ class savedSearches * @param integer $searchID The id of the saved search * @return array|object $search SUCESS - The saved search data | FAILURE - a pear error object */ - public function getSavedSearch($searchID) + public function get_saved_search($searchID) { $search = SearchHelper::getSavedSearch($searchID); return $search; @@ -4213,7 +4538,7 @@ class savedSearches * @access public * @return array|object $list SUCESS - The list of saved searches | FAILURE - an error object */ - public function getList() + public function get_list() { $user = $this->ktapi->get_user(); if (is_null($user) || PEAR::isError($user)) @@ -4253,9 +4578,9 @@ class savedSearches * @param integer $searchID The id of the saved search * @return array|object $results SUCCESS - The results of the saved serach | FAILURE - a pear error object */ - public function runSavedSearch($searchID) + public function run_saved_search($searchID) { - $search = $this->getSavedSearch($searchID); + $search = $this->get_saved_search($searchID); if(is_null($search) || PEAR::isError($search)){ $results = new PEAR_Error('Invalid saved search'); return $results; @@ -4266,4 +4591,5 @@ class savedSearches return $results; } } + ?> \ No newline at end of file diff --git a/templates/ktcore/login.smarty b/templates/ktcore/login.smarty index c898019..607f4a3 100644 --- a/templates/ktcore/login.smarty +++ b/templates/ktcore/login.smarty @@ -11,8 +11,10 @@ - - +
diff --git a/tests/api/testAcl.php b/tests/api/testAcl.php index 6bbdd53..f2298fd 100644 --- a/tests/api/testAcl.php +++ b/tests/api/testAcl.php @@ -190,6 +190,36 @@ class APIAclTestCase extends KTUnitTestCase { } + /** + * Method to test the user webservice fucntions + * + */ + public function testUsers_KTAPI() + { + $response = $this->ktapi->get_user_list(); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['status_code'], 0); + $this->assertNoErrors(); + + $response = $this->ktapi->get_user_by_id(1); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['status_code'], 0); + $this->assertEqual($response['results']['name'], 'Administrator'); + $this->assertNoErrors(); + + $response = $this->ktapi->get_user_by_username('admin'); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['status_code'], 0); + $this->assertEqual($response['results']['name'], 'Administrator'); + $this->assertNoErrors(); + + $response = $this->ktapi->get_user_by_name('Administrator'); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['status_code'], 0); + $this->assertEqual($response['results']['name'], 'Administrator'); + $this->assertNoErrors(); + } + /** * Test KTAPI_Group getList(), getById(), getByName * diff --git a/tests/api/testDocument.php b/tests/api/testDocument.php index 5bad890..534aa7d 100644 --- a/tests/api/testDocument.php +++ b/tests/api/testDocument.php @@ -395,5 +395,65 @@ class APIDocumentTestCase extends KTUnitTestCase { } } */ + + /** + * Method to test the document subscriptions for webservices + * + */ + public function testSubscriptions_KTAPI() + { + $this->ktapi->session_logout(); + $this->session = $this->ktapi->start_session('admin', 'admin'); + + $randomFile = APIDocumentHelper::createRandomFile(); + $this->assertTrue(is_file($randomFile)); + + $document = $this->root->add_document('testtitle.txt', 'testname.txt', 'Default', $randomFile); + $this->assertIsA($document, 'KTAPI_Document'); + $this->assertNoErrors(); + + @unlink($randomFile); + $documentid = $document->get_documentid(); + + // case no subscription + $response = $this->ktapi->is_document_subscribed($documentid); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['results']['subscribed'], 'FALSE'); + $this->assertNoErrors(); + + //case add subscription + $response = $this->ktapi->subscribe_to_document($documentid); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['results']['action_result'], 'TRUE'); + $this->assertNoErrors(); + + //case add DUPLICATE subscription + $response = $this->ktapi->subscribe_to_document($documentid); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['results']['action_result'], 'TRUE'); + $this->assertNoErrors(); + + // case subscription exists + $response = $this->ktapi->is_document_subscribed($documentid); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['results']['subscribed'], 'TRUE'); + $this->assertNoErrors(); + + //case delete subscription + $response = $this->ktapi->unsubscribe_from_document($documentid); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['results']['action_result'], 'TRUE'); + $this->assertNoErrors(); + + //case delete NOT EXISTANT subscription + $response = $this->ktapi->unsubscribe_from_document($documentid); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['results']['action_result'], 'TRUE'); + $this->assertNoErrors(); + + $document->delete('Test'); + $document->expunge(); + } } -?> + +?> \ No newline at end of file diff --git a/tests/api/testFolder.php b/tests/api/testFolder.php index 19323cf..638fd44 100644 --- a/tests/api/testFolder.php +++ b/tests/api/testFolder.php @@ -200,10 +200,65 @@ class APIFolderTestCase extends KTUnitTestCase { $folder->delete('testXXXXX'); } - + function testTransactionHistory() { $transactions = $this->ktapi->get_folder_transaction_history(1); $this->assertIsA($transactions, 'array'); } + + /** + * Method to test the folder subscriptions for webservices + * + */ + public function testSubscriptions_KTAPI() + { + $this->ktapi->session_logout(); + $this->session = $this->ktapi->start_session('admin', 'admin'); + + $root = $this->ktapi->get_root_folder(); + $folder = $root->add_folder('testXXXXX'); + $this->assertIsA($folder, 'KTAPI_Folder'); + $this->assertNotA($folder, 'PEAR_Error'); + $this->assertNoErrors(); + + // case no subscription + $response = $this->ktapi->is_folder_subscribed($folder->get_folderid()); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['results']['subscribed'], 'FALSE'); + $this->assertNoErrors(); + + //case add subscription + $response = $this->ktapi->subscribe_to_folder($folder->get_folderid()); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['results']['action_result'], 'TRUE'); + $this->assertNoErrors(); + + //case add DUPLICATE subscription + $response = $this->ktapi->subscribe_to_folder($folder->get_folderid()); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['results']['action_result'], 'TRUE'); + $this->assertNoErrors(); + + // case subscription exists + $response = $this->ktapi->is_folder_subscribed($folder->get_folderid()); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['results']['subscribed'], 'TRUE'); + $this->assertNoErrors(); + + //case delete subscription + $response = $this->ktapi->unsubscribe_from_folder($folder->get_folderid()); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['results']['action_result'], 'TRUE'); + $this->assertNoErrors(); + + //case delete NOT EXISTANT subscription + $response = $this->ktapi->unsubscribe_from_folder($folder->get_folderid()); + $this->assertIsA($response, 'array'); + $this->assertEqual($response['results']['action_result'], 'TRUE'); + $this->assertNoErrors(); + + $folder->delete('testXXXXX'); + } } -?> + +?> \ No newline at end of file diff --git a/tests/api/testSavedSearches.php b/tests/api/testSavedSearches.php index 7b5ea11..1ff223d 100644 --- a/tests/api/testSavedSearches.php +++ b/tests/api/testSavedSearches.php @@ -79,7 +79,7 @@ class savedSearchTestCase extends KTUnitTestCase { { // case 1: search exists $searchID = $this->savedSearch->create('test_search', '(GeneralText contains "title")'); - $list = $this->savedSearch->getList(); + $list = $this->savedSearch->get_list(); foreach($list as $item){ if($item['id'] == $searchID){ @@ -87,14 +87,14 @@ class savedSearchTestCase extends KTUnitTestCase { break; } } - $savedSearch = $this->savedSearch->getSavedSearch($search); + $savedSearch = $this->savedSearch->get_saved_search($search); $this->assertNotNull($savedSearch); $this->assertNoErrors(); $this->savedSearch->delete($searchID); // case 2: search does NOT exists - $list = $this->savedSearch->getList(); + $list = $this->savedSearch->get_list(); $inList = FALSE; foreach($list as $item){ if($item['id'] == $searchID){ @@ -118,7 +118,7 @@ class savedSearchTestCase extends KTUnitTestCase { // case 1: Saved searches exist $array = array(); $searchID = $this->savedSearch->create('test_search', '(GeneralText contains "title")'); - $list = $this->savedSearch->getList(); + $list = $this->savedSearch->get_list(); $this->assertNotA($list, 'PEAR_Error'); $this->assertNotEqual($list, $array); $this->assertNoErrors(); @@ -126,7 +126,7 @@ class savedSearchTestCase extends KTUnitTestCase { $this->savedSearch->delete($searchID); // case 2: saved search does NOT exist - $list = $this->savedSearch->getList(); + $list = $this->savedSearch->get_list(); $inList = FALSE; foreach($list as $item){ @@ -148,7 +148,7 @@ class savedSearchTestCase extends KTUnitTestCase { { $searchID = $this->savedSearch->create('test_search', '(GeneralText contains "title")'); $this->savedSearch->delete($searchID); - $result = $this->savedSearch->getSavedSearch($searchID); + $result = $this->savedSearch->get_saved_search($searchID); $array = array(); $this->assertEqual($result, $array); @@ -169,7 +169,7 @@ class savedSearchTestCase extends KTUnitTestCase { $searchID = $this->savedSearch->create('test_search', '(GeneralText contains "title")'); - $result = $this->savedSearch->runSavedSearch($searchID); + $result = $this->savedSearch->run_saved_search($searchID); $this->assertNotNull($result); $this->assertNotA($result, 'PEAR_Error'); @@ -188,7 +188,7 @@ class savedSearchTestCase extends KTUnitTestCase { public function testCreate_KTAPI() { //case 1: user logged in - $response = $this->ktapi->createSavedSearch('test_search', '(GeneralText contains "title")'); + $response = $this->ktapi->create_saved_search('test_search', '(GeneralText contains "title")'); $this->assertIsA($response, 'array'); $this->assertEqual($response['status_code'], 0); @@ -198,7 +198,7 @@ class savedSearchTestCase extends KTUnitTestCase { //case 2: user NOT logged in $this->ktapi->session_logout(); - $response = $this->ktapi->createSavedSearch('test_search', '(GeneralText contains "title")'); + $response = $this->ktapi->create_saved_search('test_search', '(GeneralText contains "title")'); $this->assertIsA($response, 'array'); $this->assertEqual($response['status_code'], 1); @@ -213,7 +213,7 @@ class savedSearchTestCase extends KTUnitTestCase { { // case 1: search exists $searchID = $this->savedSearch->create('test_search', '(GeneralText contains "title")'); - $list = $this->savedSearch->getList(); + $list = $this->savedSearch->get_list(); foreach($list as $item){ if($item['id'] == $searchID){ @@ -221,7 +221,7 @@ class savedSearchTestCase extends KTUnitTestCase { break; } } - $response = $this->ktapi->getSavedSearch($search); + $response = $this->ktapi->get_saved_search($search); $this->assertIsA($response, 'array'); $this->assertEqual($response['status_code'], 0); @@ -229,7 +229,7 @@ class savedSearchTestCase extends KTUnitTestCase { $this->savedSearch->delete($searchID); // case 2: search does NOT exists - $response = $this->ktapi->getSavedSearch($searchID); + $response = $this->ktapi->get_saved_search($searchID); $this->assertIsA($response, 'array'); $this->assertEqual($response['status_code'], 1); @@ -247,7 +247,7 @@ class savedSearchTestCase extends KTUnitTestCase { $array = array(); $searchID = $this->savedSearch->create('test_search', '(GeneralText contains "title")'); - $response = $this->ktapi->getSavedSearchList(); + $response = $this->ktapi->get_saved_search_list(); $this->assertIsA($response, 'array'); $this->assertEqual($response['status_code'], 0); @@ -255,7 +255,7 @@ class savedSearchTestCase extends KTUnitTestCase { $this->savedSearch->delete($searchID); // case 2: saved search does NOT exist - $response = $this->ktapi->getSavedSearchList(); + $response = $this->ktapi->get_saved_search_list(); $this->assertIsA($response, 'array'); $this->assertEqual($response['status_code'], 1); @@ -269,8 +269,8 @@ class savedSearchTestCase extends KTUnitTestCase { public function testDelete_KTAPI() { $searchID = $this->savedSearch->create('test_search', '(GeneralText contains "title")'); - $response = $this->ktapi->deleteSavedSearch($searchID); - $result = $this->savedSearch->getSavedSearch($searchID); + $response = $this->ktapi->delete_saved_search($searchID); + $result = $this->savedSearch->get_saved_search($searchID); $array = array(); $this->assertEqual($result, $array); @@ -292,7 +292,7 @@ class savedSearchTestCase extends KTUnitTestCase { $searchID = $this->savedSearch->create('test_search', '(GeneralText contains "title")'); - $response = $this->ktapi->runSavedSearch($searchID); + $response = $this->ktapi->run_saved_search($searchID); $this->assertIsA($response, 'array'); $this->assertEqual($response['status_code'], 0);