You are here

function BookModuleTestCase::testBook in SimpleTest 6

Test book funcitonality through node interfaces.

File

tests/book_module.test, line 23

Class

BookModuleTestCase

Code

function testBook() {

  // create users
  $book_author = $this
    ->drupalCreateUserRolePerm(array(
    'create new books',
    'create book content',
    'add content to books',
  ));
  $web_user = $this
    ->drupalCreateUserRolePerm(array(
    'access printer-friendly version',
  ));

  // create new book
  $this
    ->drupalLoginUser($book_author);
  $this->book = $this
    ->createBookNode('new');
  $book = $this->book;

  /*
   * add page hiearchy to book
   * Book
   *  |- Node 0
   *   |- Node 1
   *   |- Node 2
   *  |- Node 3
   *  |- Node 4
   */
  $nodes = array();
  $nodes[] = $this
    ->createBookNode($book->nid);

  // Node 0
  $nodes[] = $this
    ->createBookNode($book->nid, $nodes[0]->book['mlid']);

  // Node 1
  $nodes[] = $this
    ->createBookNode($book->nid, $nodes[0]->book['mlid']);

  // Node 2
  $nodes[] = $this
    ->createBookNode($book->nid);

  // Node 3
  $nodes[] = $this
    ->createBookNode($book->nid);

  // Node 4
  $this
    ->drupalGet('logout');

  // check to make sure that book pages display properly
  $this
    ->drupalLoginUser($web_user);
  $this
    ->checkBookNode($book, array(
    $nodes[0],
    $nodes[3],
    $nodes[4],
  ), false, false, $nodes[0]);
  $this
    ->checkBookNode($nodes[0], array(
    $nodes[1],
    $nodes[2],
  ), $book, $book, $nodes[1]);
  $this
    ->checkBookNode($nodes[1], NULL, $nodes[0], $nodes[0], $nodes[2]);
  $this
    ->checkBookNode($nodes[2], NULL, $nodes[1], $nodes[0], $nodes[3]);
  $this
    ->checkBookNode($nodes[3], NULL, $nodes[2], $book, $nodes[4]);
  $this
    ->checkBookNode($nodes[4], NULL, $nodes[3], $book, false);
}