function SchemaTest::checkGeneratedColumnStorage

Same name in this branch
  1. main core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php \Drupal\Tests\sqlite\Kernel\sqlite\SchemaTest::checkGeneratedColumnStorage()
  2. main core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php \Drupal\Tests\pgsql\Kernel\pgsql\SchemaTest::checkGeneratedColumnStorage()
Same name and namespace in other branches
  1. 11.x core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php \Drupal\Tests\sqlite\Kernel\sqlite\SchemaTest::checkGeneratedColumnStorage()
  2. 11.x core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php \Drupal\Tests\mysql\Kernel\mysql\SchemaTest::checkGeneratedColumnStorage()
  3. 11.x core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php \Drupal\Tests\pgsql\Kernel\pgsql\SchemaTest::checkGeneratedColumnStorage()

Checks that the database computes a column with the given storage.

Parameters

\Drupal\Core\Database\SchemaDefinition\GeneratedColumnStorage $storage: The asserted storage.

string $table: The table to test.

string $column: The generated column to test.

Overrides DriverSpecificSchemaTestBase::checkGeneratedColumnStorage

File

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

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.