You are here

function BookModuleTestCase::checkBookNode in SimpleTest 6

Checks the outline of sub-pages; previous, up, and next; and check printer friendly version.

Parameters

Node $node Node to check.:

array $nodes Nodes that should be in outline.:

Node $previous Previous link node.:

Node $up Up link node.:

Node $next Next link node.:

1 call to BookModuleTestCase::checkBookNode()
BookModuleTestCase::testBook in tests/book_module.test
Test book funcitonality through node interfaces.

File

tests/book_module.test, line 72

Class

BookModuleTestCase

Code

function checkBookNode($node, $nodes, $previous = false, $up = false, $next = false) {
  static $number = 0;
  $this
    ->drupalGet('node/' . $node->nid);

  // check outline structure
  if ($nodes !== NULL) {
    $this
      ->assertPattern($this
      ->generateOutlinePattern($nodes), 'Node ' . $number . ' outline confirmed.');
  }
  else {
    $this
      ->assertNotNull(true, 'Node ' . $number . ' doesn\'t have outline.');
  }

  // check previous, up, and next links
  if ($previous) {
    $this
      ->assertWantedRaw(l('‹ ' . $previous->title, 'node/' . $previous->nid, array(
      'attributes' => array(
        'class' => 'page-previous',
        'title' => t('Go to previous page'),
      ),
    )), 'Prevoius page link found.');
  }
  if ($up) {
    $this
      ->assertWantedRaw(l('up', 'node/' . $up->nid, array(
      'attributes' => array(
        'class' => 'page-up',
        'title' => t('Go to parent page'),
      ),
    )), 'Up page link found.');
  }
  if ($next) {
    $this
      ->assertWantedRaw(l($next->title . ' ›', 'node/' . $next->nid, array(
      'attributes' => array(
        'class' => 'page-next',
        'title' => t('Go to next page'),
      ),
    )), 'Next page link found.');
  }

  // check printer friendly version
  $this
    ->drupalGet('book/export/html/' . $node->nid);
  $this
    ->assertText($node->title, 'Printer friendly title found.');
  $node->body = str_replace('<!--break-->', '', $node->body);
  $this
    ->assertWantedRaw(check_markup($node->body, $node->format), 'Printer friendly body found.');
  $number++;
}