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