protected function DbDumpTest::getTableSchema in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php \Drupal\KernelTests\Core\Command\DbDumpTest::getTableSchema()
- 9 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: The table name.
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 - Tests loading the script back into the database.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Command/ DbDumpTest.php, line 228
Class
- DbDumpTest
- Tests for the database dump commands.
Namespace
Drupal\KernelTests\Core\CommandCode
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;
}