1 book.test | protected BookTestCase::checkBookNode(Node $node, $nodes, $previous = FALSE, $up = FALSE, $next = FALSE, array $breadcrumb = array()) |
Checks the outline of sub-pages; previous, up, and next.
Also checks the printer friendly version of the outline.
Parameters
array|null $nodes: Nodes that should be in outline.
Node|false $previous: (optional) Previous link node. Defaults to FALSE.
Node|false $up: (optional) Up link node. Defaults to FALSE.
Node|false $next: (optional) Next link node. Defaults to FALSE.
array $breadcrumb: The nodes that should be displayed in the breadcrumb.
File
- core/
modules/ book/ tests/ book.test, line 160 - Tests for book.module.
Class
- BookTestCase
- Tests the functionality of the Book module.
Code
protected function checkBookNode(Node $node, $nodes, $previous = FALSE, $up = FALSE, $next = FALSE, array $breadcrumb = array()) {
// $number does not use backdrop_static as it should not be reset
// since it uniquely identifies each call to checkBookNode().
static $number = 0;
$this->backdropGet('node/' . $node->nid);
// Check outline structure.
if ($nodes !== NULL) {
$this->assertPattern($this->generateOutlinePattern($nodes), format_string('Node %number outline confirmed.', array('%number' => $number)));
}
else {
$this->pass(format_string('Node %number does not have outline.', array('%number' => $number)));
}
// Check previous, up, and next links.
if ($previous) {
$prev_link = '<a href="/node/' . $previous->nid . '" rel="prev" title="Go to previous page"><b>‹</b> ' . $previous->title . '</a>';
$this->assertRaw($prev_link, 'Previous page link found.');
}
if ($up) {
$up_link = '<a href="/node/' . $up->nid . '" title="Go to parent page">up</a>';
$this->assertRaw($up_link, 'Up page link found.');
}
if ($next) {
$next_link = '<a href="/node/' . $next->nid . '" rel="next" title="Go to next page">' . $next->title . ' <b>›</b></a>';
$this->assertRaw($next_link, 'Next page link found.');
}
// Compute the expected breadcrumb.
$expected_breadcrumb = array();
$expected_breadcrumb[] = url('');
foreach ($breadcrumb as $a_node) {
$expected_breadcrumb[] = url('node/' . $a_node->nid);
}
// Fetch links in the current breadcrumb.
$links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
$got_breadcrumb = array();
foreach ($links as $link) {
$got_breadcrumb[] = (string) $link['href'];
}
// Compare expected and got breadcrumbs.
$this->assertIdentical($expected_breadcrumb, $got_breadcrumb, 'The breadcrumb is correctly displayed on the page.');
$number++;
}