function SchemaDefinitionTest::testInvalidSerialForGeneratedExpression

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

Tests Serial column.

File

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

Class

SchemaDefinitionTest
Tests SchemaDefinition Column object validations.

Namespace

Drupal\Tests\Core\Database

Code

public function testInvalidSerialForGeneratedExpression() : void {
  $this->expectException(SchemaDefinitionException::class);
  $this->expectExceptionMessage('Cannot set \'generatedExpression\' for serial column \'id\'');
  new Table(name: 'test', columns: [
    Column::generated(name: 'id', type: ColumnType::Serial, expression: new GeneratedColumnExpression('1 + 1'), storage: GeneratedColumnStorage::Virtual),
  ], primaryKey: new PrimaryKey([
    'id',
  ]));
}

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