diff --git a/core/modules/contact/migration_templates/contact_category.yml b/core/modules/contact/migration_templates/contact_category.yml index ce7ce9931df87b958602d7a9ce7d5301fe5b91e3..0174de491641a6f0b5fea65dd3b9e2e395d4fc25 100644 --- a/core/modules/contact/migration_templates/contact_category.yml +++ b/core/modules/contact/migration_templates/contact_category.yml @@ -12,8 +12,8 @@ process: source: category - plugin: dedupe_entity - entity_type: user_role - field: cid + entity_type: contact_form + field: id length: 32 label: category recipients: recipients diff --git a/core/modules/contact/tests/src/Kernel/Migrate/d6/MigrateContactCategoryTest.php b/core/modules/contact/tests/src/Kernel/Migrate/d6/MigrateContactCategoryTest.php index d613cacdf5b6f2a3877cc8350bd03897f222a289..e40f0bdd49a3da44cb6621c52b675c78866c90e5 100644 --- a/core/modules/contact/tests/src/Kernel/Migrate/d6/MigrateContactCategoryTest.php +++ b/core/modules/contact/tests/src/Kernel/Migrate/d6/MigrateContactCategoryTest.php @@ -47,6 +47,29 @@ public function testContactCategory() { $this->assertIdentical(array('fortyninechars@example.com'), $contact_form->getRecipients()); $this->assertIdentical('', $contact_form->getReply()); $this->assertIdentical(2, $contact_form->getWeight()); + + // Test there are no duplicated roles. + $contact_forms = [ + 'website_feedback1', + 'some_other_category1', + 'a_category_much_longer_than_thir1', + ]; + $this->assertEmpty(ContactForm::loadMultiple($contact_forms)); + + /* + * Remove the map row for the Website feedback contact form so that it + * can be migrated again. + */ + $id_map = $this->getMigration('contact_category')->getIdMap(); + $id_map->delete(['cid' => '1']); + $this->executeMigration('contact_category'); + + // Test there is a duplicate Website feedback form. + $contact_form = ContactForm::load('website_feedback1'); + $this->assertSame('Website feedback', $contact_form->label()); + $this->assertSame(array('admin@example.com'), $contact_form->getRecipients()); + $this->assertSame('', $contact_form->getReply()); + $this->assertSame(0, $contact_form->getWeight()); } }