1 book.test BookTestCase::testNavigationBlockOnAccessModuleEnabled()

Tests the book navigation block when an access module is enabled.

File

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

Class

BookTestCase
Tests the functionality of the Book module.

Code

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

  // Set the block title.
  $block_title = $this->randomName(16);

  // 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,
    'block_settings[book_mode]' => 'book pages',
  );
  $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.");

  // Create a book.
  $this->createBook();

  // Test correct display of the block to registered users.
  $this->backdropLogin($this->web_user);
  $this->backdropGet('node/' . $this->book->nid);
  $this->assertText($block_title, 'Book navigation block is displayed to registered users.');
  $this->backdropLogout();

  // Test correct display of the block to anonymous users.
  $this->backdropGet('node/' . $this->book->nid);
  $this->assertText($block_title, 'Book navigation block is displayed to anonymous users.');
}