You are here

function oa_sectionsAccess::test_oa_sectionsAccess in Open Atrium Core 7.2

File

modules/oa_sections/tests/oa_sectionsAccess.test, line 17
Tests permission inheritance for oa_subspaces

Class

oa_sectionsAccess
@file Tests permission inheritance for oa_subspaces

Code

function test_oa_sectionsAccess() {
  extract($this
    ->createOaSpaceAndUsers());
  $team = $this
    ->createNodeInOaSpace($space, array(
    'type' => 'oa_team',
    'uid' => $space_admin->uid,
    'field_oa_team_users' => array(
      LANGUAGE_NONE => array(
        array(
          'target_id' => $space_member->uid,
        ),
        array(
          'target_id' => $space_admin->uid,
        ),
      ),
    ),
  ));
  $space_member_2 = $this
    ->createUserInOaSpace($space);
  $non_member = $this
    ->drupalCreateUser();

  // Group that just $space_member is part of.
  $group = $this
    ->drupalCreateNode(array(
    'type' => 'oa_group',
  ));
  og_group('node', $group, array(
    'entity' => $space_member,
  ));

  // Test a public space.
  $this
    ->oaTestOaSectionAccess('a public space', $space, $space_admin, $space_member, $space_member_2, $non_member, $group, $team);

  // Test a private space.
  $space_private = $this
    ->drupalCreateNode(array(
    'type' => 'oa_space',
    'uid' => $space_admin->uid,
    'group_access' => array(
      LANGUAGE_NONE => array(
        array(
          'value' => 1,
        ),
      ),
    ),
  ));
  og_group('node', $space_private, array(
    'entity' => $space_member,
  ));
  og_group('node', $space_private, array(
    'entity' => $space_member_2,
  ));
  $this
    ->oaTestOaSectionAccess('a private space', $space_private, $space_admin, $space_member, $space_member_2, $non_member, $group);
}