function NonPublicSchemaTest::testIndex
Same name in other branches
- 10 core/modules/pgsql/tests/src/Kernel/pgsql/NonPublicSchemaTest.php \Drupal\Tests\pgsql\Kernel\pgsql\NonPublicSchemaTest::testIndex()
@covers ::addIndex @covers ::indexExists @covers ::dropIndex
File
-
core/
modules/ pgsql/ tests/ src/ Kernel/ pgsql/ NonPublicSchemaTest.php, line 271
Class
- NonPublicSchemaTest
- Tests schema API for non-public schema for the PostgreSQL driver.
Namespace
Drupal\Tests\pgsql\Kernel\pgsqlCode
public function testIndex() : void {
$this->testingFakeConnection
->schema()
->addIndex('faking_table', 'test_field', [
'test_field',
], []);
$this->assertTrue($this->testingFakeConnection
->schema()
->indexExists('faking_table', 'test_field'));
$results = $this->testingFakeConnection
->query("SELECT * FROM pg_indexes WHERE indexname = :indexname", [
':indexname' => $this->testingFakeConnection
->getPrefix() . 'faking_table__test_field__idx',
])
->fetchAll();
$this->assertCount(1, $results);
$this->assertSame('testing_fake', $results[0]->schemaname);
$this->assertSame($this->testingFakeConnection
->getPrefix() . 'faking_table', $results[0]->tablename);
$this->assertStringContainsString('USING btree (test_field)', $results[0]->indexdef);
$this->testingFakeConnection
->schema()
->dropIndex('faking_table', 'test_field');
$this->assertFalse($this->testingFakeConnection
->schema()
->indexExists('faking_table', 'test_field'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.