summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2017-08-05 09:00:17 (GMT)
committerNathaniel Catchpole2017-08-05 09:00:17 (GMT)
commit7d18091bc1cd51896a438f75a628a798a05608bc (patch)
treec301153f0bcb4e06a14f406b35bc74beb5e8bf6f
parent3b04db8ada20bcb53579f93d1fd0cbfc0eabff9c (diff)
Issue #2854878 by maxocub, joelpittet, mikeryan, quietone, hansrossel, phenaproxima: Taxonomy vocabulary with name Type cannot migrate from d6 to d8
-rw-r--r--core/modules/migrate_drupal/migrate_drupal.module6
-rw-r--r--core/modules/migrate_drupal/tests/fixtures/drupal6.php33
-rw-r--r--core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php2
-rw-r--r--core/modules/taxonomy/migration_templates/d6_vocabulary_entity_display.yml23
-rw-r--r--core/modules/taxonomy/migration_templates/d6_vocabulary_entity_form_display.yml23
-rw-r--r--core/modules/taxonomy/migration_templates/d6_vocabulary_field.yml15
-rw-r--r--core/modules/taxonomy/migration_templates/d6_vocabulary_field_instance.yml15
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php6
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php18
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeRevisionTest.php6
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTest.php10
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php13
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php17
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php27
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldTest.php15
15 files changed, 171 insertions, 58 deletions
diff --git a/core/modules/migrate_drupal/migrate_drupal.module b/core/modules/migrate_drupal/migrate_drupal.module
index 9b00e07..8399f3f 100644
--- a/core/modules/migrate_drupal/migrate_drupal.module
+++ b/core/modules/migrate_drupal/migrate_drupal.module
@@ -56,9 +56,9 @@ function migrate_drupal_migration_plugins_alter(&$definitions) {
$source_vid = $row->getSourceProperty('vid');
$plugin_ids = ['d6_term_node:' . $source_vid, 'd6_term_node_revision:' . $source_vid];
foreach ($plugin_ids as $plugin_id) {
- if (isset($definitions[$plugin_id])) {
- $definitions[$plugin_id]['process'][$row->getDestinationProperty('vid')] = 'tid';
- }
+ // Match the field name derivation in d6_vocabulary_field.yml.
+ $field_name = substr('field_' . $row->getDestinationProperty('vid'), 0, 32);
+ $definitions[$plugin_id]['process'][$field_name] = 'tid';
}
}
}
diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal6.php b/core/modules/migrate_drupal/tests/fixtures/drupal6.php
index 0003684..a7beb5b 100644
--- a/core/modules/migrate_drupal/tests/fixtures/drupal6.php
+++ b/core/modules/migrate_drupal/tests/fixtures/drupal6.php
@@ -9558,6 +9558,14 @@ $connection->insert('i18n_strings')
'objectindex' => '0',
'format' => '0',
))
+->values(array(
+ 'lid' => '1672',
+ 'objectid' => '6',
+ 'type' => 'vocabulary',
+ 'property' => 'name',
+ 'objectindex' => '6',
+ 'format' => '0',
+))
->execute();
$connection->schema()->createTable('i18n_variable', array(
@@ -22010,6 +22018,13 @@ $connection->insert('locales_source')
'source' => '%name: Title mismatch. Please check your selection.',
'version' => 'none',
))
+->values(array(
+ 'lid' => '1672',
+ 'location' => 'vocabulary:6:name',
+ 'textgroup' => 'taxonomy',
+ 'source' => 'Type',
+ 'version' => '1',
+))
->execute();
$connection->schema()->createTable('locales_target', array(
@@ -48226,6 +48241,20 @@ $connection->insert('vocabulary')
'weight' => '7',
'language' => '',
))
+->values(array(
+ 'vid' => '6',
+ 'name' => 'Type',
+ 'description' => '',
+ 'help' => '',
+ 'relations' => '1',
+ 'hierarchy' => '0',
+ 'multiple' => '0',
+ 'required' => '0',
+ 'tags' => '0',
+ 'module' => 'taxonomy',
+ 'weight' => '0',
+ 'language' => '',
+))
->execute();
$connection->schema()->createTable('vocabulary_node_types', array(
@@ -48269,6 +48298,10 @@ $connection->insert('vocabulary_node_types')
'type' => 'page',
))
->values(array(
+ 'vid' => '6',
+ 'type' => 'sponsor',
+))
+->values(array(
'vid' => '1',
'type' => 'story',
))
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php
index 1c4b883..418addc 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php
@@ -60,7 +60,7 @@ class MigrateUpgrade6Test extends MigrateUpgradeTestBase {
'action' => 23,
'menu' => 8,
'taxonomy_term' => 7,
- 'taxonomy_vocabulary' => 6,
+ 'taxonomy_vocabulary' => 7,
'tour' => 4,
'user' => 7,
'user_role' => 6,
diff --git a/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_display.yml b/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_display.yml
index 8f154c3..e0f4625 100644
--- a/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_display.yml
+++ b/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_display.yml
@@ -11,6 +11,7 @@ source:
label: hidden
type: entity_reference_label
weight: 20
+ field_prefix: field_
process:
entity_type: 'constants/entity_type'
view_mode: 'constants/view_mode'
@@ -23,10 +24,26 @@ process:
-
plugin: skip_on_empty
method: row
+ # This value is only used in the 'field_name' process pipeline below.
+ raw_field_name:
+ -
+ plugin: migration_lookup
+ migration: d6_taxonomy_vocabulary
+ source: vid
+ -
+ plugin: skip_on_empty
+ method: row
field_name:
- plugin: migration_lookup
- migration: d6_taxonomy_vocabulary
- source: vid
+ # Prepend field_ to avoid conflicts with base fields, and make sure the
+ # result is no longer than 32 characters.
+ -
+ plugin: concat
+ source:
+ - constants/field_prefix
+ - '@raw_field_name'
+ -
+ plugin: substr
+ length: 32
destination:
plugin: component_entity_display
migration_dependencies:
diff --git a/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_form_display.yml b/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_form_display.yml
index 4ac6d64..20bb0e4 100644
--- a/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_form_display.yml
+++ b/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_form_display.yml
@@ -9,6 +9,7 @@ source:
form_mode: default
options:
weight: 20
+ field_prefix: field_
process:
entity_type: 'constants/entity_type'
form_mode: 'constants/form_mode'
@@ -27,10 +28,26 @@ process:
-
plugin: skip_on_empty
method: row
+ # This value is only used in the 'field_name' process pipeline below.
+ raw_field_name:
+ -
+ plugin: migration_lookup
+ migration: d6_taxonomy_vocabulary
+ source: vid
+ -
+ plugin: skip_on_empty
+ method: row
field_name:
- plugin: migration_lookup
- migration: d6_taxonomy_vocabulary
- source: vid
+ # Prepend field_ to avoid conflicts with base fields, and make sure the
+ # result is no longer than 32 characters.
+ -
+ plugin: concat
+ source:
+ - constants/field_prefix
+ - '@raw_field_name'
+ -
+ plugin: substr
+ length: 32
destination:
plugin: component_entity_form_display
migration_dependencies:
diff --git a/core/modules/taxonomy/migration_templates/d6_vocabulary_field.yml b/core/modules/taxonomy/migration_templates/d6_vocabulary_field.yml
index 082386f..bb4a942 100644
--- a/core/modules/taxonomy/migration_templates/d6_vocabulary_field.yml
+++ b/core/modules/taxonomy/migration_templates/d6_vocabulary_field.yml
@@ -8,10 +8,12 @@ source:
entity_type: node
type: entity_reference
target_entity_type: taxonomy_term
+ field_prefix: field_
process:
entity_type: 'constants/entity_type'
type: 'constants/type'
- field_name:
+ # This value is only used in the 'field_name' process pipeline below.
+ raw_field_name:
-
plugin: migration_lookup
migration: d6_taxonomy_vocabulary
@@ -19,6 +21,17 @@ process:
-
plugin: skip_on_empty
method: row
+ field_name:
+ # Prepend field_ to avoid conflicts with base fields, and make sure the
+ # result is no longer than 32 characters.
+ -
+ plugin: concat
+ source:
+ - constants/field_prefix
+ - '@raw_field_name'
+ -
+ plugin: substr
+ length: 32
'settings/target_type': 'constants/target_entity_type'
cardinality: cardinality
destination:
diff --git a/core/modules/taxonomy/migration_templates/d6_vocabulary_field_instance.yml b/core/modules/taxonomy/migration_templates/d6_vocabulary_field_instance.yml
index 6fe5eed..6d9ffa6 100644
--- a/core/modules/taxonomy/migration_templates/d6_vocabulary_field_instance.yml
+++ b/core/modules/taxonomy/migration_templates/d6_vocabulary_field_instance.yml
@@ -8,6 +8,7 @@ source:
entity_type: node
auto_create: true
selection_handler: 'default:taxonomy_term'
+ field_prefix: field_
process:
entity_type: 'constants/entity_type'
bundle:
@@ -18,7 +19,8 @@ process:
-
plugin: skip_on_empty
method: row
- field_name:
+ # This value is only used in the 'field_name' process pipeline below.
+ raw_field_name:
-
plugin: migration_lookup
migration: d6_taxonomy_vocabulary
@@ -26,6 +28,17 @@ process:
-
plugin: skip_on_empty
method: row
+ field_name:
+ # Prepend field_ to avoid conflicts with base fields, and make sure the
+ # result is no longer than 32 characters.
+ -
+ plugin: concat
+ source:
+ - constants/field_prefix
+ - '@raw_field_name'
+ -
+ plugin: substr
+ length: 32
label: name
'settings/handler': 'constants/selection_handler'
'settings/handler_settings/target_bundles/0': '@field_name'
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php
index 12b9a9c..6450e4d 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php
@@ -89,8 +89,8 @@ class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
$language = isset($values['language']) ? $values['language'] . ' - ' : '';
$this->assertSame("{$language}term {$tid} of vocabulary {$values['source_vid']}", $term->name->value);
$this->assertSame("{$language}description of term {$tid} of vocabulary {$values['source_vid']}", $term->description->value);
- $this->assertIdentical($values['vid'], $term->vid->target_id);
- $this->assertIdentical((string) $values['weight'], $term->weight->value);
+ $this->assertSame($values['vid'], $term->vid->target_id);
+ $this->assertSame((string) $values['weight'], $term->weight->value);
if ($values['parent'] === [0]) {
$this->assertNull($term->parent->target_id);
}
@@ -99,7 +99,7 @@ class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
foreach (\Drupal::entityManager()->getStorage('taxonomy_term')->loadParents($tid) as $parent) {
$parents[] = (int) $parent->id();
}
- $this->assertIdentical($parents, $values['parent']);
+ $this->assertSame($parents, $values['parent']);
}
$this->assertArrayHasKey($tid, $tree_terms, "Term $tid exists in vocabulary tree");
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php
index 6c66598..79e188b 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php
@@ -32,17 +32,17 @@ class MigrateTaxonomyVocabularyTest extends MigrateDrupal6TestBase {
for ($i = 0; $i < 3; $i++) {
$j = $i + 1;
$vocabulary = Vocabulary::load("vocabulary_{$j}_i_{$i}_");
- $this->assertIdentical($this->getMigration('d6_taxonomy_vocabulary')->getIdMap()->lookupDestinationID([$j]), [$vocabulary->id()]);
- $this->assertIdentical("vocabulary $j (i=$i)", $vocabulary->label());
- $this->assertIdentical("description of vocabulary $j (i=$i)", $vocabulary->getDescription());
- $this->assertIdentical($i, $vocabulary->getHierarchy());
- $this->assertIdentical(4 + $i, $vocabulary->get('weight'));
+ $this->assertSame($this->getMigration('d6_taxonomy_vocabulary')->getIdMap()->lookupDestinationID([$j]), [$vocabulary->id()]);
+ $this->assertSame("vocabulary $j (i=$i)", $vocabulary->label());
+ $this->assertSame("description of vocabulary $j (i=$i)", $vocabulary->getDescription());
+ $this->assertSame($i, $vocabulary->getHierarchy());
+ $this->assertSame(4 + $i, $vocabulary->get('weight'));
}
$vocabulary = Vocabulary::load('vocabulary_name_much_longer_than');
- $this->assertIdentical('vocabulary name much longer than thirty two characters', $vocabulary->label());
- $this->assertIdentical('description of vocabulary name much longer than thirty two characters', $vocabulary->getDescription());
- $this->assertIdentical(3, $vocabulary->getHierarchy());
- $this->assertIdentical(7, $vocabulary->get('weight'));
+ $this->assertSame('vocabulary name much longer than thirty two characters', $vocabulary->label());
+ $this->assertSame('description of vocabulary name much longer than thirty two characters', $vocabulary->getDescription());
+ $this->assertSame(3, $vocabulary->getHierarchy());
+ $this->assertSame(7, $vocabulary->get('weight'));
}
}
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeRevisionTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeRevisionTest.php
index e002ef4..614725d 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeRevisionTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeRevisionTest.php
@@ -32,9 +32,9 @@ class MigrateTermNodeRevisionTest extends MigrateDrupal6TestBase {
*/
public function testTermRevisionNode() {
$node = \Drupal::entityManager()->getStorage('node')->loadRevision(2);
- $this->assertIdentical(2, count($node->vocabulary_3_i_2_));
- $this->assertIdentical('4', $node->vocabulary_3_i_2_[0]->target_id);
- $this->assertIdentical('5', $node->vocabulary_3_i_2_[1]->target_id);
+ $this->assertSame(2, count($node->field_vocabulary_3_i_2_));
+ $this->assertSame('4', $node->field_vocabulary_3_i_2_[0]->target_id);
+ $this->assertSame('5', $node->field_vocabulary_3_i_2_[1]->target_id);
}
}
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTest.php
index c13c4db..8e7d13d 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTest.php
@@ -40,12 +40,12 @@ class MigrateTermNodeTest extends MigrateDrupal6TestBase {
$nodes = Node::loadMultiple([1, 2]);
$node = $nodes[1];
- $this->assertIdentical(1, count($node->vocabulary_1_i_0_));
- $this->assertIdentical('1', $node->vocabulary_1_i_0_[0]->target_id);
+ $this->assertSame(1, count($node->field_vocabulary_1_i_0_));
+ $this->assertSame('1', $node->field_vocabulary_1_i_0_[0]->target_id);
$node = $nodes[2];
- $this->assertIdentical(2, count($node->vocabulary_2_i_1_));
- $this->assertIdentical('2', $node->vocabulary_2_i_1_[0]->target_id);
- $this->assertIdentical('3', $node->vocabulary_2_i_1_[1]->target_id);
+ $this->assertSame(2, count($node->field_vocabulary_2_i_1_));
+ $this->assertSame('2', $node->field_vocabulary_2_i_1_[0]->target_id);
+ $this->assertSame('3', $node->field_vocabulary_2_i_1_[1]->target_id);
}
/**
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php
index f6fb85d..5b8a638 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php
@@ -41,11 +41,16 @@ class MigrateVocabularyEntityDisplayTest extends MigrateDrupal6TestBase {
$this->executeMigration('d6_vocabulary_entity_display');
// Test that the field exists.
- $component = EntityViewDisplay::load('node.page.default')->getComponent('tags');
- $this->assertIdentical('entity_reference_label', $component['type']);
- $this->assertIdentical(20, $component['weight']);
+ $component = EntityViewDisplay::load('node.page.default')->getComponent('field_tags');
+ $this->assertSame('entity_reference_label', $component['type']);
+ $this->assertSame(20, $component['weight']);
// Test the Id map.
- $this->assertIdentical(['node', 'article', 'default', 'tags'], $this->getMigration('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationID([4, 'article']));
+ $this->assertSame(['node', 'article', 'default', 'field_tags'], $this->getMigration('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationID([4, 'article']));
+
+ // Tests that a vocabulary named like a D8 base field will be migrated and
+ // prefixed with 'field_' to avoid conflicts.
+ $field_type = EntityViewDisplay::load('node.sponsor.default')->getComponent('field_type');
+ $this->assertTrue(is_array($field_type));
}
/**
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php
index 93ac643..2c96e51 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php
@@ -41,16 +41,21 @@ class MigrateVocabularyEntityFormDisplayTest extends MigrateDrupal6TestBase {
$this->executeMigration('d6_vocabulary_entity_form_display');
// Test that the field exists.
- $component = EntityFormDisplay::load('node.page.default')->getComponent('tags');
- $this->assertIdentical('options_select', $component['type']);
- $this->assertIdentical(20, $component['weight']);
+ $component = EntityFormDisplay::load('node.page.default')->getComponent('field_tags');
+ $this->assertSame('options_select', $component['type']);
+ $this->assertSame(20, $component['weight']);
// Test the Id map.
- $this->assertIdentical(['node', 'article', 'default', 'tags'], $this->getMigration('d6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationID([4, 'article']));
+ $this->assertSame(['node', 'article', 'default', 'field_tags'], $this->getMigration('d6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationID([4, 'article']));
// Test the term widget tags setting.
$entity_form_display = EntityFormDisplay::load('node.story.default');
- $this->assertIdentical($entity_form_display->getComponent('vocabulary_1_i_0_')['type'], 'options_select');
- $this->assertIdentical($entity_form_display->getComponent('vocabulary_2_i_1_')['type'], 'entity_reference_autocomplete_tags');
+ $this->assertSame($entity_form_display->getComponent('field_vocabulary_1_i_0_')['type'], 'options_select');
+ $this->assertSame($entity_form_display->getComponent('field_vocabulary_2_i_1_')['type'], 'entity_reference_autocomplete_tags');
+
+ // Tests that a vocabulary named like a D8 base field will be migrated and
+ // prefixed with 'field_' to avoid conflicts.
+ $field_type = EntityFormDisplay::load('node.sponsor.default')->getComponent('field_type');
+ $this->assertTrue(is_array($field_type));
}
/**
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php
index bd5a497..26cd7f5 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php
@@ -40,30 +40,35 @@ class MigrateVocabularyFieldInstanceTest extends MigrateDrupal6TestBase {
$this->executeMigration('d6_vocabulary_field_instance');
// Test that the field exists.
- $field_id = 'node.article.tags';
+ $field_id = 'node.article.field_tags';
$field = FieldConfig::load($field_id);
- $this->assertIdentical($field_id, $field->id(), 'Field instance exists on article bundle.');
- $this->assertIdentical('Tags', $field->label());
+ $this->assertSame($field_id, $field->id(), 'Field instance exists on article bundle.');
+ $this->assertSame('Tags', $field->label());
$this->assertTrue($field->isRequired(), 'Field is required');
// Test the page bundle as well.
- $field_id = 'node.page.tags';
+ $field_id = 'node.page.field_tags';
$field = FieldConfig::load($field_id);
- $this->assertIdentical($field_id, $field->id(), 'Field instance exists on page bundle.');
- $this->assertIdentical('Tags', $field->label());
+ $this->assertSame($field_id, $field->id(), 'Field instance exists on page bundle.');
+ $this->assertSame('Tags', $field->label());
$this->assertTrue($field->isRequired(), 'Field is required');
$settings = $field->getSettings();
- $this->assertIdentical('default:taxonomy_term', $settings['handler'], 'The handler plugin ID is correct.');
- $this->assertIdentical(['tags'], $settings['handler_settings']['target_bundles'], 'The target_bundles handler setting is correct.');
- $this->assertIdentical(TRUE, $settings['handler_settings']['auto_create'], 'The "auto_create" setting is correct.');
+ $this->assertSame('default:taxonomy_term', $settings['handler'], 'The handler plugin ID is correct.');
+ $this->assertSame(['field_tags'], $settings['handler_settings']['target_bundles'], 'The target_bundles handler setting is correct.');
+ $this->assertSame(TRUE, $settings['handler_settings']['auto_create'], 'The "auto_create" setting is correct.');
- $this->assertIdentical(['node', 'article', 'tags'], $this->getMigration('d6_vocabulary_field_instance')->getIdMap()->lookupDestinationID([4, 'article']));
+ $this->assertSame(['node', 'article', 'field_tags'], $this->getMigration('d6_vocabulary_field_instance')->getIdMap()->lookupDestinationID([4, 'article']));
// Test the the field vocabulary_1_i_0_.
- $field_id = 'node.story.vocabulary_1_i_0_';
+ $field_id = 'node.story.field_vocabulary_1_i_0_';
$field = FieldConfig::load($field_id);
$this->assertFalse($field->isRequired(), 'Field is not required');
+
+ // Tests that a vocabulary named like a D8 base field will be migrated and
+ // prefixed with 'field_' to avoid conflicts.
+ $field_type = FieldConfig::load('node.sponsor.field_type');
+ $this->assertInstanceOf(FieldConfig::class, $field_type);
}
/**
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldTest.php
index 784da4a..d294ec4 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldTest.php
@@ -30,16 +30,21 @@ class MigrateVocabularyFieldTest extends MigrateDrupal6TestBase {
*/
public function testVocabularyField() {
// Test that the field exists.
- $field_storage_id = 'node.tags';
+ $field_storage_id = 'node.field_tags';
/** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
$field_storage = FieldStorageConfig::load($field_storage_id);
- $this->assertIdentical($field_storage_id, $field_storage->id());
+ $this->assertSame($field_storage_id, $field_storage->id());
$settings = $field_storage->getSettings();
- $this->assertIdentical('taxonomy_term', $settings['target_type'], "Target type is correct.");
- $this->assertIdentical(1, $field_storage->getCardinality(), "Field cardinality in 1.");
+ $this->assertSame('taxonomy_term', $settings['target_type'], "Target type is correct.");
+ $this->assertSame(1, $field_storage->getCardinality(), "Field cardinality in 1.");
- $this->assertIdentical(['node', 'tags'], $this->getMigration('d6_vocabulary_field')->getIdMap()->lookupDestinationID([4]), "Test IdMap");
+ $this->assertSame(['node', 'field_tags'], $this->getMigration('d6_vocabulary_field')->getIdMap()->lookupDestinationID([4]), "Test IdMap");
+
+ // Tests that a vocabulary named like a D8 base field will be migrated and
+ // prefixed with 'field_' to avoid conflicts.
+ $field_type = FieldStorageConfig::load('node.field_type');
+ $this->assertInstanceOf(FieldStorageConfig::class, $field_type);
}
}