You are here

function BookAccessRuleTestCase::testAuthorAccess in Book access 6.2

File

./book_access.test, line 55

Class

BookAccessRuleTestCase

Code

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

  // Create the test books.
  $this
    ->createBook($books, $nodes);
  $this
    ->createBook($books, $nodes);
  $this
    ->drupalLogin($this->author);

  // 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 author can view the book page %nid.', array(
      '%nid' => $nid,
    )))) {
      $this
        ->assertLink(t('Add child page'), 0, t('The author can add child pages to the book page %nid.', array(
        '%nid' => $nid,
      )));
      $this
        ->drupalGet('node/' . $nid . '/book_access');
      $this
        ->assertResponse('200', t('The author can change the permission for the book page %nid.', array(
        '%nid' => $nid,
      )));
      $this
        ->drupalGet('node/' . $nid . '/delete');
      $this
        ->assertResponse('403', t('The author cannot delete the book page %nid.', array(
        '%nid' => $nid,
      )));
      $this
        ->drupalGet('node/' . $nid . '/edit');
      $this
        ->assertResponse('200', t('The author can edit the book page %nid.', array(
        '%nid' => $nid,
      )));
      $this
        ->drupalGet('node/' . $nid . '/outline');
      $this
        ->assertResponse('403', t('The author cannot edit the outline for the book page %nid.', array(
        '%nid' => $nid,
      )));
    }
  }
  $this
    ->drupalLogout();
}