function NonPublicSchemaTest::setUp
Same name in other branches
- 10 core/modules/pgsql/tests/src/Kernel/pgsql/NonPublicSchemaTest.php \Drupal\Tests\pgsql\Kernel\pgsql\NonPublicSchemaTest::setUp()
Overrides DriverSpecificKernelTestBase::setUp
File
-
core/
modules/ pgsql/ tests/ src/ Kernel/ pgsql/ NonPublicSchemaTest.php, line 36
Class
- NonPublicSchemaTest
- Tests schema API for non-public schema for the PostgreSQL driver.
Namespace
Drupal\Tests\pgsql\Kernel\pgsqlCode
protected function setUp() : void {
parent::setUp();
// Create a connection to the non-public schema.
$info = Database::getConnectionInfo('default');
$info['default']['schema'] = 'testing_fake';
Database::getConnection()->query('CREATE SCHEMA IF NOT EXISTS testing_fake');
Database::addConnectionInfo('default', 'testing_fake', $info['default']);
$this->testingFakeConnection = Database::getConnection('testing_fake', 'default');
$table_specification = [
'description' => 'Schema table description may contain "quotes" and could be long—very long indeed.',
'fields' => [
'id' => [
'type' => 'serial',
'not null' => TRUE,
],
'test_field' => [
'type' => 'int',
'not null' => TRUE,
],
],
'primary key' => [
'id',
],
];
$this->testingFakeConnection
->schema()
->createTable('faking_table', $table_specification);
$this->testingFakeConnection
->insert('faking_table')
->fields([
'id' => '1',
'test_field' => '123',
])
->execute();
$this->testingFakeConnection
->insert('faking_table')
->fields([
'id' => '2',
'test_field' => '456',
])
->execute();
$this->testingFakeConnection
->insert('faking_table')
->fields([
'id' => '3',
'test_field' => '789',
])
->execute();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.