Hi,
I've written tests for the Country Code module. All of the committed tests work bar one. This is the code snippet:
$this->changeCountryStatus('fr', TRUE); // Enable it.
$this->changeCountryStatus('fr', FALSE); // Disable it.
......
function changeCountryStatus($country_code, $status, $default = FALSE) {
// Check to make sure that country exists.
$this->drupalGet('admin/settings/country-code');
if (strpos($this->drupalGetContent(), 'enabled[' . $country_code . ']') == TRUE) {
$this->drupalPost(NULL, array('enabled[' . $country_code . ']' => $status), t('Save configuration'));
$country = country_code_country_load($country_code);
if ($default) {
$this->assertTrue($country['enabled'] == 1, $status ? t('Country successfully enabled.') : t('Country successfully not disabled.'));
}
else {
$this->assertTrue($country['enabled'] == $status, $status ? t('Country successfully enabled.') : t('Country successfully disabled.'));
}
}
}
The first time the changeCountryStatus() function is called, the tests pass. However the second time it fails. I couldn't figure out why, so I added a $this->assertTrue(false, $this->_content); to see what was the content being returned. This is what I got:
Fatal error: Call to undefined function country_code() in sites/default/modules/contrib-dev/country_code/country_code.admin.inc on line 113
The function country_code() is defined in country_code.inc which is included in country code's hook_boot() so I don't know why SimpleTest can't find this function. When I actually manually test the code myself, everything works fine.
It happens other times too. Simply changing the order of some of the function calls in testCountryCodeCountryAdmin() can make it happen for multiple tests.
I'm not sure what is happening. Don't suppose it's anything to do with caching? I'm not sure country_code_boot() is getting invoked on each page load.
All the code is checked into CVS if you want to verify this yourself.
Cheers,
Stella
Comments
Comment #1
boombatower commentedJust found this...still an issue?
Comment #2
stella commentedIt's no longer an issue, but I imagine that's because we merged the country_code.inc file into country_code.module. So the underlying problem may still exist, and is just no longer being triggered.
Comment #3
boombatower commentedI'll mark as fixed then, but if the issue pops up again please file in D7 core.