diff --git a/core/modules/migrate/src/Plugin/MigrateIdAuditInterface.php b/core/modules/migrate/src/Plugin/MigrateIdAuditInterface.php index 6837068..f582210 100644 --- a/core/modules/migrate/src/Plugin/MigrateIdAuditInterface.php +++ b/core/modules/migrate/src/Plugin/MigrateIdAuditInterface.php @@ -11,13 +11,13 @@ /** * Check whether unsafe IDs exist that should inhibit migration. * - * @param MigrateIdMapInterface $idMap + * @param MigrateIdMapInterface $id_map * The ID map for this migration. * * @return bool * Whether unsafe IDs exist. */ - public function unsafeIdsExist(MigrateIdMapInterface $idMap); + public function unsafeIdsExist(MigrateIdMapInterface $id_map); /** * Get the subfield that contains the highest ID migrated by this diff --git a/core/modules/migrate/src/Plugin/MigrateMaxIdInterface.php b/core/modules/migrate/src/Plugin/MigrateMaxIdInterface.php index 30b089b..a8138a8 100644 --- a/core/modules/migrate/src/Plugin/MigrateMaxIdInterface.php +++ b/core/modules/migrate/src/Plugin/MigrateMaxIdInterface.php @@ -2,7 +2,6 @@ namespace Drupal\migrate\Plugin; - interface MigrateMaxIdInterface { /** diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php index e154b0f..b043b28 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php @@ -323,22 +323,16 @@ public function getHighestIdField() { } /** - * Check whether unsafe IDs exist that should inhibit migration. - * - * @param \Drupal\migrate\Plugin\MigrateIdMapInterface $idMap - * The ID map for this migration. - * - * @return bool - * Whether unsafe IDs exist. + * {@inheritdoc} */ - public function unsafeIdsExist(MigrateIdMapInterface $idMap) { - // If IDs are are audited, we can't have conflicts. + public function unsafeIdsExist(MigrateIdMapInterface $id_map) { + // If IDs are are audited, see if there are any conflicts. if (!empty($this->migration->getPluginDefinition()['audit_ids'])) { - if (!($idMap instanceof MigrateMaxIdInterface)) { + if (!($id_map instanceof MigrateMaxIdInterface)) { // We don't know how to audit IDs without a cooperating ID map. return FALSE; } - $highestMigrated = $idMap->getMaxId($this->getHighestIdField()); + $highestMigrated = $id_map->getMaxId($this->getHighestIdField()); if ($this->highestDestinationId() > $highestMigrated) { // There's a new ID that we might conflict with! return TRUE; diff --git a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php index b2e0507..53a2a46 100644 --- a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php @@ -739,18 +739,18 @@ class MigrateUpgradeForm extends ConfirmFormBase { * The renderer service. * @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $plugin_manager * The migration plugin manager. - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. - * @param \Drupal\migrate\MigrateIdAuditor $idAuditor + * @param \Drupal\migrate\MigrateIdAuditor $id_auditor * The ID conflict auditor. */ - public function __construct(StateInterface $state, DateFormatterInterface $date_formatter, RendererInterface $renderer, MigrationPluginManagerInterface $plugin_manager, EntityTypeManagerInterface $entityTypeManager, MigrateIdAuditor $idAuditor) { + public function __construct(StateInterface $state, DateFormatterInterface $date_formatter, RendererInterface $renderer, MigrationPluginManagerInterface $plugin_manager, EntityTypeManagerInterface $entity_type_manager, MigrateIdAuditor $id_auditor) { $this->state = $state; $this->dateFormatter = $date_formatter; $this->renderer = $renderer; $this->pluginManager = $plugin_manager; - $this->entityTypeManager = $entityTypeManager; - $this->idAuditor = $idAuditor; + $this->entityTypeManager = $entity_type_manager; + $this->idAuditor = $id_auditor; } /** @@ -1126,10 +1126,10 @@ public function submitCredentialForm(array &$form, FormStateInterface $form_stat */ public function buildIdConflictForm(array &$form, FormStateInterface $form_state) { // Check if there are conflicts. If none, just skip this form! - $migrationIds = array_keys($form_state->get('migrations')); - $migrations = $this->pluginManager->createInstances($migrationIds); - $typeIds = $this->idAuditor->auditIds($migrations); - if (empty($typeIds)) { + $migration_ids = array_keys($form_state->get('migrations')); + $migrations = $this->pluginManager->createInstances($migration_ids); + $type_ids = $this->idAuditor->auditIds($migrations); + if (empty($type_ids)) { $form_state->set('step', 'confirm'); return $this->buildForm($form, $form_state); } @@ -1145,8 +1145,8 @@ public function buildIdConflictForm(array &$form, FormStateInterface $form_state ]; $items = []; - sort($typeIds); - foreach ($typeIds as $typeId) { + sort($type_ids); + foreach ($type_ids as $typeId) { $items[] = $this->entityTypeManager->getDefinition($typeId)->getLabel(); } $form['type_list'] = [ diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php index ce21f97..b88fbb1 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php @@ -172,11 +172,10 @@ protected function runPostMigrationTests() { $this->resetAll(); $expected_counts = $this->getEntityCounts(); - foreach (array_keys(\Drupal::entityTypeManager() - ->getDefinitions()) as $entity_type) { + foreach (array_keys(\Drupal::entityTypeManager()->getDefinitions()) as $entity_type) { $real_count = \Drupal::entityQuery($entity_type)->count()->execute(); $expected_count = isset($expected_counts[$entity_type]) ? $expected_counts[$entity_type] : 0; - $this->assertEqual($expected_count, $real_count, "Found $real_count $entity_type entities, expected $expected_count."); + $this->assertSame($expected_count, $real_count, "Found $real_count $entity_type entities, expected $expected_count."); } $plugin_manager = \Drupal::service('plugin.manager.migration'); 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 7bdefb7..24a0d2c 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 @@ -15,9 +15,7 @@ class MigrateUpgrade6Test extends MigrateUpgradeTestBase { /** - * Modules to enable. - * - * @var array + * {@inheritdoc} */ public static $modules = [ 'language', @@ -55,7 +53,7 @@ protected function getEntityCounts() { 'block_content' => 2, 'block_content_type' => 1, 'comment' => 3, - 'comment_type' => 3, + 'comment_type' => 2, 'contact_form' => 5, 'configurable_language' => 5, 'editor' => 2, diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgradeConflicts6Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgradeConflicts6Test.php index 3c73fff..642bb9e 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgradeConflicts6Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgradeConflicts6Test.php @@ -2,9 +2,6 @@ namespace Drupal\Tests\migrate_drupal_ui\Functional\d6; -use Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeTestBase; -use Drupal\user\Entity\User; - /** * Tests Drupal 6 upgrade using the migrate UI and has ID conflicts. * @@ -15,11 +12,7 @@ class MigrateUpgradeConflicts6Test extends MigrateUpgrade6Test { /** - * Modules to enable. - * - * @var array - * - * Forum module adds content, resulting in content id conflicts. + * {@inheritdoc} */ public static $modules = [ 'language', @@ -28,6 +21,7 @@ class MigrateUpgradeConflicts6Test extends MigrateUpgrade6Test { 'telephone', 'aggregator', 'book', + // Forum module adds content, resulting in content id conflicts. 'forum', 'statistics', ]; @@ -54,4 +48,13 @@ public function testMigrateUpgrade() { $this->runPostMigrationTests(); } + /** + * {@inheritdoc} + */ + protected function getEntityCounts() { + $counts = parent::getEntityCounts(); + $counts['comment_type'] = 3; + return $counts; + } + } diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php index 248213a..6cadfe5 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php @@ -45,7 +45,7 @@ protected function getEntityCounts() { 'block_content' => 1, 'block_content_type' => 1, 'comment' => 1, - 'comment_type' => 8, + 'comment_type' => 7, // Module 'language' comes with 'en', 'und', 'zxx'. Migration adds 'is'. 'configurable_language' => 4, 'contact_form' => 3, diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgradeConflicts7Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgradeConflicts7Test.php index 22670a9..5bba621 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgradeConflicts7Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgradeConflicts7Test.php @@ -2,9 +2,6 @@ namespace Drupal\Tests\migrate_drupal_ui\Functional\d7; -use Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeTestBase; -use Drupal\user\Entity\User; - /** * Tests Drupal 7 upgrade using the migrate UI and has ID conflicts. * @@ -15,19 +12,17 @@ class MigrateUpgradeConflicts7Test extends MigrateUpgrade7Test { /** - * Modules to enable. - * - * @var array - * - * Forum module adds content, resulting in content id conflicts. + * {@inheritdoc} */ public static $modules = [ + 'file', 'language', 'content_translation', 'migrate_drupal_ui', 'telephone', 'aggregator', 'book', + // Forum module adds content, resulting in content id conflicts. 'forum', 'statistics', ]; @@ -54,4 +49,14 @@ public function testMigrateUpgrade() { $this->runPostMigrationTests(); } + /** + * {@inheritdoc} + */ + protected function getEntityCounts() { + $counts = parent::getEntityCounts(); + // Forum has a comment. + $counts['comment_type'] = 8; + return $counts; + } + }