public function OpenAtriumAccessTestCase::testTeamAccess in Open Atrium Core 7.2
File
- modules/oa_access/tests/oa_access.test, line 552
- Functional tests for the Open Atrium Access module.
Class
- OpenAtriumAccessTestCase
- Functional tests for the Open Atrium Access module.
Code
public function testTeamAccess() {
$account = $this
->oaCreateUser(array(
'create oa_space content',
));
$this
->drupalLogin($account);
$space1 = $this
->oaCreateNode(array(
'title' => 'Space A',
'type' => 'oa_space',
'uid' => $account->uid,
));
$team_a = $this
->oaCreateTeamWithUser(array(
'title' => 'Team A',
), array(
'access content',
), $space1);
$team_b = $this
->oaCreateTeamWithUser(array(
'title' => 'Team B',
), array(
'access content',
), $space1);
$not_in_team = $this
->oaCreateUser(array(
'access content',
), $space1);
$not_in_group = $this
->oaCreateUser(array(
'access content',
));
$group_permissions = array(
$team_a['team']->nid => array(
'oa_access_test' => array(
'access oa_access_test',
'administer oa_access_test',
),
),
$team_b['team']->nid => array(
'oa_access_test' => array(
'access oa_access_test',
),
),
);
oa_access_set_group_permissions($group_permissions);
$this
->assertFalse(oa_access($space1, 'access oa_access_test', $not_in_team));
$this
->assertFalse(oa_access($space1, 'administer oa_access_test', $not_in_team));
$this
->assertFalse(oa_access($space1, 'access oa_access_test', $not_in_group));
$this
->assertFalse(oa_access($space1, 'administer oa_access_test', $not_in_group));
$this
->assertTrue(oa_access($space1, 'access oa_access_test', $team_a['user']));
$this
->assertTrue(oa_access($space1, 'administer oa_access_test', $team_a['user']));
$this
->assertTrue(oa_access($space1, 'access oa_access_test', $team_b['user']));
$this
->assertFalse(oa_access($space1, 'administer oa_access_test', $team_b['user']));
$space2 = $this
->oaCreateNode(array(
'title' => 'Space B',
'type' => 'oa_space',
'uid' => $account->uid,
));
$this
->assertFalse(oa_access($space2, 'access oa_access_test', $team_a['user']));
$this
->assertFalse(oa_access($space2, 'administer oa_access_test', $team_a['user']));
$this
->assertFalse(oa_access($space2, 'access oa_access_test', $team_b['user']));
$this
->assertFalse(oa_access($space2, 'administer oa_access_test', $team_b['user']));
$this
->assertFalse(oa_access(NULL, 'access oa_access_test', $team_a['user']));
$this
->assertFalse(oa_access(NULL, 'administer oa_access_test', $team_a['user']));
$this
->assertFalse(oa_access(NULL, 'access oa_access_test', $team_b['user']));
$this
->assertFalse(oa_access(NULL, 'administer oa_access_test', $team_b['user']));
$this
->assertFalse(oa_access($space1, 'permission with all option for oa_access_test', $not_in_team));
$this
->assertFalse(oa_access($space1, 'permission with all option for oa_access_test', $not_in_group));
$this
->assertFalse(oa_access($space1, 'permission with all option for oa_access_test', $team_a['user']));
$this
->assertFalse(oa_access($space1, 'permission with all option for oa_access_test', $team_b['user']));
oa_access_set_group_permissions(array(
$space1->nid => array(
'oa_access_test' => array(
'permission with all option for oa_access_test',
),
),
));
drupal_static_reset('oa_access');
$this
->assertTrue(oa_access($space1, 'permission with all option for oa_access_test', $not_in_team));
$this
->assertFalse(oa_access($space1, 'permission with all option for oa_access_test', $not_in_group));
$this
->assertTrue(oa_access($space1, 'permission with all option for oa_access_test', $team_a['user']));
$this
->assertTrue(oa_access($space1, 'permission with all option for oa_access_test', $team_b['user']));
}