function SchemaDefinitionTest::testStringDefaultForIntColumn
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Database/SchemaDefinitionTest.php \Drupal\Tests\Core\Database\SchemaDefinitionTest::testStringDefaultForIntColumn()
Tests passing a string default to an int column.
File
-
core/
tests/ Drupal/ Tests/ Core/ Database/ SchemaDefinitionTest.php, line 295
Class
- SchemaDefinitionTest
- Tests SchemaDefinition Column object validations.
Namespace
Drupal\Tests\Core\DatabaseCode
public function testStringDefaultForIntColumn() : void {
$this->expectException(SchemaDefinitionException::class);
$this->expectExceptionMessageIs('Cannot set a string default for column \'id\'');
new Table(name: 'test', columns: [
Column::create(name: 'id', type: ColumnType::Int, default: new StringValue('foo')),
], primaryKey: new PrimaryKey([
'id',
]));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.