function SchemaDefinitionTest::testFloatDefaultForTextColumn

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

Tests passing a float default to a text column.

File

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

Class

SchemaDefinitionTest
Tests SchemaDefinition Column object validations.

Namespace

Drupal\Tests\Core\Database

Code

public function testFloatDefaultForTextColumn() : void {
  $this->expectException(SchemaDefinitionException::class);
  $this->expectExceptionMessageIs('Cannot set a float default for column \'id\'');
  new Table(name: 'test', columns: [
    Column::create(name: 'id', type: ColumnType::Text, default: new FloatValue(10)),
  ], primaryKey: new PrimaryKey([
    'id',
  ]));
}

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