You are here

protected function DbDumpTest::getTableSchema in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php \Drupal\KernelTests\Core\Command\DbDumpTest::getTableSchema()
  2. 10 core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php \Drupal\KernelTests\Core\Command\DbDumpTest::getTableSchema()

Helper function to get a simplified schema for a given table.

Parameters

string $table:

Return value

array Array keyed by field name, with the values being the field type.

1 call to DbDumpTest::getTableSchema()
DbDumpTest::testScriptLoad in core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php
Test loading the script back into the database.

File

core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php, line 232

Class

DbDumpTest
Tests for the database dump commands.

Namespace

Drupal\KernelTests\Core\Command

Code

protected function getTableSchema($table) {

  // Verify the field type on the data column in the cache table.
  // @todo this is MySQL specific.
  $query = Database::getConnection()
    ->query("SHOW COLUMNS FROM {" . $table . "}");
  $definition = [];
  while ($row = $query
    ->fetchAssoc()) {
    $definition[$row['Field']] = $row['Type'];
  }
  return $definition;
}