You are here

public function DbalConnectionKernelTest::testConnectionFactory in Dbal connection 8

Tests dbal_connection service and factory.

File

tests/src/Kernel/DbalConnectionKernelTest.php, line 32

Class

DbalConnectionKernelTest
Tests dbal_connection service.

Namespace

Drupal\Tests\dbal\Kernel

Code

public function testConnectionFactory() {
  $database = $this->container
    ->get('database');
  $connection = $this->container
    ->get('dbal_connection');
  $connection
    ->insert($database
    ->getFullQualifiedTableName('semaphore'), [
    'name' => 'dbal_test',
    'value' => 'dbal_test',
    'expire' => time(),
  ]);
  $this
    ->assertEquals('dbal_test', $database
    ->select('semaphore', 's')
    ->condition('name', 'dbal_test')
    ->fields('s', [
    'value',
  ])
    ->execute()
    ->fetchField());
}