Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Need to test:
Book html exports.
Attempting to export a book page in an unknown format.
Attempting to view exported book pages as an unprivileged user.
Comment | File | Size | Author |
---|---|---|---|
#21 | book.test.patch | 4.58 KB | paulmckibben |
#20 | book.test.patch | 15.45 KB | mtift |
#19 | book.test.patch | 4.73 KB | paulmckibben |
#13 | book-step-1.png | 114.21 KB | Francewhoa |
#13 | book-step-2.png | 50.24 KB | Francewhoa |
Comments
Comment #1
paulmckibbenAs part of the DrupalCon DC code sprint, I'm writing my very first test. Please be lenient on me! :)
Comment #2
paulmckibbenThe attached patch adds a new test method, testBookExport(), to the existing BookTestCase class. This method:
- creates a book with a hierarchy of pages
- verifies the book can be exported to html
- verifies that the book cannot be exported to another format (tested using path book/export/foobar/$nid)
- verifies that a user without the 'access printer-friendly version' privilege cannot export the book to html
Comment #3
mr.baileysThanks for this patch!
Reviewing the patch, here are my comments:
You can just logout and use the anonymous user (saves some cycles when running tests). I made the same mistake recently when working on one of my first tests.
$this->clickLink(...)
to get to the printer-friendly page?$this->assertText($node->title, t('Printer friendly title found.'));
I think something like "Node title found in printer friendly version" is better (as there is no such thing as a printer friendlly title for nodes). Same goes for the "printer friendly body".
Comment #4
mr.baileysBack to CNW for the coding standards items (#1, #2 and #4).
Comment #5
paulmckibbenThanks for your review and explanation, and I apologize for the newbie mistake of not reading the coding standards.
I have attached a new patch with your suggested changes.
Cheers,
Paul
Comment #6
paulmckibbenChanging to "code needs review" - hopefully for the last time. :)
Comment #8
paulmckibbenI know it's been awhile since DrupalCon DC. I'm here in the Paris code sprint and am working on it again.
Comment #9
paulmckibbenFields in core, and access to the node body, changed, which broke the previous patch. Here's a new patch.
Comment #10
FrancewhoaConfirming that patch in #9 can be apply without error. But could someone give me direction on how to test book html exports. I searched Drupal 7 admin & settings but found nothing. Do I need to install a contributed module?
Patch applied to Drupal 7 (September 9, 2009 - 05:11) fresh install.
Comment #11
paulmckibbenThanks, Onopoc,
An example of an export is the "Printer-friendly version" link. The "Printer-friendly version" link exports the book as a single HTML page. You will see that it points to the path: book/export/html/[nid]
As I understand the issue, the new test in this patch needs to make sure:
1. book/export/html/[nid] works for permitted roles
2. book/export/html/[nid] is blocked for roles that do not have permission
3. book/export/something-else/[nid] does not work
This new patch only adds test code, so there will be no change in the GUI. The reviewer will need to verify that the new test code actually achieves the above requirements.
Cheers,
Paul
Comment #12
FrancewhoaThanks for clarifying Paul.
Comment #13
FrancewhoaConfirming that patch in #9 works. Thanks pmckibben
The good news. I tested all that is describe in #11. And it works fine.
As for the bad news. On the
Printer-friendly version
The linkAdd new comment
should be hidden. Steps to reproduce the usability issue:1. Create a book.
2. Add a comment to any page of the book.
3. View the book. Then click on
Printer-friendly version
button.4. The issue is on this page. The HTML link
Add new comment
is display on this page. Expected result is to hide this link. Usually aPrinter-friendly version
is strip of all navigation link/button. I don't see any point for end user to printAdd new comment
links. Find attached screenshots to clarify. What do you think?Tested with.
-Drupal 7 (September 9, 2009 - 05:11) fresh install.
-Garland theme.
-Three different roles :User #1 (Admin), Content Author, Anonymous. With various permissions.
Comment #14
FrancewhoaForgot to change status to 'needs work'.
Comment #15
paulmckibbenOnopoc,
Thanks for testing this patch, and I'm glad that you have found that it meets the requested functionality.
Since this issue is for adding a test to the test suite, and has nothing to do with the user interface, I think this should be considered "RTBC", and a new usability issue should be written for the "Add new comment" link. That way, this test can be committed to core, and a new issue will be in place to track the problem you found with the "Add new comment" link.
Would that be ok with you?
Thanks,
Paul
Comment #16
Francewhoa@Paul: Thanks for pointing this out. I'll let someone review the test for the test suite. I don't know how to do that yet.
Ok with me about the issue. I have opened a new issue at http://drupal.org/node/583576
Comment #18
sun.core CreditAttribution: sun.core commentedTests don't qualify as critical.
Comment #19
paulmckibbenIn grand DrupalCon code sprint tradition, I'm back on this! Here's a new patch correcting the test failures of the previous patch.
Comment #20
mtiftI applied the patch, ran it, and everything appears to be working correctly. I simply added a doc block to explain the function ('Tests book export ("printer-friendly version") functionality'). If I formatted my patch incorrectly I apologize.
Comment #21
paulmckibbenRe-generating mtift's patch (he patched the patch file, not the code).
Per our discussion, we both believe this is RTBC.
Comment #22
webchickWow, this is a great clean-up patch, folks! :D
Committed to HEAD!