You are here

public function OpenAtriumAccessTestCase::testUserTeams in Open Atrium Core 7.2

File

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

Class

OpenAtriumAccessTestCase
Functional tests for the Open Atrium Access module.

Code

public function testUserTeams() {

  // Create an admin user and login.
  $account = $this
    ->oaCreateUser(array(
    'create oa_space content',
  ));
  $this
    ->drupalLogin($account);

  // Create a Space that all our users are going to belong to.
  $space1 = $this
    ->oaCreateNode(array(
    'title' => 'Space A',
    'type' => 'oa_space',
    'uid' => $account->uid,
  ));
  $user_a = $this
    ->oaCreateUser(array(), $space1);

  // Now, create a Team in our Space.
  $team_a = $this
    ->oaCreateTeamWithUser(array(
    'title' => 'Team A',
  ), array(
    'access content',
  ), $space1);

  // Check the teams that the $team_a user belongs to.
  $this
    ->assertEqual(oa_access_user_teams($space1->nid, $team_a['user']), array(
    $team_a['team']->nid => $team_a['team']->nid,
    $space1->nid => $space1->nid,
  ));

  // Check the (much simpler) $user_a user.
  $this
    ->assertEqual(oa_access_user_teams($space1->nid, $user_a), array(
    // Magic 'All' Team.
    $space1->nid => $space1->nid,
  ));
}