Commit 9e04e570c1b4cf42d611e8386141a582bfb57c7c
1 parent
28181f0e
Added unit tests for webservice functionality for subscriptions
Committed By: Kevin Cyster Reviewed By: Megan Watson
Showing
1 changed file
with
56 additions
and
2 deletions
tests/api/testFolder.php
| @@ -200,10 +200,64 @@ class APIFolderTestCase extends KTUnitTestCase { | @@ -200,10 +200,64 @@ class APIFolderTestCase extends KTUnitTestCase { | ||
| 200 | 200 | ||
| 201 | $folder->delete('testXXXXX'); | 201 | $folder->delete('testXXXXX'); |
| 202 | } | 202 | } |
| 203 | - | 203 | + |
| 204 | function testTransactionHistory() { | 204 | function testTransactionHistory() { |
| 205 | $transactions = $this->ktapi->get_folder_transaction_history(1); | 205 | $transactions = $this->ktapi->get_folder_transaction_history(1); |
| 206 | $this->assertIsA($transactions, 'array'); | 206 | $this->assertIsA($transactions, 'array'); |
| 207 | } | 207 | } |
| 208 | + | ||
| 209 | + /** | ||
| 210 | + * Method to test the folder subscriptions for webservices | ||
| 211 | + * | ||
| 212 | + */ | ||
| 213 | + public function testSubscriptions_KTAPI() | ||
| 214 | + { | ||
| 215 | + $this->ktapi->session_logout(); | ||
| 216 | + $this->session = $this->ktapi->start_session('admin', 'admin'); | ||
| 217 | + | ||
| 218 | + $root = $this->ktapi->get_root_folder(); | ||
| 219 | + $folder = $root->add_folder('testXXXXX'); | ||
| 220 | + $this->assertIsA($folder, 'KTAPI_Folder'); | ||
| 221 | + $this->assertNotA($folder, 'PEAR_Error'); | ||
| 222 | + $this->assertNoErrors(); | ||
| 223 | + | ||
| 224 | + // case no subscription | ||
| 225 | + $response = $this->ktapi->is_folder_subscribed($folder->get_folderid()); | ||
| 226 | + $this->assertIsA($response, 'array'); | ||
| 227 | + $this->assertEqual($response['results']['subscribed'], 'FALSE'); | ||
| 228 | + $this->assertNoErrors(); | ||
| 229 | + | ||
| 230 | + //case add subscription | ||
| 231 | + $response = $this->ktapi->subscribe_to_folder($folder->get_folderid()); | ||
| 232 | + $this->assertIsA($response, 'array'); | ||
| 233 | + $this->assertEqual($response['results']['action_result'], 'TRUE'); | ||
| 234 | + $this->assertNoErrors(); | ||
| 235 | + | ||
| 236 | + //case add DUPLICATE subscription | ||
| 237 | + $response = $this->ktapi->subscribe_to_folder($folder->get_folderid()); | ||
| 238 | + $this->assertIsA($response, 'array'); | ||
| 239 | + $this->assertEqual($response['results']['action_result'], 'TRUE'); | ||
| 240 | + $this->assertNoErrors(); | ||
| 241 | + | ||
| 242 | + // case subscription exists | ||
| 243 | + $response = $this->ktapi->is_folder_subscribed($folder->get_folderid()); | ||
| 244 | + $this->assertIsA($response, 'array'); | ||
| 245 | + $this->assertEqual($response['results']['subscribed'], 'TRUE'); | ||
| 246 | + $this->assertNoErrors(); | ||
| 247 | + | ||
| 248 | + //case delete subscription | ||
| 249 | + $response = $this->ktapi->unsubscribe_from_folder($folder->get_folderid()); | ||
| 250 | + $this->assertIsA($response, 'array'); | ||
| 251 | + $this->assertEqual($response['results']['action_result'], 'TRUE'); | ||
| 252 | + $this->assertNoErrors(); | ||
| 253 | + | ||
| 254 | + //case delete NOT EXISTANT subscription | ||
| 255 | + $response = $this->ktapi->unsubscribe_from_folder($folder->get_folderid()); | ||
| 256 | + $this->assertIsA($response, 'array'); | ||
| 257 | + $this->assertEqual($response['results']['action_result'], 'TRUE'); | ||
| 258 | + $this->assertNoErrors(); | ||
| 259 | + | ||
| 260 | + $folder->delete('testXXXXX'); | ||
| 261 | + } | ||
| 208 | } | 262 | } |
| 209 | -?> | 263 | -?> |
| 264 | +?> | ||
| 210 | \ No newline at end of file | 265 | \ No newline at end of file |