? .buildpath
? .project
? .settings
? book.test.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.7
diff -u -p -r1.7 book.test
--- modules/book/book.test	23 Dec 2008 14:32:08 -0000	1.7
+++ modules/book/book.test	7 Mar 2009 18:14:13 -0000
@@ -3,6 +3,8 @@
 
 class BookTestCase extends DrupalWebTestCase {
   protected $book;
+  protected $book_author; //user with necessary permissions to author a book
+  protected $web_user; //user with permissions to view a book/access printer-friendly version
 
   function getInfo() {
     return array(
@@ -14,18 +16,18 @@ class BookTestCase extends DrupalWebTest
 
   function setUp() {
     parent::setUp('book');
+    
+    // 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'));
   }
-
+  
   /**
-   * Test book functionality through node interfaces.
+   * Create a book with a page hierarchy.
    */
-  function testBook() {
-    // Create users.
-    $book_author = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books'));
-    $web_user = $this->drupalCreateUser(array('access printer-friendly version'));
-
+  function createBook() {
     // Create new book.
-    $this->drupalLogin($book_author);
+    $this->drupalLogin($this->book_author);
 
     $this->book = $this->createBookNode('new');
     $book = $this->book;
@@ -47,6 +49,20 @@ class BookTestCase extends DrupalWebTest
     $nodes[] = $this->createBookNode($book->nid); // Node 4.
 
     $this->drupalLogout();
+    
+    return $nodes;
+  }
+
+  /**
+   * Test book functionality through node interfaces.
+   */
+  function testBook() {
+    $book_author = $this->book_author;
+    $web_user = $this->web_user;
+
+    // Create new book.
+    $nodes = $this->createBook();
+    $book = $this->book;
 
     // Check that book pages display.
     $this->drupalLogin($web_user);
@@ -171,6 +187,34 @@ class BookTestCase extends DrupalWebTest
 
     return $node;
   }
+  
+  function testBookExport() {
+    //create a book
+    $nodes = $this->createBook();
+    
+    //login as web user and view printer-friendly version
+    $this->drupalLogin($this->web_user);
+    $this->drupalGet('book/export/html/'.$this->book->nid);
+    
+    //make sure each part of the book is there
+    foreach($nodes as $node) {
+      $this->assertText($node->title, t('Printer friendly title found.'));
+      $node->body = str_replace('<!--break-->', '', $node->body);
+      $this->assertRaw(check_markup($node->body, $node->format), t('Printer friendly body found.'));
+    }
+    
+    //make sure we can't export an unsupported format
+    $this->drupalGet('book/export/foobar/'.$this->book->nid);
+    $this->assertResponse('404',t('Unsupported export format returned "not found".'));
+    
+    $this->drupalLogout();
+    
+    //make sure a user without the right privilege cannot view printer-friendly version
+    $this->drupalCreateUser();
+    $this->drupalGet('book/export/html/'.$this->book->nid);
+    $this->assertResponse('403',t('Unprivileged user properly forbidden.'));
+  }
+  
 }
 
 class BookBlockTestCase extends DrupalWebTestCase {
