function SchemaDefinitionConversionTest::testConvertSchemaDefinition
Tests Schema::toArray().
File
-
core/
tests/ Drupal/ Tests/ Core/ Database/ SchemaDefinitionConversionTest.php, line 192
Class
- SchemaDefinitionConversionTest
- Tests conversion of SchemaDefinition objects to legacy array-based structure.
Namespace
Drupal\Tests\Core\DatabaseCode
public function testConvertSchemaDefinition() : void {
$arraySpecification = [
'foo' => [
'description' => 'Foo table for the database unit tests.',
'fields' => [
'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
],
'primary key' => [
'id',
],
],
'bar' => [
'description' => 'Bar table for the database unit tests.',
'fields' => [
'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
],
'primary key' => [
'id',
],
],
];
$schemaDefinition = new Schema(type: SchemaDefinitionType::Test, name: 'test_foo_bar', tables: [
new Table(name: 'foo', description: 'Foo table for the database unit tests.', columns: [
Column::serial(name: 'id'),
], primaryKey: new PrimaryKey([
'id',
])),
new Table(name: 'bar', description: 'Bar table for the database unit tests.', columns: [
Column::serial(name: 'id'),
], primaryKey: new PrimaryKey([
'id',
])),
]);
$this->assertEquals($arraySpecification, $schemaDefinition->toArray());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.