You are here

public function ConnectionTest::testAccessDeniedException in Drupal driver for SQL Server and SQL Azure 4.2.x

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

Test AccessDeniedException is thrown.

File

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

Class

ConnectionTest
Tests of the sqlsrv database system.

Namespace

Drupal\Tests\sqlsrv\Kernel

Code

public function testAccessDeniedException() {
  $connection_array = [
    'driver' => 'sqlsrv',
    'database' => 'mydrupalsite',
    'username' => 'sa',
    'password' => 'incorrect!',
    'host' => 'localhost',
    'schema' => 'dbo',
    'cache_schema' => 'true',
  ];
  $this
    ->expectException(DatabaseAccessDeniedException::class);

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