diff --git a/modules/ubercart/tests/src/Functional/uc6/MigrateUpgradeReviewPageTestBase.php b/modules/ubercart/tests/src/Functional/MigrateUpgradeReviewPageTestBase.php similarity index 98% rename from modules/ubercart/tests/src/Functional/uc6/MigrateUpgradeReviewPageTestBase.php rename to modules/ubercart/tests/src/Functional/MigrateUpgradeReviewPageTestBase.php index 56d7552..5b7855a 100644 --- a/modules/ubercart/tests/src/Functional/uc6/MigrateUpgradeReviewPageTestBase.php +++ b/modules/ubercart/tests/src/Functional/MigrateUpgradeReviewPageTestBase.php @@ -1,6 +1,6 @@ loadFixture(drupal_get_path('module', 'commerce_migrate_ubercart') . '/tests/fixtures/uc6.php'); + $this->loadFixture(drupal_get_path('module', 'commerce_migrate_ubercart') . '/tests/fixtures/uc7.php'); } /** @@ -58,83 +60,67 @@ class MigrateUpgradeReviewPageTest extends MigrateUpgradeReviewPageTestBase { protected function getAvailablePaths() { $paths = [ 'action', + 'addressfield', 'block', 'blog', - 'blogapi', - 'calendarsignup', + 'bulk_export', 'color', 'comment', 'contact', - 'content', - 'content_copy', - 'content_multigroup', - 'content_permissions', + 'contextual', + 'ctools', + 'ctools_access_ruleset', + 'ctools_ajax_sample', + 'ctools_custom_content', + 'dashboard', 'date', - 'date_locale', - 'date_php4', - 'date_repeat', - 'date_timezone', - 'date_tools', - 'datepicker', 'dblog', 'email', - 'event', - 'fieldgroup', - 'filefield', - 'filefield_meta', + 'entity', + 'entity_feature', + 'entity_token', + 'entityreference', + 'field', + 'field_sql_storage', + 'field_ui', + 'file', 'filter', 'help', - 'i18nstrings', - 'imageapi', - 'imageapi_gd', - 'imageapi_imagemagick', - 'imagecache', - 'imagecache_ui', - 'imagefield', - 'jquery_ui', + 'image', 'link', + 'list', 'menu', 'node', - 'nodereference', + 'number', 'openid', - 'optionwidgets', + 'options', + 'overlay', + 'page_manager', 'path', + 'phone', 'php', - 'ping', 'poll', 'profile', + 'rdf', 'search', + 'search_embedded_form', + 'search_extra_type', + 'search_node_tags', + 'shortcut', + 'simpletest', + 'stylizer', 'system', 'taxonomy', + 'term_depth', 'text', - 'throttle', - 'tracker', + 'toolbar', 'translation', 'trigger', - 'uc_attribute', - 'uc_flatrate', - 'uc_order', - 'uc_product', 'uc_store', - 'upload', 'user', - 'userreference', - 'variable', - 'variable_admin', - 'views_export', - // Include modules that do not have an upgrade path, defined in the - // $noUpgradePath property in MigrateUpgradeForm. - 'date_api', - 'date_popup', - 'number', + 'views_content', 'views_ui', ]; - // TODO: remove after 8.5 is sunset. - // See https://www.drupal.org/project/commerce_migrate/issues/2976114 - $version = _install_get_version_info(\Drupal::VERSION); - if ($version['minor'] == 5) { - $paths[] = 'i18nmenu'; - } return $paths; } @@ -145,31 +131,20 @@ class MigrateUpgradeReviewPageTest extends MigrateUpgradeReviewPageTestBase { $paths = [ 'aggregator', 'book', - 'ca', - 'date_copy', - 'devel', - 'devel_generate', - 'devel_node_access', 'forum', - 'i18n', - 'i18nblocks', - 'i18ncck', - 'i18ncontent', - 'i18nmenu', - 'i18npoll', - 'i18nprofile', - 'i18nsync', - 'i18ntaxonomy', - 'i18nviews', 'locale', - 'phone', + 'rules', + 'rules_admin', + 'rules_i18n', + 'rules_scheduler', 'statistics', 'syslog', 'test_gateway', 'token', - 'tokenSTARTER', - 'token_actions', + 'tracker', 'uc_2checkout', + 'uc_ajax_admin', + 'uc_attribute', 'uc_authorizenet', 'uc_cart', 'uc_cart_links', @@ -177,11 +152,14 @@ class MigrateUpgradeReviewPageTest extends MigrateUpgradeReviewPageTestBase { 'uc_credit', 'uc_cybersource', 'uc_file', + 'uc_flatrate', 'uc_google_checkout', 'uc_googleanalytics', + 'uc_order', 'uc_payment', 'uc_payment_pack', 'uc_paypal', + 'uc_product', 'uc_product_kit', 'uc_quote', 'uc_reports', @@ -196,13 +174,6 @@ class MigrateUpgradeReviewPageTest extends MigrateUpgradeReviewPageTestBase { 'update', 'views', ]; - // TODO: remove after 8.5 is sunset. - // See https://www.drupal.org/project/commerce_migrate/issues/2976114 - $version = _install_get_version_info(\Drupal::VERSION); - if ($version['minor'] == 5) { - $key = array_search('i18nmenu', $paths); - unset($paths[$key]); - } return $paths; } 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..4eeaf93 --- /dev/null +++ b/modules/ubercart/tests/src/Functional/uc7/MigrateUpgradeUbercart7Test.php @@ -0,0 +1,261 @@ +loadFixture(drupal_get_path('module', 'commerce_migrate_ubercart') . '/tests/fixtures/uc7.php'); + } + + /** + * 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() { + return ''; + } + + /** + * {@inheritdoc} + */ + protected function getEntityCounts() { + return [ + 'action' => '25', + 'base_field_override' => '4', + 'block' => '28', + 'block_content' => '0', + 'block_content_type' => '1', + 'comment' => '0', + 'comment_type' => '4', + 'commerce_currency' => '1', + 'commerce_log' => '0', + 'commerce_order' => '0', + 'commerce_order_item' => '0', + 'commerce_order_item_type' => '1', + 'commerce_order_type' => '1', + 'commerce_package_type' => '0', + 'commerce_payment' => '0', + 'commerce_payment_gateway' => '0', + 'commerce_payment_method' => '0', + 'commerce_product' => '0', + 'commerce_product_attribute' => '0', + 'commerce_product_attribute_value' => '0', + 'commerce_product_type' => '1', + 'commerce_product_variation' => '0', + 'commerce_product_variation_type' => '1', + 'commerce_promotion' => '0', + 'commerce_promotion_coupon' => '0', + 'commerce_shipment' => '0', + 'commerce_shipment_type' => '1', + 'commerce_shipping_method' => '0', + 'commerce_store' => '1', + 'commerce_store_type' => '1', + 'commerce_tax_type' => '0', + 'contact_form' => '2', + 'contact_message' => '0', + 'date_format' => '11', + 'editor' => '2', + 'entity_form_display' => '17', + 'entity_form_mode' => '2', + 'entity_view_display' => '23', + 'entity_view_mode' => '14', + 'field_config' => '25', + 'field_storage_config' => '20', + 'file' => '0', + 'filter_format' => '5', + 'image_style' => '3', + 'menu' => '5', + 'menu_link_content' => '1', + 'migration' => '0', + 'migration_group' => '1', + 'node' => '3', + 'node_type' => '3', + 'profile' => '0', + 'profile_type' => '1', + 'rdf_mapping' => '5', + 'search_page' => '2', + 'shortcut' => '4', + 'shortcut_set' => '1', + 'taxonomy_term' => '0', + 'taxonomy_vocabulary' => '2', + 'tour' => '1', + 'user' => '3', + 'user_role' => '3', + 'view' => '24', + ]; + } + + /** + * {@inheritdoc} + */ + protected function getEntityCountsIncremental() {} + + /** + * {@inheritdoc} + */ + protected function getAvailablePaths() { + return []; + } + + /** + * {@inheritdoc} + */ + protected function getMissingPaths() { + return []; + } + +}