protected function MigrateSqlIdMapTest::saveMap in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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.
7 calls to MigrateSqlIdMapTest::saveMap()
- MigrateSqlIdMapTest::testErrorCount in core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php  - Performs error count test with a given number of error rows.
 - 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.
 - MigrateSqlIdMapTest::testIterators in core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php  - Tests all the iterator methods in one swing.
 - MigrateSqlIdMapTest::testLookupDestinationIdMapping in core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php  - Performs destination ID test on source and destination fields.
 
File
- core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php, line 61  - Contains \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest.
 
Class
- MigrateSqlIdMapTest
 - Tests the SQL ID map plugin.
 
Namespace
Drupal\Tests\migrate\UnitCode
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();
}