You are here

function BookAccessRuleTestCase::testBookAdministratorAccess in Book access 6.2

File

./book_access.test, line 84

Class

BookAccessRuleTestCase

Code

function testBookAdministratorAccess() {
  $books = array();
  $nodes = array();

  // Create the test books.
  $this
    ->createBook($books, $nodes);
  $this
    ->createBook($books, $nodes);
  $this
    ->drupalLogin($this
    ->drupalCreateUser(array(
    'administer book access',
    'access content',
  )));

  // Verify if the user has access to the book pages.
  foreach ($nodes as $node) {
    $nid = $node->nid;
    $this
      ->drupalGet('node/' . $nid);
    if ($this
      ->assertResponse('200', t('The book access administrator user can view the book page %nid.', array(
      '%nid' => $nid,
    )))) {
      $this
        ->assertNoLink(t('Add child page'), t('The book access administrator user cannot add child pages to the book page %nid.', array(
        '%nid' => $nid,
      )));
      $this
        ->drupalGet('node/' . $nid . '/book_access');
      $this
        ->assertResponse('200', t('The book access administrator user can change the permission for the book page %nid.', array(
        '%nid' => $nid,
      )));
      $this
        ->drupalGet('node/' . $nid . '/delete');
      $this
        ->assertResponse('403', t('The book access administrator user cannot delete the book page %nid.', array(
        '%nid' => $nid,
      )));
      $this
        ->drupalGet('node/' . $nid . '/edit');
      $this
        ->assertResponse('403', t('The book access administrator user cannot edit the book page %nid.', array(
        '%nid' => $nid,
      )));
      $this
        ->drupalGet('node/' . $nid . '/outline');
      $this
        ->assertResponse('403', t('The book access administrator user cannot edit the outline for the book page %nid.', array(
        '%nid' => $nid,
      )));
    }
  }
  $this
    ->drupalLogout();
}