function SchemaDefinitionTest::testInvalidSerialForDefault

Tests Serial column.

File

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

Class

SchemaDefinitionTest
Tests SchemaDefinition Column object validations.

Namespace

Drupal\Tests\Core\Database

Code

public function testInvalidSerialForDefault() : void {
  $this->expectException(SchemaDefinitionException::class);
  $this->expectExceptionMessageIs('Cannot set a int default for column \'id\'');
  new Table(name: 'test', columns: [
    Column::create(name: 'id', type: ColumnType::Serial, default: new IntValue(1)),
    Column::varcharAscii(name: 'foo'),
  ], primaryKey: new PrimaryKey([
    'id',
  ]));
}

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