function MigrateTestCase::createSchemaFromRow

Same name in other branches
  1. 9 core/modules/migrate/tests/src/Unit/MigrateTestCase.php \Drupal\Tests\migrate\Unit\MigrateTestCase::createSchemaFromRow()
  2. 10 core/modules/migrate/tests/src/Unit/MigrateTestCase.php \Drupal\Tests\migrate\Unit\MigrateTestCase::createSchemaFromRow()
  3. 11.x core/modules/migrate/tests/src/Unit/MigrateTestCase.php \Drupal\Tests\migrate\Unit\MigrateTestCase::createSchemaFromRow()

Generates a table schema from a row.

Parameters

array $row: The reference row on which to base the schema.

Return value

array The Schema API-ready table schema.

2 calls to MigrateTestCase::createSchemaFromRow()
MigrateSqlIdMapTest::saveMap in core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
Saves a single ID mapping row in the database.
MigrateTestCase::getDatabase in core/modules/migrate/tests/src/Unit/MigrateTestCase.php
Gets an SQLite database connection object for use in tests.

File

core/modules/migrate/tests/src/Unit/MigrateTestCase.php, line 142

Class

MigrateTestCase
Provides setup and helper methods for Migrate module tests.

Namespace

Drupal\Tests\migrate\Unit

Code

protected function createSchemaFromRow(array $row) {
    // SQLite uses loose ("affinity") typing, so it is OK for every column to be
    // a text field.
    $fields = array_map(function () {
        return [
            'type' => 'text',
        ];
    }, $row);
    return [
        'fields' => $fields,
    ];
}

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