function ConnectionTest::testNoQueriesOnConnect

Tests that no queries are executed when opening a connection.

The client encoding is set through the DSN in ::open(), as part of the connection startup packet, so constructing the connection must not send any statement (an extra round trip) to the database.

File

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

Class

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

Namespace

Drupal\Tests\pgsql\Unit

Code

public function testNoQueriesOnConnect() : void {
  $pdo = $this->createMock(Pgsql::class);
  $pdo->expects($this->never())
    ->method('exec');
  $pdo->expects($this->never())
    ->method('query');
  $pdo->expects($this->never())
    ->method('prepare');
  new Connection($pdo, []);
}

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