? book_test_0.patch
? book_update.patch
? sites/default/files
? sites/default/settings.php
Index: modules/book/book.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.test,v
retrieving revision 1.9
diff -r1.9 book.test
24c24
<     $book_author = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books'));
---
>     $book_author = $this->drupalCreateUser(array('create new books', 'create book content', 'add content to books', 'edit any book content', 'administer book outlines', 'access administration pages', 'administer site configuration', 'administer nodes', 'administer content types')); 
40a41
>      *  |- Node 5
47a49
>     $nodes[] = $this->createBookNode($book->nid); // Node 5
68a71,127
>     
>     // Update checks, move the book structure to this.
>     // Book
>     // |- Node 0
>     //  |- Node 1
>     //    | - Node 2
>     //      | - Node 3
>     // | - Node 4
>     // | - Node 5
>     $this->drupalLogin($book_author);
>     $nodes[2] = $this->updateBookNode($book->nid, $nodes[2]->nid, $nodes[1]->book['mlid']);
>     $nodes[3] = $this->updateBookNode($book->nid, $nodes[3]->nid, $nodes[2]->book['mlid']);
>     $this->drupalLogout();
>     
>     // Check to ensure the updates worked.
>     $this->drupalLogin($web_user);
>     $this->checkBookNode($nodes[1], array($nodes[2]), FALSE, $nodes[0], FALSE);
>     $this->checkBookNode($nodes[2], array($nodes[3]), FALSE, $nodes[1], FALSE);
>     $this->checkBookNode($nodes[3], NULL, FALSE, $nodes[2], FALSE);
>     $this->drupalLogout();
>         
>     // Set another content type as a book page.
>     $this->drupalLogin($book_author);
>     $type = $this->drupalCreateContentType();
>     $edit = array(
>       'book_allowed_types[' . $type->type . ']' => $type->type,
>     );
>     $this->drupalPost('admin/content/book/settings', $edit, t('Save configuration'));
>     $nodes[] = $this->createBookNode($book->nid, $book_node, $type->type); // Node 6
>     $this->drupalLogout();
>     
>     // Check to see that the new content type was added as a book page.
>     $this->drupalLogin($web_user);
>     $this->checkBookNode($nodes[6], NULL, FALSE, $book, FALSE);
>     $this->drupalLogout();
>     
>     // Make articles the default book type.
>     $this->drupalLogin($book_author);
>     $edit = array('book_child_type' => $type->type);
>     $this->drupalPost('admin/content/book/settings', $edit, t('Save configuration'));
>     $this->drupalGet('node/' . $nodes[6]->nid);
>     $this->clickLink(t('Add child page'));
>     $this->assertText(t("Create !title", array('!title' => $type->name)), t("Default child page type correctly set"));
>     
>     // Try to delete a book page from a book.
>     node_delete($nodes[0]->nid);
>     $this->drupalLogout();
>    
>     // Check that the structure got reorganized.
>     $this->drupalLogin($web_user);
>     $this->drupalGet('node/'. $node[0]->nid);
>     $this->checkBookNode($nodes[1], array($nodes[2]), $book, FALSE, FALSE);
>     $this->checkBookNode($nodes[2], array($nodes[3]), FALSE, $nodes[1], FALSE);
>     $this->checkBookNode($nodes[3], NULL, FALSE, $nodes[2], FALSE);
>     $this->checkBookNode($nodes[4], NULL, FALSE, $book, $nodes[5]);
>     $this->checkBookNode($nodes[5], NULL, $nodes[4], $book, $nodes[6]);
>     $this->checkBooknode($nodes[6], NULL, $nodes[5], $book, FALSE);
168c227
<   function createBookNode($book_nid, $parent = NULL) {
---
>   function createBookNode($book_nid, $parent = NULL, $type = 'book') {
170a230,231
>     // Replace the underscores for the correct node/add path.
>     $type = str_replace('_', '-', $type);
177c238
<       $this->drupalPost('node/add/book', $edit, t('Change book (update list of parents)'));
---
>       $this->drupalPost('node/add/' . $type, $edit, t('Change book (update list of parents)'));
183c244
<       $this->drupalPost('node/add/book', $edit, t('Save'));
---
>       $this->drupalPost('node/add/'. $type, $edit, t('Save'));
192a254,274
> 
>   /**
>    * Update a book node.
>    *
>    * @param integer $book_nid Book node id.
>    * @param integer $nid Book page nid.
>    * @param integer $parent Parent book reference id.
>    */
>   function updateBookNode($book_nid, $nid, $parent = NULL) {
>     // Set update parameters.
>     $edit = array();
>     $edit['book[bid]'] = $book_nid;
>     if ($parent !== NULL) {
>       $edit['book[plid]'] = $parent;
>     }
>     $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save'));
>     // Check to make sure the book node was updated.
>     $node = node_load($nid);
>     $this->assertNotNull(($node === FALSE ? NULL : $node), t('Book node found in database.'));
>     return $node;
>   }
