This makes it impossible to write tests that use the ip2country module, because then the module gets installed for every test, which means the database will be populated equally many times.

This should be done *after* the module is installed. Not automatically, but through the config UI.

Comments

tr’s picture

Modules get installed only for each test case, right? Not for each test. A test case that installs ip2country should contain all tests related to the use of ip2country. How do you run tests if the database isn't populated?

wim leers’s picture

Simple: by inserting the data that is needed for the test. In my case, a single row is sufficient.

In any case, the choice should be left to the developer.

tr’s picture

What do you think about adding a flag in the Drupal DB (a row in the variable table, for instance) that the ip2country module can use to determine whether to load the data on install or not?

My concern is that most users expect the module to work when it is installed. If the data has to be manually loaded the first time, then I anticipate many support issues from people complaining the module doesn't work. This is by far the biggest use case. SimpleTest writers are going to be a minority, but they are better able to deal with special requirements than the average user. So requiring a variable to be set before installing this module from a test case seems to be only a small inconvenience. Not installing the data at all when the module is enabled poses a much bigger problem to the average user.

wim leers’s picture

Agreed :)

tr’s picture

Status: Active » Fixed

Took me longer than expected to get around to this :-(

Anyway, the change I suggested in #3 is now in the Drupal 6 AND the Drupal 7 branches of ip2country. The database will still be populated when the module is installed normally from the Drupal interface, but if you are using the module from a test case you can set the variable 'ip2country_populate_database_on_install' to FALSE and you'll get a clean database. See the Drupal 7 tests ip2country.test for an example of how to use this feature.

wim leers’s picture

Thanks! :)

Status: Fixed » Closed (fixed)

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