You are here

protected function Faq_AskTestCase::setPermissions in FAQ_Ask 7

Set the permission of a user. If user is NULL or blank then assume anonymous

Parameters

object $user: The user to set permission for

array $perms: An array of permissions

1 call to Faq_AskTestCase::setPermissions()
CRAUDFaq_AskTestCase::testFaq_AskCreate in ./faq_ask.test
Test creating an unanswered FAQ and verify its status Also switches on notifcation of asker and verifies that anonymous are sent an e-mail by cron run

File

./faq_ask.test, line 208
Test Faq_Ask functionality Base test class. All tests inherits this one Hugely based on code from the test file block.test by boombatower

Class

Faq_AskTestCase
Base class that is extended by test cases

Code

protected function setPermissions($user, $perms) {
  $edit = array();
  $role = '1';
  if (isset($user->roles)) {
    $role = end($user->roles);
    $this
      ->pass('Roles of user ' . $user->name . ': <pre>' . var_export($user->roles, TRUE) . '</pre>');

    // Show us the user roles
  }
  $this
    ->pass('Role selected: <pre>' . var_export($role, TRUE) . '</pre>');

  // Show us the user roles
  foreach ($perms as $permission) {
    $edit[$role . '[' . $permission . ']'] = TRUE;
  }
  $this
    ->drupalPost('admin/people/permissions', $edit, 'Save permissions');
}