Following up with #2003986: help create simpletest file. where an initial version of Block Class Test Cases was committed (at f4474ec), it seems block_class.test could probably be further improved:

Test Cases: A few more things we might want to test:

  • Display of the block with CSS classes for anonymous user with and without Block Cache enabled.
  • Multiple class names, not just one.

In terms of code organization, as it is suggested at Organizing your test cases, it seems to be recommended to group in a base/utility Test Case class commonly used properties, setup or methods, and other test case classes could extend this common base class.
This would allow breaking into separate test cases the tests that we have currently in a single class.

Code clean-up:

  • All Doc comment blocks would need to be added, not to mention inline comments.
  • Assert messages would also have to be cleaned-up and edited.
  • Watch out for coding standards (such as lowerCamel naming of properties, methods, etc...).

 
Although we would be adding more tests, none of these changes or updates would add any new feature or functionnality to the module, however, it would certainly improve its code organization, readability, maintainability as well as its possibility to be further extended in the future.

Please let me know if you would have any questions, objections, comments, suggestions, recommendations or concerns on any aspects of this issue, I would be glad to provide more information or explain in more details.

Any questions, feedback, testing, changes, ideas or recommendations would be highly appreciated.
Thanks to all in advance.

Comments

DYdave’s picture

Status: Active » Fixed

Quick follow-up on this issue:

Major improvement of block_class.test:

  • Added a common base/utility class called BlockClassTestCase (extending DrupalWebTestCase) which now groups: setup method with module inclusion and user creation/login, $privilegedUser, $module, $delta and $permissions properties and methods.
  • Initial Test Case broken down in two classes:
    • BlockClassUpdateDisplayTestCase to test the update and display of the CSS class for a Block.
    • BlockClassPermissionTestCase to test specifically Block Class permissions.
  • All test case classes now extend common BlockClassTestCase base class.
  • Added a helper method to the base class: function assertUpdateBlockClass to update the CSS classes of a block and assert whether classes could be found when displayed
  • Removed from all test case classes all duplicate code accordingly.
  • Improved Doc comment blocks and inline comments.

I went ahead and committed the changes against the 7.x-2.x branch at a5d9310, followed by a minor commit at e6ae404 to fix a few coding standards errors introduced by the changes (white space, wrong indent or array too long).

Changes were back-ported to the 7.x-1.x branch at 2d79356.

I invite you to check the Tests results at anytime for any of the versions on the Block Class Automated Testing page.

I assume we would probably have to keep updating these tests in the future as more changes are made to the module, but for now, they would seem to already cover all the potential basic use cases (that we could think of) for the module in its current state .

Therefore, I allowed myself to mark this issue as fixed for now, but feel free to re-open it, or post a new ticket, at any time if you have any further objections with this issue or any of the related commits (a5d9310, e6ae404 or 2d79356 - we would surely be happy to hear your feedback).

Please let me know if you would have any further comments, feedback, questions, issues, objections, suggestions or concerns on the commit or this ticket in general, I would be glad to provide more information or explain in more details.

Thanks in advance to everyone for your testing, reviews, feedback and comments on this issue.
Cheers!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.