function SchemaDefinitionTest::testInvalidUniqueKeyForPartialLengthColumn

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Database/SchemaDefinitionTest.php \Drupal\Tests\Core\Database\SchemaDefinitionTest::testInvalidUniqueKeyForPartialLengthColumn()

Tests passing limited length columns to an unique key.

File

core/tests/Drupal/Tests/Core/Database/SchemaDefinitionTest.php, line 528

Class

SchemaDefinitionTest
Tests SchemaDefinition Column object validations.

Namespace

Drupal\Tests\Core\Database

Code

public function testInvalidUniqueKeyForPartialLengthColumn() : void {
  $this->expectException(SchemaDefinitionException::class);
  $this->expectExceptionMessage('Limited length columns not allowed in this context');
  $table = new Table(name: 'test', columns: [
    Column::text(name: 'id', length: 40, default: new StringValue('foo')),
  ], primaryKey: new PrimaryKey([
    'id',
  ]), uniqueKeys: [
    new UniqueKey(name: 'invalid', columns: [
      [
        'id',
        10,
      ],
    ]),
  ]);
  $this->assertInstanceOf(Table::class, $table);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.