You are here

protected function OpignoWebTestCase::addMemberToCourse in Opigno 7

Add member to course.

Parameters

object $node:

int $uid:

array $roles:

1 call to OpignoWebTestCase::addMemberToCourse()
OpignoWebTestCase::createCourse in tests/OpignoWebTestCase.test
Create a course and assign members to it.

File

tests/OpignoWebTestCase.test, line 107
Defines the base class for Opigno unit testing. This base class contains re-usable logic that will make it easier and faster to write Opigno-specific unit tests.

Class

OpignoWebTestCase
@file Defines the base class for Opigno unit testing. This base class contains re-usable logic that will make it easier and faster to write Opigno-specific unit tests.

Code

protected function addMemberToCourse($node, $uid, $roles = array(
  'member',
)) {
  og_membership_create('node', $node->nid, 'user', $uid, 'og_user_node');
  foreach ($roles as $role) {
    $rid = $this
      ->getRoleId($role);
    if (!empty($rid)) {
      og_role_grant('node', $node->nid, $uid, $rid);
    }
    else {
      $this
        ->fail("Could not find the role '{$role}'.");
    }
  }
}