public function PostgresqlSchemaTest::testComputedConstraintName in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlSchemaTest.php \Drupal\Tests\Core\Database\Driver\pgsql\PostgresqlSchemaTest::testComputedConstraintName()
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 49 - Contains \Drupal\Tests\Core\Database\Driver\pgsql\PostgresqlSchemaTest.
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
->getMock('\\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
->getMock('\\Drupal\\Core\\Database\\StatementInterface'));
$schema
->constraintExists($table_name, $name);
}