You are here

protected function oa_sectionsNodeAccessBase::oaTestOaSectionAccessToSection in Open Atrium Core 7.2

Tests access to a specfic section.

Parameters

$space_text: Text to use for asserts.

$member_text: Text to use for asserts.

$section_text: Text to use for asserts.

$space: Space the section is part of.

$section: Section to test.

$account: Account to test access for.

$has_access: Whether $account should have access to this space.

1 call to oa_sectionsNodeAccessBase::oaTestOaSectionAccessToSection()
oa_sectionsNodeAccessBase::oaTestOaSectionAccess in modules/oa_sections/tests/oa_sectionsNodeAccessBase.test
Tests access to section nodes.

File

modules/oa_sections/tests/oa_sectionsNodeAccessBase.test, line 98
Base class for section access tests.

Class

oa_sectionsNodeAccessBase
@file Base class for section access tests.

Code

protected function oaTestOaSectionAccessToSection($space_text, $member_text, $section_text, $space, $section, $account, $has_access) {
  if ($account->uid) {
    $this
      ->drupalLogin($account);
  }
  else {
    $this
      ->drupalLogout();
  }

  // Test node_access directly and viewing section page.
  $this
    ->drupalGet('node/' . $section->nid);
  if ($has_access) {
    $this
      ->assertTrue(node_access('view', $section, $account), t('@member has view access to @section section for @space', array(
      '@space' => $space_text,
      '@member' => $member_text,
      '@section' => $section_text,
    )));
    $this
      ->assertResponse(200, t('@member can view @section section for @space', array(
      '@space' => $space_text,
      '@member' => $member_text,
      '@section' => $section_text,
    )));
  }
  else {
    $this
      ->assertFalse(node_access('view', $section, $account), t('@member does not have view access to @section section for @space', array(
      '@space' => $space_text,
      '@member' => $member_text,
      '@section' => $section_text,
    )));
    $this
      ->assertResponse(403, t('@member cannot view @section section for @space', array(
      '@space' => $space_text,
      '@member' => $member_text,
      '@section' => $section_text,
    )));
  }

  // Test listing of sections (by viewing space homepage)
  $this
    ->drupalGet('node/' . $space->nid);
  if ($has_access) {
    $this
      ->assertText($section->title, t('@member can view @section section on @space homepage', array(
      '@space' => $space_text,
      '@member' => $member_text,
      '@section' => $section_text,
    )));
  }
  else {
    $this
      ->assertNoText($section->title, t('@member cannot view @section section on @space homepage', array(
      '@space' => $space_text,
      '@member' => $member_text,
      '@section' => $section_text,
    )));
  }
}