Download & Extend

GHOP #152: write SimpleTests for filter module

Project:SimpleTest
Version:6.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:boombatower
Status:closed (fixed)
Issue tags:GHOP

Issue Summary

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

#1

Title:GHOP : write SimpleTests for filter module» GHOP #152: write SimpleTests for filter module

GHOP issue: http://code.google.com/p/google-highly-open-participation-drupal/issues/...

#2

Status:active» needs review

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.

AttachmentSizeStatusTest resultOperations
filter_module6x.test_.txt5.84 KBIgnored: Check issue status.NoneNone
filter_module5x.test_.txt6.28 KBIgnored: Check issue status.NoneNone

#3

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

AttachmentSizeStatusTest resultOperations
filter_module.test_.txt6.73 KBIgnored: Check issue status.NoneNone

#4

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

AttachmentSizeStatusTest resultOperations
filter_module.test_.txt6.69 KBIgnored: Check issue status.NoneNone

#5

Changes requested by pwolanin in IRC:

  • Order actually confirmed
  • URL filter check wasn't correct
AttachmentSizeStatusTest resultOperations
filter_module.test_.txt7.29 KBIgnored: Check issue status.NoneNone

#6

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;
      }

#7

Status:needs work» needs review

This should do it.

AttachmentSizeStatusTest resultOperations
filter_module.test_.txt7.3 KBIgnored: Check issue status.NoneNone

#8

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
AttachmentSizeStatusTest resultOperations
filter_module.test_.txt7.71 KBIgnored: Check issue status.NoneNone
drupal_test_case.diff327 bytesIgnored: Check issue status.NoneNone

#9

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

#10

Here is the updated diff.

AttachmentSizeStatusTest resultOperations
drupal_test_case.diff411 bytesIgnored: Check issue status.NoneNone

#11

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.

AttachmentSizeStatusTest resultOperations
filter_module.test_.txt7.71 KBIgnored: Check issue status.NoneNone

#12

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.

#13

Assigned to:Anonymous» boombatower

Double post.

#14

Status:fixed» closed (fixed)

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

nobody click here