function MigrateSqlIdMapTest::saveMap

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

Saves a single ID mapping row in the database.

Parameters

array $map: The row to save.

9 calls to MigrateSqlIdMapTest::saveMap()
MigrateSqlIdMapTest::setupRows in core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
Setup a database with the given rows.
MigrateSqlIdMapTest::testErrorCount in core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
Performs error count test with a given number of error rows.
MigrateSqlIdMapTest::testGetHighestId in core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
Tests getHighestId method.
MigrateSqlIdMapTest::testGetRowByDestination in core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
Tests the getRowByDestination method.
MigrateSqlIdMapTest::testGetRowBySource in core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
Tests the getRowBySource method.

... See full list

File

core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php, line 71

Class

MigrateSqlIdMapTest
Tests the SQL ID map plugin.

Namespace

Drupal\Tests\migrate\Unit

Code

protected function saveMap(array $map) {
    $table = 'migrate_map_sql_idmap_test';
    $schema = $this->database
        ->schema();
    // If the table already exists, add any columns which are in the map array,
    // but don't yet exist in the table. Yay, flexibility!
    if ($schema->tableExists($table)) {
        foreach (array_keys($map) as $field) {
            if (!$schema->fieldExists($table, $field)) {
                $schema->addField($table, $field, [
                    'type' => 'text',
                ]);
            }
        }
    }
    else {
        $schema->createTable($table, $this->createSchemaFromRow($map));
    }
    $this->database
        ->insert($table)
        ->fields($map)
        ->execute();
}

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