From 9e04e570c1b4cf42d611e8386141a582bfb57c7c Mon Sep 17 00:00:00 2001 From: Kevin Cyster Date: Thu, 19 Feb 2009 12:39:45 +0200 Subject: [PATCH] Added unit tests for webservice functionality for subscriptions --- tests/api/testFolder.php | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/tests/api/testFolder.php b/tests/api/testFolder.php index 19323cf..d006ed8 100644 --- a/tests/api/testFolder.php +++ b/tests/api/testFolder.php @@ -200,10 +200,64 @@ 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 -- libgit2 0.21.4