public function DatabaseExceptionWrapperTest::testQueryThrowsDatabaseExceptionWrapperException in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Database/DatabaseExceptionWrapperTest.php \Drupal\system\Tests\Database\DatabaseExceptionWrapperTest::testQueryThrowsDatabaseExceptionWrapperException()
Tests the expected database exception thrown for inexistent tables.
File
- core/
modules/ system/ src/ Tests/ Database/ DatabaseExceptionWrapperTest.php, line 51 - Contains \Drupal\system\Tests\Database\DatabaseExceptionWrapperTest.
Class
- DatabaseExceptionWrapperTest
- Tests exceptions thrown by queries.
Namespace
Drupal\system\Tests\DatabaseCode
public function testQueryThrowsDatabaseExceptionWrapperException() {
$connection = Database::getConnection();
try {
$connection
->query('SELECT * FROM {does_not_exist}');
$this
->fail('Expected PDOException, none was thrown.');
} catch (DatabaseExceptionWrapper $e) {
$this
->pass('Expected DatabaseExceptionWrapper was thrown.');
} catch (\Exception $e) {
$this
->fail("Thrown exception is not a DatabaseExceptionWrapper:\n" . (string) $e);
}
}