summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-06-01 16:47:06 +0000
committerDries Buytaert <dries@buytaert.net>2009-06-01 16:47:06 +0000
commit00271e741f7d4825c76b1db21a7c55b250f209e9 (patch)
tree48a9ccf6abc25e43ba6a9049eae6245321b3ae1c /modules/simpletest/tests
parent8a0e218d32701d75c8ebb3c1d99b090f6f611f96 (diff)
downloadbrdo-00271e741f7d4825c76b1db21a7c55b250f209e9.tar.gz
brdo-00271e741f7d4825c76b1db21a7c55b250f209e9.tar.bz2
- Patch #458176 by c960657: improved exception handling in database layer.
Diffstat (limited to 'modules/simpletest/tests')
-rw-r--r--modules/simpletest/tests/database_test.test3
-rw-r--r--modules/simpletest/tests/error.test4
2 files changed, 5 insertions, 2 deletions
diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test
index 0263036ef..e5d5b3fe0 100644
--- a/modules/simpletest/tests/database_test.test
+++ b/modules/simpletest/tests/database_test.test
@@ -2446,6 +2446,9 @@ class DatabaseInvalidDataTestCase extends DatabaseTestCase {
$this->pass(t('The whole transaction is rolled back when a duplicate key insert occurs.'));
}
+ // 23000 means "Integrity constraint violation" according to ANSI SQL.
+ $this->assertEqual($e->errorInfo[0], '23000', t('Exception has proper SQLSTATE.'));
+
// Ensure the other values were not inserted.
$record = db_select('test')
->fields('test', array('name', 'age'))
diff --git a/modules/simpletest/tests/error.test b/modules/simpletest/tests/error.test
index 8584e2a40..ed430bfff 100644
--- a/modules/simpletest/tests/error.test
+++ b/modules/simpletest/tests/error.test
@@ -78,7 +78,7 @@ class DrupalErrorHandlerUnitTest extends DrupalWebTestCase {
);
$error_pdo_exception = array(
'%type' => 'PDOException',
- '%message' => 'SQLSTATE',
+ '%message' => 'SELECT * FROM bananas_are_awesome',
'%function' => 'error_test_trigger_pdo_exception()',
'%line' => 65,
'%file' => realpath('modules/simpletest/tests/error_test.module'),
@@ -89,7 +89,7 @@ class DrupalErrorHandlerUnitTest extends DrupalWebTestCase {
$this->drupalGet('error-test/trigger-pdo-exception');
// We cannot use assertErrorMessage() since the extact error reported
- // varies from database to database. Check for the error keyword 'SQLSTATE'.
+ // varies from database to database. Check that the SQL string is displayed.
$this->assertText($error_pdo_exception['%type'], t('Found %type in error page.', $error_pdo_exception));
$this->assertText($error_pdo_exception['%message'], t('Found %message in error page.', $error_pdo_exception));
$error_details = t('in %function (line %line of %file)', $error_pdo_exception);