Multiple test functions and db_prefixing cause error
boombatower - March 27, 2008 - 22:35
| Project: | SimpleTest |
| Version: | 7.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | boombatower |
| Status: | closed |
Description
When running multiple test functions within a class something isn't working correctly so that test fails horribly. If the test functions are run individual everything works. I'm guessing this is why most the tests fail, as they used to work.
This is a very hard to catch/debug error. Chx and I have been trying to figure this out with little luck.
So far the only thing I can confirm is that if setUp and the db_prefix portion of tearDown are commented out the tests work.
From the our best reasoning chx and I believe this has to do with a caching issue.

#1
We should consider running all tests with the batch API. This will prevent out of memory errors as well ( thats what i got when i ran all tests from within drush)
#2
@moshe weitzman: Looks like a possibility. This doesn't fix the db_prefixing issue, but could prove useful. If you would write a patch that would be great.
@all: Batch API Documentation
#3
After allot of time spent debugging this (and tearing out hair) I have discovered what I believe to be the issue.
$this->_modulesarray wasn't being reset and thus wasn't enabled repeat modules in the second test function. This, as you can imagine, creates havoc.The above was fixed with the addition of the following code:
<?php
function tearDown() {
...
$this->_logged_in = FALSE;
$this->_modules = $this->_originalModules;
$this->curlClose();
...
}
...
protected function curlClose() {
if (isset($this->ch)) {
curl_close($this->ch);
unset($this->ch);
}
}
?>
Although the fix is quiet simple, coming to this conclusion took many hours of painstaking debugging. Now that this is fixed SimpleTest should be able to reliably flush the database after each test function has run and I can move on the clean out the issue queue.
#4
very nice detective work, boombatower. thanks.
#5
Automatically closed -- issue fixed for two weeks with no activity.