diff -u b/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test --- b/modules/simpletest/tests/database_test.test +++ b/modules/simpletest/tests/database_test.test @@ -3756,6 +3756,7 @@ $this->insertRow('row'); $this->executeDDLStatement(); + set_error_handler(array($this, 'rollBackWithoutTransactionErrorHandler')); try { // Rollback the outer transaction. $transaction->rollback(); @@ -3765,13 +3766,25 @@ } } - catch (Throwable $warning) { - $this->assertSame('Rollback attempted when there is no active transaction. This can cause data integrity issues.', $warning->getMessage()); + catch (Exception $e) { + $this->assertEqual('Rollback attempted when there is no active transaction.', $e->getMessage()); } + restore_error_handler(); unset($transaction); $this->assertRowPresent('row'); } } /** + * Special handling of "rollback without transaction" errors. + */ + public function rollBackWithoutTransactionErrorHandler($error_level, $message, $filename, $line) { + // Throw an exception if this is a "rollback without transaction" error. + if (strpos($message, 'Rollback attempted when there is no active transaction.') !== FALSE ) { + throw new Exception('Rollback attempted when there is no active transaction.'); + } + _drupal_error_handler($error_level, $message, $filename, $line); + } + + /** * Insert a single row into the testing table. */