ConnectionTest.php
Same filename in this branch
- 11.x core/modules/sqlite/tests/src/Unit/ConnectionTest.php
- 11.x core/modules/mysql/tests/src/Unit/ConnectionTest.php
- 11.x core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php
- 11.x core/modules/mysqli/tests/src/Kernel/mysqli/ConnectionTest.php
- 11.x core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
- 11.x core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
- 11.x core/modules/pgsql/tests/src/Kernel/pgsql/ConnectionTest.php
Same filename and directory in other branches
- 10 core/modules/sqlite/tests/src/Kernel/sqlite/ConnectionTest.php
- 8.9.x core/tests/Drupal/Tests/Core/Database/Driver/sqlite/ConnectionTest.php
- 10 core/modules/sqlite/tests/src/Unit/ConnectionTest.php
- 10 core/modules/mysql/tests/src/Unit/ConnectionTest.php
- 10 core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php
- 10 core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
- 10 core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
- 9 core/modules/sqlite/tests/src/Unit/ConnectionTest.php
- 9 core/modules/mysql/tests/src/Unit/ConnectionTest.php
- 9 core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php
- 9 core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
- 9 core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
- 8.9.x core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
- 8.9.x core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
- main core/modules/sqlite/tests/src/Unit/ConnectionTest.php
- main core/modules/mysql/tests/src/Unit/ConnectionTest.php
- main core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php
- main core/modules/mysqli/tests/src/Kernel/mysqli/ConnectionTest.php
- main core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
- main core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
Namespace
Drupal\Tests\pgsql\UnitFile
-
core/
modules/ pgsql/ tests/ src/ Unit/ ConnectionTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\pgsql\Unit;
use Drupal\pgsql\Driver\Database\pgsql\Connection;
use Drupal\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use Pdo\Pgsql;
/**
* Tests Drupal\pgsql\Driver\Database\pgsql\Connection.
*/
class ConnectionTest extends UnitTestCase {
/**
* 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.
*/
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, []);
}
/**
* Tests that init_commands are executed when opening a connection.
*/
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'",
],
]);
}
}
Classes
| Title | Deprecated | Summary |
|---|---|---|
| ConnectionTest | Tests Drupal\pgsql\Driver\Database\pgsql\Connection. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.