summaryrefslogtreecommitdiff
path: root/modules/book
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-10-19 23:45:29 -0700
committerwebchick <webchick@24967.no-reply.drupal.org>2011-10-19 23:45:29 -0700
commitc9f793c456d30f76258d9de00023a9691d052925 (patch)
tree47ee44c53f049d383c1e0aac793577d9c9e1e236 /modules/book
parenta5fd8c9478e0a99c44a256cca6bd0b4cb5bb2ac5 (diff)
downloadbrdo-c9f793c456d30f76258d9de00023a9691d052925.tar.gz
brdo-c9f793c456d30f76258d9de00023a9691d052925.tar.bz2
Issue #766382 by neoglez, pebosi, andypost, sarah_p: Fixed Column 'nid' is ambiguous when using node access modules.
Diffstat (limited to 'modules/book')
-rw-r--r--modules/book/book.module2
-rw-r--r--modules/book/book.test57
2 files changed, 55 insertions, 4 deletions
diff --git a/modules/book/book.module b/modules/book/book.module
index beb17214c..595d87d2d 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -281,7 +281,7 @@ function book_block_view($delta = '') {
// Only display this block when the user is browsing a book.
$select = db_select('node', 'n')
->fields('n', array('title'))
- ->condition('nid', $node->book['bid'])
+ ->condition('n.nid', $node->book['bid'])
->addTag('node_access');
$title = $select->execute()->fetchField();
// Only show the block if the user has view access for the top-level node.
diff --git a/modules/book/book.test b/modules/book/book.test
index cc61778b9..6c351b8ec 100644
--- a/modules/book/book.test
+++ b/modules/book/book.test
@@ -24,12 +24,15 @@ 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->admin_user = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books', 'administer blocks'));
+ $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', 'administer permissions'));
}
/**
@@ -274,6 +277,12 @@ class BookTestCase extends DrupalWebTestCase {
$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>');
@@ -281,4 +290,46 @@ 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 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.'));
+
+ // 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.'));
+
+ // Create a book.
+ $this->createBook();
+
+ // 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.'));
+ }
}