You are here

function OgUiUserPermissionsTestCase::testOgUiUserPermissionChanges in Organic groups 7

Same name and namespace in other branches
  1. 7.2 og_ui/og_ui.test \OgUiUserPermissionsTestCase::testOgUiUserPermissionChanges()

Change user permissions and check og_user_access().

File

og_ui/og_ui.test, line 37

Class

OgUiUserPermissionsTestCase

Code

function testOgUiUserPermissionChanges() {
  $web_user = $this
    ->drupalCreateUser();
  $gid = $this->group->gid;
  $this
    ->assertTrue(og_user_access($gid, 'subscribe', $web_user), t('User has "subscribe" permission.'));
  $roles = og_get_default_roles();
  $roles = array_flip(array_keys($roles['og']));

  // Remove a permission.
  $edit = array();
  $edit['1[subscribe]'] = FALSE;
  $this
    ->drupalPost('admin/config/group/permissions', $edit, t('Save global permissions'));
  $this
    ->assertText(t('The changes have been saved.'), t('Successful save message displayed.'));

  // FIXME: Understand why reseting the static cache isn't enough.
  $this
    ->resetAll();
  $this
    ->assertFalse(og_user_access($gid, 'subscribe', $web_user), t('User now does not have "subscribe" permission.'));

  // Re-add permission.
  $edit = array();
  $edit['1[subscribe]'] = TRUE;
  $this
    ->drupalPost('admin/config/group/permissions', $edit, t('Save global permissions'));
  $this
    ->resetAll();
  $this
    ->assertTrue(og_user_access($gid, 'subscribe', $web_user), t('User has "subscribe" permission again.'));
}