function NodeMigrateTypeTestTrait::makeNodeMigrateMapTable
Same name in other branches
- 9 core/modules/migrate_drupal/tests/src/Traits/NodeMigrateTypeTestTrait.php \Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait::makeNodeMigrateMapTable()
- 10 core/modules/migrate_drupal/tests/src/Traits/NodeMigrateTypeTestTrait.php \Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait::makeNodeMigrateMapTable()
- 11.x core/modules/migrate_drupal/tests/src/Traits/NodeMigrateTypeTestTrait.php \Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait::makeNodeMigrateMapTable()
Create a node migrate_map table.
Parameters
string $type: The type of node migration, 'complete' or 'classic'.
string $version: The source database version.
Throws
\Exception
4 calls to NodeMigrateTypeTestTrait::makeNodeMigrateMapTable()
- MigrateDrupal6TestBase::setUp in core/
modules/ migrate_drupal/ tests/ src/ Kernel/ d6/ MigrateDrupal6TestBase.php - MigrateDrupal7TestBase::setUp in core/
modules/ migrate_drupal/ tests/ src/ Kernel/ d7/ MigrateDrupal7TestBase.php - NodeClassicTest::testMigrateUpgradeExecute in core/
modules/ migrate_drupal_ui/ tests/ src/ Functional/ d6/ NodeClassicTest.php - Tests ID Conflict form.
- NodeMigrationTypePluginAlterTest::testMigrationPluginAlter in core/
modules/ migrate_drupal/ tests/ src/ Kernel/ NodeMigrationTypePluginAlterTest.php - Tests the assignment of the node migration type.
File
-
core/
modules/ migrate_drupal/ tests/ src/ Traits/ NodeMigrateTypeTestTrait.php, line 92
Class
- NodeMigrateTypeTestTrait
- Helper functions to test complete and classic node migrations.
Namespace
Drupal\Tests\migrate_drupal\TraitsCode
protected function makeNodeMigrateMapTable($type, $version) {
$name = $this->getTableName($type, $version);
$fields = [
'source_ids_hash' => [
'type' => 'varchar',
'not null' => TRUE,
'length' => '64',
],
'sourceid1' => [
'type' => 'int',
'not null' => TRUE,
'size' => 'normal',
],
'sourceid2' => [
'type' => 'int',
'not null' => TRUE,
'size' => 'normal',
],
'sourceid3' => [
'type' => 'varchar',
'not null' => TRUE,
'length' => '255',
],
'destid1' => [
'type' => 'int',
'not null' => FALSE,
'size' => 'normal',
'unsigned' => TRUE,
],
'destid2' => [
'type' => 'int',
'not null' => FALSE,
'size' => 'normal',
'unsigned' => TRUE,
],
'destid3' => [
'type' => 'varchar_ascii',
'not null' => FALSE,
'length' => '12',
],
'source_row_status' => [
'type' => 'int',
'not null' => TRUE,
'size' => 'tiny',
'default' => '0',
'unsigned' => TRUE,
],
'rollback_action' => [
'type' => 'int',
'not null' => TRUE,
'size' => 'tiny',
'default' => '0',
'unsigned' => TRUE,
],
'last_imported' => [
'type' => 'int',
'not null' => TRUE,
'size' => 'normal',
'default' => '0',
'unsigned' => TRUE,
],
'hash' => [
'type' => 'varchar',
'not null' => FALSE,
'length' => '64',
],
];
$values = [
'source_ids_hash' => '123',
'sourceid1' => '4242',
'sourceid2' => '4242',
'sourceid3' => 'en',
'destid1' => '4242',
'destid2' => '4242',
'destid3' => 'en',
'source_row_status' => '1',
'rollback_action' => '1',
'last_imported' => time(),
'hash' => 'abc',
];
$indexes = [
'source' => [
'sourceid1',
'sourceid2',
'sourceid3',
],
];
// Remove keys not used.
if ($type == NodeMigrateType::NODE_MIGRATE_TYPE_CLASSIC) {
$keys = [
'sourceid2',
'sourceid3',
'destid2',
'destid3',
];
foreach ($keys as $key) {
unset($fields[$key]);
unset($values[$key]);
if (strstr($key, 'sourceid')) {
$index_key = substr($key, -1) - 1;
unset($indexes['source'][$index_key]);
}
}
}
$connection = \Drupal::database();
$connection->schema()
->createTable($name, [
'fields' => $fields,
'primary key' => [
'source_ids_hash',
],
'indexes' => $indexes,
'mysql_character_set' => 'utf8mb4',
]);
$field_names = array_keys($fields);
$connection->insert($name)
->fields($field_names)
->values($values)
->execute();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.