Commit 6eaa4d39 authored by alexpott's avatar alexpott

Issue #2381751 by hussainweb: Clean-up Book module test members - ensure...

Issue #2381751 by hussainweb: Clean-up Book module test members - ensure property definition and use of camelCase naming convention
parent 4d514be6
......@@ -36,21 +36,21 @@ class BookTest extends WebTestBase {
*
* @var object
*/
protected $book_author;
protected $bookAuthor;
/**
* A user with permission to view a book and access printer-friendly version.
*
* @var object
*/
protected $web_user;
protected $webUser;
/**
* A user with permission to create and edit books and to administer blocks.
*
* @var object
*/
protected $admin_user;
protected $adminUser;
protected function setUp() {
parent::setUp();
......@@ -59,9 +59,9 @@ protected function setUp() {
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', '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', 'administer book outlines', 'node test view', 'administer content types', 'administer site configuration'));
$this->bookAuthor = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books'));
$this->webUser = $this->drupalCreateUser(array('access printer-friendly version', 'node test view'));
$this->adminUser = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'node test view', 'administer content types', 'administer site configuration'));
}
/**
......@@ -69,7 +69,7 @@ protected function setUp() {
*/
function createBook() {
// Create new book.
$this->drupalLogin($this->book_author);
$this->drupalLogin($this->bookAuthor);
$this->book = $this->createBookNode('new');
$book = $this->book;
......@@ -100,12 +100,12 @@ function createBook() {
*/
function testEmptyBook() {
// Create a new empty book.
$this->drupalLogin($this->book_author);
$this->drupalLogin($this->bookAuthor);
$book = $this->createBookNode('new');
$this->drupalLogout();
// Log in as a user with access to the book outline and save the form.
$this->drupalLogin($this->admin_user);
$this->drupalLogin($this->adminUser);
$this->drupalPostForm('admin/structure/book/' . $book->id(), array(), t('Save book pages'));
$this->assertText(t('Updated book @book.', array('@book' => $book->label())));
}
......@@ -118,7 +118,7 @@ function testBook() {
$nodes = $this->createBook();
$book = $this->book;
$this->drupalLogin($this->web_user);
$this->drupalLogin($this->webUser);
// Check that book pages display along with the correct outlines and
// previous/next links.
......@@ -130,7 +130,7 @@ function testBook() {
$this->checkBookNode($nodes[4], NULL, $nodes[3], $book, FALSE, array($book));
$this->drupalLogout();
$this->drupalLogin($this->book_author);
$this->drupalLogin($this->bookAuthor);
/*
* Add Node 5 under Node 3.
* Book
......@@ -145,20 +145,20 @@ function testBook() {
$nodes[] = $this->createBookNode($book->id(), $nodes[3]->book['nid']); // Node 5.
$this->drupalLogout();
$this->drupalLogin($this->web_user);
$this->drupalLogin($this->webUser);
// Verify the new outline - make sure we don't get stale cached data.
$this->checkBookNode($nodes[3], array($nodes[5]), $nodes[2], $book, $nodes[5], array($book));
$this->checkBookNode($nodes[4], NULL, $nodes[5], $book, FALSE, array($book));
$this->drupalLogout();
// Create a second book, and move an existing book page into it.
$this->drupalLogin($this->book_author);
$this->drupalLogin($this->bookAuthor);
$other_book = $this->createBookNode('new');
$node = $this->createBookNode($book->id());
$edit = array('book[bid]' => $other_book->id());
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->drupalLogout();
$this->drupalLogin($this->web_user);
$this->drupalLogin($this->webUser);
// Check that the nodes in the second book are displayed correctly.
// First we must set $this->book to the second book, so that the
......@@ -168,7 +168,7 @@ function testBook() {
$this->checkBookNode($node, NULL, $other_book, $other_book, FALSE, array($other_book));
// Test that we can save a book programatically.
$this->drupalLogin($this->book_author);
$this->drupalLogin($this->bookAuthor);
$book = $this->createBookNode('new');
$book->save();
}
......@@ -317,7 +317,7 @@ function testBookExport() {
$nodes = $this->createBook();
// Login as web user and view printer-friendly version.
$this->drupalLogin($this->web_user);
$this->drupalLogin($this->webUser);
$this->drupalGet('node/' . $this->book->id());
$this->clickLink(t('Printer-friendly version'));
......@@ -358,7 +358,7 @@ function testBookExport() {
* Tests the functionality of the book navigation block.
*/
function testBookNavigationBlock() {
$this->drupalLogin($this->admin_user);
$this->drupalLogin($this->adminUser);
// Enable the block.
$block = $this->drupalPlaceBlock('book_navigation');
......@@ -381,7 +381,7 @@ function testBookNavigationBlock() {
* Tests the book navigation block when an access module is installed.
*/
function testNavigationBlockOnAccessModuleInstalled() {
$this->drupalLogin($this->admin_user);
$this->drupalLogin($this->adminUser);
$block = $this->drupalPlaceBlock('book_navigation', array('block_mode' => 'book pages'));
// Give anonymous users the permission 'node test view'.
......@@ -394,7 +394,7 @@ function testNavigationBlockOnAccessModuleInstalled() {
$this->createBook();
// Test correct display of the block to registered users.
$this->drupalLogin($this->web_user);
$this->drupalLogin($this->webUser);
$this->drupalGet('node/' . $this->book->id());
$this->assertText($block->label(), 'Book navigation block is displayed to registered users.');
$this->drupalLogout();
......@@ -414,7 +414,7 @@ function testNavigationBlockOnAccessModuleInstalled() {
function testBookDelete() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$nodes = $this->createBook();
$this->drupalLogin($this->admin_user);
$this->drupalLogin($this->adminUser);
$edit = array();
// Test access to delete top-level and child book nodes.
......@@ -440,7 +440,7 @@ function testBookDelete() {
* Tests node type changing machine name when type is a book allowed type.
*/
function testBookNodeTypeChange() {
$this->drupalLogin($this->admin_user);
$this->drupalLogin($this->adminUser);
// Change the name, machine name and description.
$edit = array(
'name' => 'Bar',
......@@ -537,7 +537,7 @@ public function testBookOrdering() {
$this->createBook();
$book = $this->book;
$this->drupalLogin($this->admin_user);
$this->drupalLogin($this->adminUser);
$node1 = $this->createBookNode($book->id());
$node2 = $this->createBookNode($book->id());
$pid = $node1->book['nid'];
......@@ -561,14 +561,14 @@ public function testBookOrdering() {
* Tests outline of a book.
*/
public function testBookOutline() {
$this->drupalLogin($this->book_author);
$this->drupalLogin($this->bookAuthor);
// Create new node not yet a book.
$empty_book = $this->drupalCreateNode(array('type' => 'book'));
$this->drupalGet('node/' . $empty_book->id() . '/outline');
$this->assertNoLink(t('Book outline'), 'Book Author is not allowed to outline');
$this->drupalLogin($this->admin_user);
$this->drupalLogin($this->adminUser);
$this->drupalGet('node/' . $empty_book->id() . '/outline');
$this->assertRaw(t('Book outline'));
$this->assertOptionSelected('edit-book-bid', 0, 'Node does not belong to a book');
......@@ -585,10 +585,10 @@ public function testBookOutline() {
$this->assertEqual($node->book['pid'], '0');
// Create new book.
$this->drupalLogin($this->book_author);
$this->drupalLogin($this->bookAuthor);
$book = $this->createBookNode('new');
$this->drupalLogin($this->admin_user);
$this->drupalLogin($this->adminUser);
$this->drupalGet('node/' . $book->id() . '/outline');
$this->assertRaw(t('Book outline'));
......@@ -639,7 +639,7 @@ public function testBookListing() {
$this->createBook();
// Must be a user with 'node test view' permission since node_access_test is installed.
$this->drupalLogin($this->web_user);
$this->drupalLogin($this->webUser);
// Load the book page and assert the created book title is displayed.
$this->drupalGet('book');
......@@ -655,7 +655,7 @@ public function testAdminBookListing() {
$this->createBook();
// Load the book page and assert the created book title is displayed.
$this->drupalLogin($this->admin_user);
$this->drupalLogin($this->adminUser);
$this->drupalGet('admin/structure/book');
$this->assertText($this->book->label(), 'The book title is displayed on the administrative book listing page.');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment