BookTestCase::testBookNavigationBlock

7 book.test BookTestCase::testBookNavigationBlock()
8 book.test BookTestCase::testBookNavigationBlock()

Tests the functionality of the book navigation block.

File

modules/book/book.test, line 266
Tests for book.module.

Code

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

  // Set block title to confirm that the interface is available.
  $block_title = $this->randomName(16);
  $this->drupalPost('admin/structure/block/manage/book/navigation/configure', array('title' => $block_title), t('Save block'));
  $this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));

  // Set the block to a region to confirm block is available.
  $edit = array();
  $edit['blocks[book_navigation][region]'] = 'footer';
  $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
  $this->assertText(t('The block settings have been updated.'), t('Block successfully move to footer region.'));

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

  // Test correct display of the block.
  $nodes = $this->createBook();
  $this->drupalGet('<front>');
  $this->assertText($block_title, t('Book navigation block is displayed.'));
  $this->assertText($this->book->title, t('Link to book root (@title) is displayed.', array('@title' => $nodes[0]->title)));
  $this->assertNoText($nodes[0]->title, t('No links to individual book pages are displayed.'));
}
Login or register to post comments