function SchemaUniquePrefixedKeysIndexTestBase::checkUniqueConstraintException
Same name in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Database/SchemaUniquePrefixedKeysIndexTestBase.php \Drupal\KernelTests\Core\Database\SchemaUniquePrefixedKeysIndexTestBase::checkUniqueConstraintException()
Verifies that inserting the same value/prefix twice causes an exception.
Parameters
string $table: The table to insert into.
string $column: The column on that table that has a UNIQUE index. If prefix lengths are accepted for UNIQUE keys on the current database, the prefix length for the field is expected to be set to 10 characters.
4 calls to SchemaUniquePrefixedKeysIndexTestBase::checkUniqueConstraintException()
- SchemaUniquePrefixedKeysIndexTestBase::testAddField in core/
tests/ Drupal/ KernelTests/ Core/ Database/ SchemaUniquePrefixedKeysIndexTestBase.php - Tests adding a new field with UNIQUE key.
- SchemaUniquePrefixedKeysIndexTestBase::testAddUniqueKey in core/
tests/ Drupal/ KernelTests/ Core/ Database/ SchemaUniquePrefixedKeysIndexTestBase.php - Tests adding a UNIQUE key to an existing table.
- SchemaUniquePrefixedKeysIndexTestBase::testChangeField in core/
tests/ Drupal/ KernelTests/ Core/ Database/ SchemaUniquePrefixedKeysIndexTestBase.php - Tests changing a field to add a UNIQUE key.
- SchemaUniquePrefixedKeysIndexTestBase::testCreateTable in core/
tests/ Drupal/ KernelTests/ Core/ Database/ SchemaUniquePrefixedKeysIndexTestBase.php - Tests UNIQUE keys put directly on the table definition.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ SchemaUniquePrefixedKeysIndexTestBase.php, line 109
Class
- SchemaUniquePrefixedKeysIndexTestBase
- Tests adding UNIQUE keys to tables.
Namespace
Drupal\KernelTests\Core\DatabaseCode
protected function checkUniqueConstraintException(string $table, string $column) : void {
$this->connection
->insert($table)
->fields([
$column => '1234567890 foo',
])
->execute();
$this->expectException(DatabaseException::class);
$this->connection
->insert($table)
->fields([
$column => $this->columnValue,
])
->execute();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.