Skip to content

DatabaseColumnTrait

Asserts the actual definition of database columns.

Reads columns from the database itself, not from Drupal's stored schema, so tests can catch the two getting out of sync. Supports MySQL, PostgreSQL and SQLite.


  • Full name: \Drupal\Tests\helper\Traits\DatabaseColumnTrait

Methods

assertColumn

Asserts a column's actual type and nullability in the database.

protected assertColumn(string $table, string $column, string $type, bool $nullable, int $length = 255): void

Reads the column from the database itself, not from Drupal's stored schema, so it catches the two getting out of sync.

Parameters:

Parameter Type Description
$table string
The table name, without the prefix.
$column string
The column name.
$type string
The expected type: 'text:big', 'varchar' or 'varchar_ascii'.
$nullable bool
Whether the column should allow NULL.
$length int
(optional) The expected length of a varchar column.