You are here

function BookAccessRuleTestCase::testBookOutlineAdministratorAccess in Book access 6.2

File

./book_access.test, line 116

Class

BookAccessRuleTestCase

Code

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

  // Create the test books.
  $this
    ->createBook($books, $nodes);
  $this
    ->createBook($books, $nodes);
  $this
    ->drupalLogin($this
    ->drupalCreateUser(array(
    'administer access of any books',
    '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 outline administrator user can view the book page %nid.', array(
      '%nid' => $nid,
    )))) {
      $this
        ->assertNoLink(t('Add child page'), t('The book outline 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 outline 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 outline administrator user cannot delete the book page %nid.', array(
        '%nid' => $nid,
      )));
      $this
        ->drupalGet('node/' . $nid . '/edit');
      $this
        ->assertResponse('403', t('The book outline administrator user cannot edit the book page %nid.', array(
        '%nid' => $nid,
      )));
      $this
        ->drupalGet('node/' . $nid . '/outline');
      $this
        ->assertResponse('403', t('The user %uid cannot edit the outline for the book page %nid.', array(
        '%nid' => $nid,
      )));
    }
  }
  $this
    ->drupalLogout();
}