You are here

public function OpenAtriumAccessTestCase::testUserGroups in Open Atrium Core 7.2

File

modules/oa_access/tests/oa_access.test, line 391
Functional tests for the Open Atrium Access module.

Class

OpenAtriumAccessTestCase
Functional tests for the Open Atrium Access module.

Code

public function testUserGroups() {

  // Create an admin user and login.
  $account = $this
    ->oaCreateUser(array(
    'create oa_space content',
  ));
  $this
    ->drupalLogin($account);
  $group_a = $this
    ->oaCreateGroupWithUser(array(
    'title' => 'Group A',
  ), array(
    'access content',
  ));
  $group_b = $this
    ->oaCreateGroupWithUser(array(
    'title' => 'Group B',
  ), array(
    'access content',
  ));

  // Add the user from $group_a to $group_b as well.
  og_group('node', $group_b['group']->nid, array(
    'entity type' => 'user',
    'entity' => $group_a['user']->uid,
    'membership type' => OG_MEMBERSHIP_TYPE_DEFAULT,
  ));

  // Check the groups that the $group_a user belongs to.
  $this
    ->assertEqual(oa_access_user_groups($group_a['user']), array(
    $group_a['group']->nid => $group_a['group']->nid,
    $group_b['group']->nid => $group_b['group']->nid,
    // Magic 'All' Group.
    0 => 0,
  ));

  // Check the (much simpler) $group_b user.
  $this
    ->assertEqual(oa_access_user_groups($group_b['user']), array(
    $group_b['group']->nid => $group_b['group']->nid,
    // Magic 'All' Group.
    0 => 0,
  ));
}