class ConnectionTest
Same name in this branch
- 11.x core/modules/sqlite/tests/src/Unit/ConnectionTest.php \Drupal\Tests\sqlite\Unit\ConnectionTest
- 11.x core/modules/mysql/tests/src/Unit/ConnectionTest.php \Drupal\Tests\mysql\Unit\ConnectionTest
- 11.x core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php \Drupal\Tests\mysql\Kernel\mysql\ConnectionTest
- 11.x core/modules/mysqli/tests/src/Kernel/mysqli/ConnectionTest.php \Drupal\Tests\mysqli\Kernel\mysqli\ConnectionTest
- 11.x core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php \Drupal\KernelTests\Core\Database\ConnectionTest
- 11.x core/tests/Drupal/Tests/Core/Database/ConnectionTest.php \Drupal\Tests\Core\Database\ConnectionTest
- 11.x core/modules/pgsql/tests/src/Kernel/pgsql/ConnectionTest.php \Drupal\Tests\pgsql\Kernel\pgsql\ConnectionTest
Same name and namespace in other branches
- 10 core/modules/sqlite/tests/src/Kernel/sqlite/ConnectionTest.php \Drupal\Tests\sqlite\Kernel\sqlite\ConnectionTest
- 8.9.x core/tests/Drupal/Tests/Core/Database/Driver/sqlite/ConnectionTest.php \Drupal\Tests\Core\Database\Driver\sqlite\ConnectionTest
- 10 core/modules/sqlite/tests/src/Unit/ConnectionTest.php \Drupal\Tests\sqlite\Unit\ConnectionTest
- 10 core/modules/mysql/tests/src/Unit/ConnectionTest.php \Drupal\Tests\mysql\Unit\ConnectionTest
- 10 core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php \Drupal\Tests\mysql\Kernel\mysql\ConnectionTest
- 10 core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php \Drupal\KernelTests\Core\Database\ConnectionTest
- 10 core/tests/Drupal/Tests/Core/Database/ConnectionTest.php \Drupal\Tests\Core\Database\ConnectionTest
- 9 core/modules/sqlite/tests/src/Unit/ConnectionTest.php \Drupal\Tests\sqlite\Unit\ConnectionTest
- 9 core/modules/mysql/tests/src/Unit/ConnectionTest.php \Drupal\Tests\mysql\Unit\ConnectionTest
- 9 core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php \Drupal\Tests\mysql\Kernel\mysql\ConnectionTest
- 9 core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php \Drupal\KernelTests\Core\Database\ConnectionTest
- 9 core/tests/Drupal/Tests/Core/Database/ConnectionTest.php \Drupal\Tests\Core\Database\ConnectionTest
- 8.9.x core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php \Drupal\KernelTests\Core\Database\ConnectionTest
- 8.9.x core/tests/Drupal/Tests/Core/Database/ConnectionTest.php \Drupal\Tests\Core\Database\ConnectionTest
- main core/modules/sqlite/tests/src/Unit/ConnectionTest.php \Drupal\Tests\sqlite\Unit\ConnectionTest
- main core/modules/mysql/tests/src/Unit/ConnectionTest.php \Drupal\Tests\mysql\Unit\ConnectionTest
- main core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php \Drupal\Tests\mysql\Kernel\mysql\ConnectionTest
- main core/modules/mysqli/tests/src/Kernel/mysqli/ConnectionTest.php \Drupal\Tests\mysqli\Kernel\mysqli\ConnectionTest
- main core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php \Drupal\KernelTests\Core\Database\ConnectionTest
- main core/tests/Drupal/Tests/Core/Database/ConnectionTest.php \Drupal\Tests\Core\Database\ConnectionTest
Tests Drupal\pgsql\Driver\Database\pgsql\Connection.
Attributes
#[CoversClass(Connection::class)]
#[Group('Database')]
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\RandomGeneratorTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\pgsql\Unit\ConnectionTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of ConnectionTest
File
-
core/
modules/ pgsql/ tests/ src/ Unit/ ConnectionTest.php, line 16
Namespace
Drupal\Tests\pgsql\UnitView source
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'",
],
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.