public function PostgresqlSchemaTest::testComputedConstraintName in Drupal 8
Tests whether the actual constraint name is correctly computed.
@covers ::constraintExists @dataProvider providerComputedConstraintName
Parameters
string $table_name: The table name the constrained column belongs to.
string $name: The constraint name.
string $expected: The expected computed constraint name.
File
- core/
tests/ Drupal/ Tests/ Core/ Database/ Driver/ pgsql/ PostgresqlSchemaTest.php, line 45
Class
- PostgresqlSchemaTest
- @coversDefaultClass \Drupal\Core\Database\Driver\pgsql\Schema @group Database
Namespace
Drupal\Tests\Core\Database\Driver\pgsqlCode
public function testComputedConstraintName($table_name, $name, $expected) {
$max_identifier_length = 63;
$schema = new Schema($this->connection);
$statement = $this
->createMock('\\Drupal\\Core\\Database\\StatementInterface');
$statement
->expects($this
->any())
->method('fetchField')
->willReturn($max_identifier_length);
$this->connection
->expects($this
->any())
->method('query')
->willReturn($statement);
$this->connection
->expects($this
->at(2))
->method('query')
->with("SELECT 1 FROM pg_constraint WHERE conname = '{$expected}'")
->willReturn($this
->createMock('\\Drupal\\Core\\Database\\StatementInterface'));
$schema
->constraintExists($table_name, $name);
}