diff --git a/modules/ubercart/commerce_migrate_ubercart.module b/modules/ubercart/commerce_migrate_ubercart.module index 5efb418..9bc29ac 100644 --- a/modules/ubercart/commerce_migrate_ubercart.module +++ b/modules/ubercart/commerce_migrate_ubercart.module @@ -193,6 +193,7 @@ function commerce_migrate_ubercart_migration_plugins_alter(&$migrations) { D7FieldInstance::class, ], FALSE)) { $migration['migration_dependencies']['optional'][] = 'uc7_product_type'; + $migration['migration_dependencies']['optional'][] = 'uc7_comment_type'; } } diff --git a/modules/ubercart/tests/src/Functional/MigrateUpgradeExecuteTestBase.php b/modules/ubercart/tests/src/Functional/MigrateUpgradeExecuteTestBase.php new file mode 100644 index 0000000..a1ea6f7 --- /dev/null +++ b/modules/ubercart/tests/src/Functional/MigrateUpgradeExecuteTestBase.php @@ -0,0 +1,62 @@ +sourceDatabase->getConnectionOptions(); + $session = $this->assertSession(); + + $driver = $connection_options['driver']; + $connection_options['prefix'] = $connection_options['prefix']['default']; + + // Use the driver connection form to get the correct options out of the + // database settings. This supports all of the databases we test against. + $drivers = drupal_get_database_types(); + $form = $drivers[$driver]->getFormOptions($connection_options); + $connection_options = array_intersect_key($connection_options, $form + $form['advanced_options']); + $version = $this->getLegacyDrupalVersion($this->sourceDatabase); + $edit = [ + $driver => $connection_options, + 'source_private_file_path' => $this->getSourceBasePath(), + 'version' => $version, + ]; + if ($version == 6) { + $edit['d6_source_base_path'] = $this->getSourceBasePath(); + } + else { + $edit['source_base_path'] = $this->getSourceBasePath(); + } + if (count($drivers) !== 1) { + $edit['driver'] = $driver; + } + $edits = $this->translatePostValues($edit); + + // Start the upgrade process. + $this->drupalGet('/upgrade'); + + $this->drupalPostForm(NULL, [], t('Continue')); + $session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.'); + $session->fieldExists('mysql[host]'); + + $this->drupalPostForm(NULL, $edits, t('Review upgrade')); + $session->statusCodeEquals(200); + + $this->drupalPostForm(NULL, [], t('I acknowledge I may lose data. Continue anyway.')); + $session->statusCodeEquals(200); + + $this->drupalPostForm(NULL, [], t('Perform upgrade')); + $session->pageTextContains(t('Congratulations, you upgraded Drupal!')); + $this->assertMigrationResults($this->getEntityCounts(), $version); + } + +} diff --git a/modules/ubercart/tests/src/Functional/uc6/MigrateUpgradeUbercart6Test.php b/modules/ubercart/tests/src/Functional/uc6/MigrateUpgradeUbercart6Test.php index 9182cac..01567d4 100644 --- a/modules/ubercart/tests/src/Functional/uc6/MigrateUpgradeUbercart6Test.php +++ b/modules/ubercart/tests/src/Functional/uc6/MigrateUpgradeUbercart6Test.php @@ -2,15 +2,11 @@ namespace Drupal\Tests\commerce_migrate_ubercart\Functional\uc6; -use Drupal\migrate\Plugin\MigrateIdMapInterface; -use Drupal\migrate_drupal\MigrationConfigurationTrait; -use Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeTestBase; +use Drupal\Tests\commerce_migrate_ubercart\Functional\MigrateUpgradeExecuteTestBase; /** * Tests Ubercart 6 using the migrate UI. * - * The test method is provided by the MigrateUpgradeTestBase class. - * * @requires module migrate_plus * @requires module commerce_shipping * @requires module physical @@ -18,9 +14,7 @@ use Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeTestBase; * @group commerce_migrate * @group commerce_migrate_uc6 */ -class MigrateUpgradeUbercart6Test extends MigrateUpgradeTestBase { - - use MigrationConfigurationTrait; +class MigrateUpgradeUbercart6Test extends MigrateUpgradeExecuteTestBase { /** * Modules to enable. @@ -85,87 +79,6 @@ class MigrateUpgradeUbercart6Test extends MigrateUpgradeTestBase { } /** - * Executes all steps of migrations upgrade. - */ - public function testMigrateUpgrade() { - $connection_options = $this->sourceDatabase->getConnectionOptions(); - $session = $this->assertSession(); - - $driver = $connection_options['driver']; - $connection_options['prefix'] = $connection_options['prefix']['default']; - - // Use the driver connection form to get the correct options out of the - // database settings. This supports all of the databases we test against. - $drivers = drupal_get_database_types(); - $form = $drivers[$driver]->getFormOptions($connection_options); - $connection_options = array_intersect_key($connection_options, $form + $form['advanced_options']); - $version = $this->getLegacyDrupalVersion($this->sourceDatabase); - $edit = [ - $driver => $connection_options, - 'source_private_file_path' => $this->getSourceBasePath(), - 'version' => $version, - ]; - if ($version == 6) { - $edit['d6_source_base_path'] = $this->getSourceBasePath(); - } - else { - $edit['source_base_path'] = $this->getSourceBasePath(); - } - if (count($drivers) !== 1) { - $edit['driver'] = $driver; - } - $edits = $this->translatePostValues($edit); - - // Start the upgrade process. - $this->drupalGet('/upgrade'); - - $this->drupalPostForm(NULL, [], t('Continue')); - $session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.'); - $session->fieldExists('mysql[host]'); - - $this->drupalPostForm(NULL, $edits, t('Review upgrade')); - $session->statusCodeEquals(200); - - $this->drupalPostForm(NULL, [], t('Perform upgrade')); - - // Have to reset all the statics after migration to ensure entities are - // loadable. - $this->resetAll(); - - $expected_counts = $this->getEntityCounts(); - 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."); - } - - $plugin_manager = \Drupal::service('plugin.manager.migration'); - /** @var \Drupal\migrate\Plugin\Migration[] $all_migrations */ - $all_migrations = $plugin_manager->createInstancesByTag('Drupal ' . $version); - foreach ($all_migrations as $migration) { - $id_map = $migration->getIdMap(); - foreach ($id_map as $source_id => $map) { - // Convert $source_id into a keyless array so that - // \Drupal\migrate\Plugin\migrate\id_map\Sql::getSourceHash() works as - // expected. - $source_id_values = array_values(unserialize($source_id)); - $row = $id_map->getRowBySource($source_id_values); - $destination = serialize($id_map->currentDestination()); - $message = "Migration of $source_id to $destination as part of the {$migration->id()} migration. The source row status is " . $row['source_row_status']; - // A completed migration should have maps with - // MigrateIdMapInterface::STATUS_IGNORED or - // MigrateIdMapInterface::STATUS_IMPORTED. - if ($row['source_row_status'] == MigrateIdMapInterface::STATUS_FAILED || $row['source_row_status'] == MigrateIdMapInterface::STATUS_NEEDS_UPDATE) { - $this->fail($message); - } - else { - $this->pass($message); - } - } - } - } - - /** * {@inheritdoc} */ protected function getSourceBasePath() { @@ -177,66 +90,66 @@ class MigrateUpgradeUbercart6Test extends MigrateUpgradeTestBase { */ protected function getEntityCounts() { return [ - 'block' => '23', - 'block_content' => '0', - 'block_content_type' => '1', - 'comment' => '0', - 'comment_type' => '3', - 'commerce_log' => '0', - 'commerce_order_type' => '1', - 'commerce_order' => '5', - 'commerce_order_item' => '6', - 'commerce_order_item_type' => '1', - 'commerce_payment' => '4', - 'commerce_payment_method' => '0', - 'commerce_payment_gateway' => '2', - 'commerce_product' => '5', - 'commerce_product_attribute' => '4', - 'commerce_product_attribute_value' => '7', - 'commerce_product_variation_type' => '4', - 'commerce_product_variation' => '5', - 'commerce_product_type' => '4', - 'commerce_promotion_coupon' => '0', - 'commerce_promotion' => '0', - 'commerce_currency' => '2', - 'commerce_shipping_method' => '2', - 'commerce_shipment_type' => '1', - 'commerce_store' => '1', - 'commerce_store_type' => '1', - 'commerce_tax_type' => '1', - 'contact_form' => '2', - 'contact_message' => '0', - 'editor' => '2', - 'field_config' => '41', - 'field_storage_config' => '27', - 'file' => '0', - 'filter_format' => '5', - 'image_style' => '3', - 'migration_group' => '1', - 'migration' => '0', - 'node_type' => '3', - 'node' => '1', - 'profile_type' => '1', - 'profile' => '4', - 'rdf_mapping' => '5', - 'search_page' => '2', - 'shortcut' => '2', - 'shortcut_set' => '1', - 'action' => '29', - 'menu' => '8', - 'taxonomy_vocabulary' => '2', - 'taxonomy_term' => '3', - 'tour' => '1', - 'user_role' => '5', - 'user' => '6', - 'menu_link_content' => '0', - 'view' => '24', - 'base_field_override' => '6', - 'date_format' => '11', - 'entity_view_display' => '29', - 'entity_view_mode' => '17', - 'entity_form_display' => '18', - 'entity_form_mode' => '2', + 'block' => 23, + 'block_content' => 1, + 'block_content_type' => 1, + 'comment' => 0, + 'comment_type' => 3, + 'commerce_log' => 0, + 'commerce_order_type' => 1, + 'commerce_order' => 5, + 'commerce_order_item' => 6, + 'commerce_order_item_type' => 1, + 'commerce_payment' => 4, + 'commerce_payment_method' => 0, + 'commerce_payment_gateway' => 2, + 'commerce_product' => 5, + 'commerce_product_attribute' => 4, + 'commerce_product_attribute_value' => 7, + 'commerce_product_variation_type' => 4, + 'commerce_product_variation' => 5, + 'commerce_product_type' => 4, + 'commerce_promotion_coupon' => 0, + 'commerce_promotion' => 0, + 'commerce_currency' => 2, + 'commerce_shipping_method' => 2, + 'commerce_shipment_type' => 1, + 'commerce_store' => 1, + 'commerce_store_type' => 1, + 'commerce_tax_type' => 1, + 'contact_form' => 2, + 'contact_message' => 0, + 'editor' => 2, + 'field_config' => 41, + 'field_storage_config' => 27, + 'file' => 0, + 'filter_format' => 5, + 'image_style' => 3, + 'migration_group' => 1, + 'migration' => 0, + 'node_type' => 3, + 'node' => 1, + 'profile_type' => 1, + 'profile' => 4, + 'rdf_mapping' => 5, + 'search_page' => 2, + 'shortcut' => 2, + 'shortcut_set' => 1, + 'action' => 29, + 'menu' => 8, + 'taxonomy_vocabulary' => 2, + 'taxonomy_term' => 3, + 'tour' => 1, + 'user_role' => 5, + 'user' => 6, + 'menu_link_content' => 0, + 'view' => 24, + 'base_field_override' => 6, + 'date_format' => 11, + 'entity_view_display' => 29, + 'entity_view_mode' => 17, + 'entity_form_display' => 18, + 'entity_form_mode' => 2, ]; } diff --git a/modules/ubercart/tests/src/Functional/uc7/MigrateUpgradeUbercart7Test.php b/modules/ubercart/tests/src/Functional/uc7/MigrateUpgradeUbercart7Test.php new file mode 100644 index 0000000..f46fc7f --- /dev/null +++ b/modules/ubercart/tests/src/Functional/uc7/MigrateUpgradeUbercart7Test.php @@ -0,0 +1,174 @@ +loadFixture(drupal_get_path('module', 'commerce_migrate_ubercart') . '/tests/fixtures/uc7.php'); + } + + /** + * {@inheritdoc} + */ + protected function getSourceBasePath() { + return ''; + } + + /** + * {@inheritdoc} + */ + protected function getEntityCounts() { + return [ + 'action' => 25, + 'base_field_override' => 3, + 'block' => 28, + 'block_content' => 1, + 'block_content_type' => 1, + 'comment' => 1, + 'comment_type' => 5, + 'commerce_currency' => 1, + 'commerce_log' => 0, + 'commerce_order' => 4, + 'commerce_order_item' => 4, + 'commerce_order_item_type' => 1, + 'commerce_order_type' => 1, + 'commerce_package_type' => 0, + 'commerce_payment' => 4, + 'commerce_payment_gateway' => 1, + 'commerce_payment_method' => 0, + 'commerce_product' => 3, + 'commerce_product_attribute' => 4, + 'commerce_product_attribute_value' => 6, + 'commerce_product_type' => 3, + 'commerce_product_variation' => 3, + 'commerce_product_variation_type' => 3, + 'commerce_promotion' => 0, + 'commerce_promotion_coupon' => 0, + 'commerce_shipment' => 0, + 'commerce_shipment_type' => 1, + 'commerce_shipping_method' => 1, + 'commerce_store' => 1, + 'commerce_store_type' => 1, + 'commerce_tax_type' => 3, + 'contact_form' => 2, + 'contact_message' => 0, + 'date_format' => 11, + 'editor' => 2, + 'entity_form_display' => 19, + 'entity_form_mode' => 2, + 'entity_view_display' => 25, + 'entity_view_mode' => 16, + 'field_config' => 39, + 'field_storage_config' => 28, + 'file' => 1, + 'filter_format' => 5, + 'image_style' => 3, + 'menu' => 5, + 'menu_link_content' => 2, + 'migration' => 0, + 'migration_group' => 1, + 'node' => 2, + 'node_type' => 2, + 'profile' => 2, + 'profile_type' => 1, + 'rdf_mapping' => 5, + 'search_page' => 2, + 'shortcut' => 4, + 'shortcut_set' => 1, + 'taxonomy_term' => 1, + 'taxonomy_vocabulary' => 2, + 'tour' => 1, + 'user' => 4, + 'user_role' => 3, + 'view' => 24, + ]; + } + + /** + * {@inheritdoc} + */ + protected function getEntityCountsIncremental() {} + + /** + * {@inheritdoc} + */ + protected function getAvailablePaths() { + return []; + } + + /** + * {@inheritdoc} + */ + protected function getMissingPaths() { + return []; + } + +}