function ConnectionTest::testInitCommandsOnConnect

Tests that init_commands are executed when opening a connection.

File

core/modules/pgsql/tests/src/Unit/ConnectionTest.php, line 39

Class

ConnectionTest
Tests Drupal\pgsql\Driver\Database\pgsql\Connection.

Namespace

Drupal\Tests\pgsql\Unit

Code

public function testInitCommandsOnConnect() : void {
  $pdo = $this->createMock(Pgsql::class);
  $pdo->expects($this->once())
    ->method('exec')
    ->with("SET timezone = 'UTC'");
  new Connection($pdo, [
    'init_commands' => [
      "SET timezone = 'UTC'",
    ],
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.