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/Unit/ConnectionTest.php \Drupal\Tests\pgsql\Unit\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
PostgreSQL-specific connection tests.
Attributes
#[Group('Database')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\pgsql\Kernel\pgsql\ConnectionTest extends \Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase
- class \Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ConnectionTest
File
-
core/
modules/ pgsql/ tests/ src/ Kernel/ pgsql/ ConnectionTest.php, line 17
Namespace
Drupal\Tests\pgsql\Kernel\pgsqlView source
class ConnectionTest extends DriverSpecificKernelTestBase {
/**
* Tests the client encoding is set to UTF8 when the connection is opened.
*
* The client encoding is set via the DSN in
* \Drupal\pgsql\Driver\Database\pgsql\Connection::open(), so it is part of
* the connection startup packet and no "SET NAMES" query is needed.
*/
public function testClientEncoding() : void {
$this->assertSame('UTF8', $this->connection
->query('SHOW client_encoding')
->fetchField());
// Ensure multi-byte UTF-8 data round trips intact.
$string = 'héllo wörld ✓ 漢字';
$this->assertSame($string, $this->connection
->query('SELECT :string::text', [
':string' => $string,
])
->fetchField());
// The client encoding in the DSN must take precedence over the
// PGCLIENTENCODING environment variable, which libpq would otherwise use
// as the default.
putenv('PGCLIENTENCODING=LATIN1');
try {
Database::addConnectionInfo('encoding_test', 'default', Database::getConnectionInfo()['default']);
$connection = Database::getConnection('default', 'encoding_test');
$this->assertSame('UTF8', $connection->query('SHOW client_encoding')
->fetchField());
} finally {
putenv('PGCLIENTENCODING');
Database::closeConnection('default', 'encoding_test');
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.