From 6df047d3864bd483ae03e0c0fd61459290c10e61 Mon Sep 17 00:00:00 2001 From: neoglez Date: Fri, 14 Oct 2011 16:38:09 +0200 Subject: [PATCH] Issue 766382: Created test to hit book block on access modules enabled --- modules/book/book.test | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 42 insertions(+), 2 deletions(-) diff --git a/modules/book/book.test b/modules/book/book.test index cc61778..1a1aac3 100644 --- a/modules/book/book.test +++ b/modules/book/book.test @@ -24,11 +24,14 @@ class BookTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('book'); + parent::setUp(array('book', 'node_access_test')); + + // node_access_test requires a node_access_rebuild() + node_access_rebuild(); // Create users. $this->book_author = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books')); - $this->web_user = $this->drupalCreateUser(array('access printer-friendly version')); + $this->web_user = $this->drupalCreateUser(array('access printer-friendly version', 'node test view')); $this->admin_user = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books', 'administer blocks')); } @@ -281,4 +284,41 @@ class BookTestCase extends DrupalWebTestCase { $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.')); } + + /** + * Test the functionality of the book navigation block when an access module is enabled + */ + function testNavigationBlockOnAccessModuleEnabled() { + $this->drupalLogin($this->admin_user); + $edit = array(); + + // Set the block title + $block_title = $this->randomName(16); + $edit['title'] = $block_title; + + // Set block display to 'Show block only on book pages' + $edit['book_block_mode'] = 'book pages'; + $this->drupalPost('admin/structure/block/manage/book/navigation/configure', $edit, 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.')); + + // Create a book + $this->createBook(); + $this->drupalLogout(); + + // Test correct display of the block to registered users. + $this->drupalLogin($this->web_user); + $this->drupalGet('node/' . $this->book->nid); + $this->assertText($block_title, t('Book navigation block is displayed to registered users.')); + $this->drupalLogout(); + + // Test correct display of the block to anonymous users. + $this->drupalGet('node/' . $this->book->nid); + $this->assertText($block_title, t('Book navigation block is displayed to anonymous users.')); + } } -- 1.7.6.msysgit.0