1 book.test BookTestCase::testBook()

Tests book functionality through node interfaces.

File

core/modules/book/tests/book.test, line 90
Tests for book.module.

Class

BookTestCase
Tests the functionality of the Book module.

Code

function testBook() {
  // Create new book.
  $nodes = $this->createBook();
  $book = $this->book;

  $this->backdropLogin($this->web_user);

  // Check that book pages display along with the correct outlines and
  // previous/next links.
  $this->checkBookNode($book, array($nodes[0], $nodes[3], $nodes[4]), FALSE, FALSE, $nodes[0], array());
  $this->checkBookNode($nodes[0], array($nodes[1], $nodes[2]), $book, $book, $nodes[1], array($book));
  $this->checkBookNode($nodes[1], NULL, $nodes[0], $nodes[0], $nodes[2], array($book, $nodes[0]));
  $this->checkBookNode($nodes[2], NULL, $nodes[1], $nodes[0], $nodes[3], array($book, $nodes[0]));
  $this->checkBookNode($nodes[3], NULL, $nodes[2], $book, $nodes[4], array($book));
  $this->checkBookNode($nodes[4], NULL, $nodes[3], $book, FALSE, array($book));

  $this->backdropLogout();

  // Create a second book, and move an existing book page into it.
  $this->backdropLogin($this->book_author);
  $other_book = $this->createBookNode('new');
  $node = $this->createBookNode($book->nid);
  $edit = array('book[bid]' => $other_book->nid);
  $this->backdropPost('node/' . $node->nid . '/edit', $edit, t('Save'));

  $this->backdropLogout();
  $this->backdropLogin($this->web_user);

  // Check that the nodes in the second book are displayed correctly.
  // First we must set $this->book to the second book, so that the
  // correct regex will be generated for testing the outline.
  $this->book = $other_book;
  $this->checkBookNode($other_book, array($node), FALSE, FALSE, $node, array());
  $this->checkBookNode($node, NULL, $other_book, $other_book, FALSE, array($other_book));
}