function DatabaseExceptionWrapperTest::testDatabaseExceptionWrapper

File

drupal/core/modules/system/lib/Drupal/system/Tests/Database/DatabaseExceptionWrapperTest.php, line 26
Contains Drupal\system\Tests\Database\DatabaseExceptionWrapperTest.

Class

DatabaseExceptionWrapperTest
Tests DatabaseExceptionWrapper thrown.

Namespace

Drupal\system\Tests\Database

Code

function testDatabaseExceptionWrapper() {
  $connection = Database::getConnection();
  $query = $connection
    ->prepare('bananas');
  try {
    $connection
      ->query($query);
    $this
      ->fail('The expected exception is not thrown.');
  } catch (DatabaseExceptionWrapper $e) {
    $this
      ->pass('The expected exception has been thrown.');
  }
}