This unfortunate SNAFU: http://drupal.org/node/208700 demonstrates again the need for unit tests for the filter module.

Deliverables:

Your overall task will be to create a set of tests that thoroughly tests the administrative interface of the filter module. This suite should be written as a single .test file and should achieve RTBC status.

Suggested tests/components to be written for this task:

1. Save all the original settings (e.g. you might even rename and duplicate the table) so you can revert to them.
2. admin/settings/filters change the default filter by POST. Check that the new default shows up and cannot be deleted.
3.admin/settings/filters/1/configure Add an additional tag, check that is shows up, and check that the filter cache is cleared
4 admin/settings/filters/1/order reorder the input formats by POST, and check that the changes are saved.
5. settings/filters/add add a new input format by POST and check that it is saved and has all selected options
6.settings/filters/delete/x check that the newly added format can be deleted
7. admin/settings/filters/2 allow authenticated users, log in as a normal user and check access to the filter.

Note, you can assume the default filtered and full HTML filters are 1 and 2 (though bonus points for checking or making it so). Revert to the original filters when you are done.

Your test should either work for Drupal 5.x as well as 6.x, or provide both 5.x and 6.x versions.

Note each of these 3 tests should include at least 3 to 8 assertions that are checked. Proper validation of your new tests will ideally include changing the Drupal core code to break the tested functionality and then confirming that your tests report a failure. Ideally, post each such change as a patch to help the reviewers.

Comments

pwolanin’s picture

Title: GHOP : write SimpleTests for filter module » GHOP #152: write SimpleTests for filter module
boombatower’s picture

Status: Active » Needs review
StatusFileSize
new6.28 KB
new5.84 KB

I got the 6.x test working fine, but 5.x doesn't want to work.

It doesn't seem like logout works, or that drupalGet correctly...I'm not exactly sure.

So i'm not sure what exactly to do with the 5.x test.

boombatower’s picture

StatusFileSize
new6.73 KB

I think I figured the stuff out. This test should work for both 6.x and 5.x

boombatower’s picture

StatusFileSize
new6.69 KB

Removed enabling of filter since it must be enabled for Drupal to run.

boombatower’s picture

StatusFileSize
new7.29 KB

Changes requested by pwolanin in IRC:

  • Order actually confirmed
  • URL filter check wasn't correct
pwolanin’s picture

Status: Needs review » Needs work

code style problems - use {} with all if/else statements. For example:

      if ($filter->delta == $second_filter || $filter->delta == $first_filter)
        $filters[] = $filter;

needs to be:

      if ($filter->delta == $second_filter || $filter->delta == $first_filter) {
        $filters[] = $filter;
      }
boombatower’s picture

Status: Needs work » Needs review
StatusFileSize
new7.3 KB

This should do it.

boombatower’s picture

StatusFileSize
new327 bytes
new7.71 KB

I made the following changes after talking with chx in IRC:

  • Cleaned up a few coding guideline issues
  • Clean up some code
  • Added test to make sure filter removes unwanted tags
  • Made a patch for 5.x simpletest framework to remove need to different url standard
chx’s picture

Note that the patch for D5 simpletest is submtited reversed. It also could use a $query = NULL parameter.

boombatower’s picture

StatusFileSize
new411 bytes

Here is the updated diff.

gribnif’s picture

StatusFileSize
new7.71 KB

This is a version of the tests, updated to work with HEAD. It accounts for the name change in the drupalPostRequest function, and changes in the submit button text. More unit tests to follow.

boombatower’s picture

Status: Needs review » Fixed

Committed.

In future this test will probably be made HEAD specific, removing all 5.x stuff.

@Gribnif: Thanks for updating test.

boombatower’s picture

Assigned: Unassigned » boombatower

Double post.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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