1 book.test BookTestCase::testBookNavigationBlock()

Tests the functionality of the book navigation block.

File

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

Class

BookTestCase
Tests the functionality of the Book module.

Code

function testBookNavigationBlock() {
  $this->backdropLogin($this->admin_user);

  // Add the block to the sidebar region in the default layout.
  $layout_name = 'default';
  $region = 'sidebar';
  $block = array(
    'module' => 'book',
    'delta' => 'navigation',
  );
  $block_title = $this->randomName(16);
  $edit = array(
    'region' => $region,
    'title' => $block_title,
    'title_display' => LAYOUT_TITLE_CUSTOM,
  );
  $this->backdropPost('admin/structure/layouts/manage/' . $layout_name . '/add-block/editor/' . $region . '/' . $block['module'] . ':' . $block['delta'], $edit, t('Add block'));
  $this->backdropPost('admin/structure/layouts/manage/' . $layout_name, array(), t('Save layout'));

  // Give anonymous users the permission 'node test view'.
  $edit = array();
  $edit['anonymous[node test view]'] = TRUE;
  $this->backdropPost('admin/config/people/permissions/anonymous', $edit, t('Save permissions'));
  $this->assertText(t('The changes have been saved.'), "Permission 'node test view' successfully assigned to anonymous users.");

  // Test correct display of the block.
  $nodes = $this->createBook();
  $this->backdropGet('user');
  $this->assertText($block_title, 'Book navigation block is displayed.');
  $this->assertText($this->book->title, format_string('Link to book root (@title) is displayed.', array('@title' => $nodes[0]->title)));
  $this->assertNoText($nodes[0]->title, 'No links to individual book pages are displayed.');
}