You are here

protected function FeaturesUserTestCase::_test_user_permission in Features 6

Same name and namespace in other branches
  1. 7.2 tests/features.test \FeaturesUserTestCase::_test_user_permission()
  2. 7 tests/features.test \FeaturesUserTestCase::_test_user_permission()

File

tests/features.test, line 195

Class

FeaturesUserTestCase
User permission component tests for Features

Code

protected function _test_user_permission($op = 'load') {
  switch ($op) {
    case 'load':

      // So... relying on our own API functions to test is pretty lame.
      // But these modules don't have APIs either. So might as well use
      // the ones we've written for them...
      features_include();
      $permissions = _user_features_get_permissions();
      return isset($permissions['create features_test content']) ? $permissions['create features_test content'] : FALSE;
    case 'override':
      $roles = _features_get_roles();
      if (in_array('create features_test content', $roles['authenticated user']['perm'])) {
        $position = array_search('create features_test content', $roles['authenticated user']['perm']);
        unset($roles['authenticated user']['perm'][$position]);
      }
      _user_features_save_roles($roles);
      break;
  }
}