function SchemaTest::checkGeneratedColumnStorage

Same name in this branch
  1. 11.x core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php \Drupal\Tests\sqlite\Kernel\sqlite\SchemaTest::checkGeneratedColumnStorage()

File

core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php, line 42

Class

SchemaTest
Tests schema API for the MySQL driver.

Namespace

Drupal\Tests\mysql\Kernel\mysql

Code

public function checkGeneratedColumnStorage(GeneratedColumnStorage $storage, string $table, string $column) : void {
  $getPrefixInfo = new \ReflectionMethod(get_class($this->schema), 'getPrefixInfo');
  $info = $getPrefixInfo->invoke($this->schema, $table);
  $extra = $this->connection
    ->query('SELECT [extra] FROM [information_schema].[columns] WHERE [table_schema] = :schema AND [table_name] = :table AND [column_name] = :column', [
    ':schema' => $info['database'],
    ':table' => $info['table'],
    ':column' => $column,
  ])
    ->fetchField();
  $expected = match ($storage) {  GeneratedColumnStorage::Virtual => 'VIRTUAL GENERATED',
    GeneratedColumnStorage::Stored => 'STORED GENERATED',
  
  };
  $this->assertSame($expected, $extra);
}

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