function SchemaTest::testComputedConstraintName
Same name and namespace in other branches
- 11.x core/modules/pgsql/tests/src/Unit/SchemaTest.php \Drupal\Tests\pgsql\Unit\SchemaTest::testComputedConstraintName()
- 10 core/modules/pgsql/tests/src/Unit/SchemaTest.php \Drupal\Tests\pgsql\Unit\SchemaTest::testComputedConstraintName()
- 9 core/modules/pgsql/tests/src/Unit/SchemaTest.php \Drupal\Tests\pgsql\Unit\SchemaTest::testComputedConstraintName()
Tests whether the actual constraint name is correctly computed.
@legacy-covers ::constraintExists
Attributes
#[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/
modules/ pgsql/ tests/ src/ Unit/ SchemaTest.php, line 34
Class
Namespace
Drupal\Tests\pgsql\UnitCode
public function testComputedConstraintName(string $table_name, string $name, string $expected) : void {
$max_identifier_length = 63;
$connection = $this->createMock(Connection::class);
$connection->method('getConnectionOptions')
->willReturn([]);
$connection->method('getPrefix')
->willReturn('');
$statement = $this->createStub(StatementInterface::class);
$statement->method('fetchField')
->willReturn($max_identifier_length);
$matched_statement = $this->createStub(StatementInterface::class);
$connection->expects($this->exactly(2))
->method('query')
->willReturnCallback(function (string $query) use ($expected, $statement, $matched_statement) {
if ($query === 'SHOW max_identifier_length') {
return $statement;
}
$this->assertStringContainsString($expected, $query);
return $matched_statement;
});
$schema = new Schema($connection);
$schema->constraintExists($table_name, $name);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.