You are here

public function ConnectionTest::testRethrowPDOException in Drupal driver for SQL Server and SQL Azure 4.0.x

Same name and namespace in other branches
  1. 4.2.x tests/src/Kernel/ConnectionTest.php \Drupal\Tests\sqlsrv\Kernel\ConnectionTest::testRethrowPDOException()
  2. 3.1.x tests/src/Kernel/ConnectionTest.php \Drupal\Tests\sqlsrv\Kernel\ConnectionTest::testRethrowPDOException()
  3. 4.1.x tests/src/Kernel/ConnectionTest.php \Drupal\Tests\sqlsrv\Kernel\ConnectionTest::testRethrowPDOException()

Test PDOExceptions are rethrown.

File

tests/src/Kernel/ConnectionTest.php, line 74

Class

ConnectionTest
Tests of the sqlsrv database system.

Namespace

Drupal\Tests\sqlsrv\Kernel

Code

public function testRethrowPDOException() {
  $connection_array = [
    'driver' => 'sqlsrv',
    'database' => 'mydrupalsite',
    'username' => 'sa',
    'password' => 'Password12!',
    'host' => '10.0.0.42',
    'schema' => 'dbo',
    'cache_schema' => 'true',
  ];
  $this
    ->expectException(\PDOException::class);
  $this
    ->expectExceptionCode('HYT00');

  // Generate an exception
  $this->connection
    ->open($connection_array);
}