/** * Create a ktapi session */ function setUp() { $this->ktapi = new KTAPI(); $this->session = $this->ktapi->start_system_session(); $this->root = $this->ktapi->get_root_folder(); $this->assertTrue($this->root instanceof KTAPI_Folder); }
/** * Create a ktapi session */ function setUp() { $this->ktapi = new KTAPI(); $this->session = $this->ktapi->start_system_session(); $this->root = $this->ktapi->get_root_folder(); $this->bulk = new KTAPI_BulkActions($this->ktapi); }
/** * Test KTAPI_PermissionAllocation getAllocation(), add(), remove(), save() * */ function testPermissionAllocation() { $root = $this->ktapi->get_root_folder(); $folder = $this->ktapi->get_folder_by_name('test123'); if (!$folder instanceof KTAPI_Folder) { $folder = $root->add_folder('test123'); } $allocation = KTAPI_PermissionAllocation::getAllocation($this->ktapi, $folder); $group = KTAPI_Group::getByName('System Administrators'); $user = KTAPI_User::getByUsername('anonymous'); $role = KTAPI_Role::getByName('Publisher'); $read = KTAPI_Permission::getByNamespace('ktcore.permissions.read'); $write = KTAPI_Permission::getByNamespace('ktcore.permissions.write'); $addFolder = KTAPI_Permission::getByNamespace('ktcore.permissions.addFolder'); $security = KTAPI_Permission::getByNamespace('ktcore.permissions.security'); $allocation->add($user, $read); $allocation->add($user, $write); $allocation->add($user, $addFolder); $allocation->add($user, $security); $allocation->add($role, $read); $allocation->add($role, $write); $allocation->remove($group, $write); $allocation->save(); // refresh object and check permission allocations $folder2 = $this->ktapi->get_folder_by_name('test123'); $allocation = KTAPI_PermissionAllocation::getAllocation($this->ktapi, $folder2); $this->assertTrue($allocation->isMemberPermissionSet($user, $read)); $this->assertTrue($allocation->isMemberPermissionSet($user, $write)); $this->assertTrue($allocation->isMemberPermissionSet($role, $write)); $this->assertFalse($allocation->isMemberPermissionSet($group, $write)); $folder->delete('Testing permission allocation'); }
/** * Setup the session, add and index the document * */ function setUp() { $this->ktapi = new KTAPI(); $this->session = $this->ktapi->start_system_session(); $this->root = $this->ktapi->get_root_folder(); $doc = array(); $docId = array(); // Add documents to DB and lucene index $filename = 'Test987.txt'; $title = 'Test987'; $this->addNewDocument($title, $filename, 0); $filename = 'Test654.txt'; $title = 'Test654'; $content = 'Searchable text: abcde ghijk 4567'; $this->addNewDocument($title, $filename, 1, $content); $filename = 'Test321.txt'; $title = 'Test321'; $content = 'Searchable text: abcde mnopqr 891011'; $this->addNewDocument($title, $filename, 2, $content); }
/** * 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'); }