In DrupalTestCase::assert, a db_insert() is done without special try/catch handler, even though the $db_prefix is temporarily set to the non-testing database. If an exception is thrown by db_insert(), the exception-handling mechanism proceeds without the $db_prefix set correctly, resulting an a final, incomprehensible result, because the exception handler triggers on $db_prefix.
What I did: Made a stupid error in a test (left out the t())
$this->assertText('Saved @name configuration.', array('@name' => $content_type_friendly));
What happened: I got a fatal out of the simpletest batch with
An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: /batch?id=21&op=do StatusText: OK ResponseText: {"status":true,"percentage":"100","message":"Processed test 1 of 1 - \u003cem class=\"placeholder\"\u003eField Example Tests\u003c\/em\u003e.\u003cdiv class=\"simpletest-fail\"\u003eOverall results: 20 passes, 8 fails, 1 exception, and 7 debug messages\u003c\/div\u003e\u003cdiv class=\"item-list\"\u003e\u003cul\u003e\u003cli class=\"first last\"\u003e\u003cdiv class=\"simpletest-fail\"\u003eField Example Tests: 20 passes, 8 fails, 1 exception, and 7 debug messages\u003c\/div\u003e\u003c\/li\u003e\n\u003c\/ul\u003e\u003c\/div\u003e"}Uncaught exception thrown in shutdown function.PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'd7git.search_total' doesn't exist: SELECT t.word AS realword, i.word FROM {search_total} t LEFT JOIN {search_index} i ON t.word = i.word WHERE i.word IS NULL; Array ( ) in search_update_totals() (line 411 of /home/rfay/workspace/d7git/modules/search/search.module).
because the non-testing (host) system doesn't even have search module enabled.
What I expected instead: Some kind of a rational failure.
The attached patch simply switches the $db_prefix back to what it is supposed to be before handling proceeds. The result is that Simpletest registers the full requisite information.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | drupal.simpletest_reset_current_db_818838_04.patch | 999 bytes | rfay |
| #1 | Screenshot-Test result | d7git.l - Mozilla Firefox.png | 59.52 KB | rfay |
| drupal.simpletest_reset_current_db.patch | 1.26 KB | rfay |
Comments
Comment #1
rfayThe attached shows the exception handling in Simpletest *with* the patch.
Comment #2
rfayComment #3
dries commentedI don't understand why we assign this to $x. Debugging left-over?
Comment #4
rfayAh, but you *do* understand. Debugging of course. Good eye.
Comment #6
aspilicious commented#4: drupal.simpletest_reset_current_db_818838_04.patch queued for re-testing.
Comment #7
rfayThe "can't drop database" is plaguing DamZ's fine testing server. I just reset it, but will see if there's anything we can actually do about it.
Comment #8
rfay#4: drupal.simpletest_reset_current_db_818838_04.patch queued for re-testing.