function SchemaDefinitionTest::testInvalidTableInSchema

Tests passing a non Table array member to Schema::$tables.

File

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

Class

SchemaDefinitionTest
Tests SchemaDefinition Column object validations.

Namespace

Drupal\Tests\Core\Database

Code

public function testInvalidTableInSchema() : void {
  $this->expectException(SchemaDefinitionException::class);
  $this->expectExceptionMessage('All members of the \'tables\' argument of a Schema must be Table objects');
  $table = new Schema(type: SchemaDefinitionType::Test, name: 'test', tables: [
    'foo' => [
      'description' => 'Foo table for the database unit tests.',
      'fields' => [
        'id' => [
          'type' => 'serial',
          'unsigned' => TRUE,
          'not null' => TRUE,
        ],
      ],
      'primary key' => [
        'id',
      ],
    ],
  ]);
  $this->assertInstanceOf(Table::class, $table);
}

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