/** * Test role allocation on folders */ function testAllocatingMembersToRoles() { $folder = $this->ktapi->get_folder_by_name('test123'); if (!$folder instanceof KTAPI_Folder) { $folder = $this->root->add_folder('test123'); } $folder_id = $folder->get_folderid(); $allocation = $this->ktapi->get_role_allocation_for_folder($folder_id); $this->assertEqual($allocation['status_code'], 0); $this->assertTrue(empty($allocation['results'])); // add a user to a role $role_id = 2; // Publisher $user_id = 1; // Admin $result = $this->ktapi->add_user_to_role_on_folder($folder_id, $role_id, $user_id); $this->assertEqual($result['status_code'], 0); $allocation = $this->ktapi->get_role_allocation_for_folder($folder_id); $this->assertEqual($allocation['status_code'], 0); $this->assertTrue(isset($allocation['results']['Publisher'])); $this->assertEqual($allocation['results']['Publisher']['user'][1], 'Administrator'); // test check on members in the role $check = $this->ktapi->is_member_in_role_on_folder($folder_id, $role_id, $user_id, 'user'); $this->assertEqual($check['status_code'], 0); $this->assertEqual($check['results'], 'YES'); // remove user from a role $result = $this->ktapi->remove_user_from_role_on_folder($folder_id, $role_id, $user_id); $this->assertEqual($result['status_code'], 0); $allocation = $this->ktapi->get_role_allocation_for_folder($folder_id); $this->assertEqual($allocation['status_code'], 0); $this->assertFalse(isset($allocation['results']['Publisher'])); // clean up $folder->delete('Testing API'); }