function SchemaDefinitionTest::testInvalidForeignKeyForMismatchingColumnCount
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Database/SchemaDefinitionTest.php \Drupal\Tests\Core\Database\SchemaDefinitionTest::testInvalidForeignKeyForMismatchingColumnCount()
Tests passing a non Column array member to Table::$columns.
File
-
core/
tests/ Drupal/ Tests/ Core/ Database/ SchemaDefinitionTest.php, line 128
Class
- SchemaDefinitionTest
- Tests SchemaDefinition Column object validations.
Namespace
Drupal\Tests\Core\DatabaseCode
public function testInvalidForeignKeyForMismatchingColumnCount() : void {
$this->expectException(SchemaDefinitionException::class);
$this->expectExceptionMessage('Mismatching count of columns for the \'user_id\' foreign key');
$table = new Table(name: 'test', description: 'Basic test table for the database unit tests.', columns: [
Column::serial(name: 'id'),
Column::varcharAscii(name: 'name', description: "A person's name", length: 255, notNull: TRUE, default: new StringValue(''), binary: TRUE),
], primaryKey: new PrimaryKey([
'id',
]), foreignKeys: [
new ForeignKey(name: 'user_id', foreignTable: 'test_users', columns: [
'id',
'name',
], foreignColumns: [
'id',
]),
]);
$this->assertInstanceOf(Table::class, $table);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.