diff --git a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php index 383d4c3ab1..6ce595cffa 100644 --- a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php @@ -71,12 +71,12 @@ class MigrateUpgradeForm extends ConfirmFormBase { /** * List of modules that do not need an upgrade path. */ - public static $noUpgradePath = [ + protected $noUpgradePath = [ '6' => [ 'blog', 'color', - 'date_timezone', 'date_api', + 'date_timezone', 'help', 'i18n', 'i18nstrings', @@ -111,7 +111,6 @@ class MigrateUpgradeForm extends ConfirmFormBase { 'syslog', 'trigger', 'toolbar', - 'update', 'views', 'views_ui', ], @@ -210,7 +209,7 @@ public function buildOverviewForm(array $form, FormStateInterface $form_state) { $form['#title'] = $this->t('Upgrade'); // Add the no upgrade path array to the form state so it can be altered. - $form_state->set('no_upgrade_path', static::$noUpgradePath); + $form_state->set('no_upgrade_path', $this->noUpgradePath); if ($date_performed = $this->state->get('migrate_drupal_ui.performed')) { // @todo Add back support for rollbacks and incremental migrations. @@ -321,7 +320,7 @@ public function buildCredentialForm(array $form, FormStateInterface $form_state) '#type' => 'radios', '#default_value' => 7, '#title' => $this->t('Drupal version of the source site'), - '#options' => [6 => $this->t('Drupal 6'), 7 => $this->t('Drupal 7')], + '#options' => ['6' => $this->t('Drupal 6'), '7' => $this->t('Drupal 7')], '#required' => TRUE, ]; @@ -384,7 +383,7 @@ public function buildCredentialForm(array $form, FormStateInterface $form_state) '#description' => $this->t('To import files from your current Drupal site, enter a local file directory containing your site (e.g. /var/www/docroot), or your site address (for example http://example.com).'), '#states' => [ 'visible' => [ - ':input[name="version"]' => ['value' => 6], + ':input[name="version"]' => ['value' => '6'], ], ], ]; @@ -395,7 +394,7 @@ public function buildCredentialForm(array $form, FormStateInterface $form_state) '#description' => $this->t('To import public files from your current Drupal site, enter a local file directory containing your site (e.g. /var/www/docroot), or your site address (for example http://example.com).'), '#states' => [ 'visible' => [ - ':input[name="version"]' => ['value' => 7], + ':input[name="version"]' => ['value' => '7'], ], ], ]; @@ -407,7 +406,7 @@ public function buildCredentialForm(array $form, FormStateInterface $form_state) '#description' => $this->t('To import private files from your current Drupal site, enter a local file directory containing your site (e.g. /var/www/docroot).'), '#states' => [ 'visible' => [ - ':input[name="version"]' => ['value' => 7], + ':input[name="version"]' => ['value' => '7'], ], ], ]; @@ -456,7 +455,7 @@ public function validateCredentialForm(array &$form, FormStateInterface $form_st try { $connection = $this->getConnection($database); - $version = $this->getLegacyDrupalVersion($connection); + $version = (string) $this->getLegacyDrupalVersion($connection); if (!$version) { $form_state->setErrorByName($database['driver'] . '][0', $this->t('Source database does not contain a recognizable Drupal version.')); } @@ -483,7 +482,7 @@ public function validateCredentialForm(array &$form, FormStateInterface $form_st // Store the retrieved migration IDs in form storage. $form_state->set('version', $version); $form_state->set('migrations', $migration_array); - if ($version == 6) { + if ($version == '6') { $form_state->set('source_base_path', $form_state->getValue('d6_source_base_path')); } else { @@ -724,7 +723,7 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) { $system_data = $form_state->get('system_data'); // Add source_module and destination_module for modules that do not need an - // upgrade path and are enabled on the source site.. + // upgrade path and are enabled on the source site. $no_upgrade_path = $form_state->get('no_upgrade_path'); foreach ($no_upgrade_path[$version] as $module) { if ($system_data['module'][$module]['status']) { diff --git a/core/modules/migrate_drupal_ui/tests/modules/upgrade_form_alter_test/upgrade_form_alter_test.info.yml b/core/modules/migrate_drupal_ui/tests/modules/upgrade_form_alter_test/upgrade_form_alter_test.info.yml new file mode 100644 index 0000000000..c6b66cdb34 --- /dev/null +++ b/core/modules/migrate_drupal_ui/tests/modules/upgrade_form_alter_test/upgrade_form_alter_test.info.yml @@ -0,0 +1,6 @@ +name: 'Upgrade form alter test' +type: module +description: 'Tests that contrib modules can alter the upgrade form.' +package: Testing +version: VERSION +core: 8.x diff --git a/core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/migration_provider_test.module b/core/modules/migrate_drupal_ui/tests/modules/upgrade_form_alter_test/upgrade_form_alter_test.module similarity index 61% rename from core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/migration_provider_test.module rename to core/modules/migrate_drupal_ui/tests/modules/upgrade_form_alter_test/upgrade_form_alter_test.module index 0038375f74..499a0dbbe2 100644 --- a/core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/migration_provider_test.module +++ b/core/modules/migrate_drupal_ui/tests/modules/upgrade_form_alter_test/upgrade_form_alter_test.module @@ -2,7 +2,7 @@ /** * @file - * Test module for testing the migrate UI. + * Test module for altering the upgrade form. */ use Drupal\Core\Form\FormStateInterface; @@ -10,9 +10,9 @@ /** * Implements hook_form_FORM_ID_alter(). */ -function migration_provider_test_form_migrate_drupal_ui_form_alter(&$form, FormStateInterface $form_state, $form_id) { +function upgrade_form_alter_test_form_migrate_drupal_ui_form_alter(&$form, FormStateInterface $form_state, $form_id) { $no_upgrade_path = $form_state->get('no_upgrade_path'); - $no_upgrade_path[6][] = 'views_ui'; - $no_upgrade_path[7][] = 'views_ui'; + $no_upgrade_path['6'][] = 'event'; + $no_upgrade_path['7'][] = 'book'; $form_state->set('no_upgrade_path', $no_upgrade_path); } 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 6f3149af64..eafe5a4b56 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php @@ -37,6 +37,7 @@ */ public static $modules = [ 'language', + 'config_translation', 'content_translation', 'migrate_drupal_ui', 'telephone', @@ -44,24 +45,13 @@ 'book', 'forum', 'statistics', + 'tracker', + 'update', 'migration_provider_test', + 'upgrade_form_alter_test', ]; /** - * Count of modules that will not be upgraded. - * - * @var array - */ - public static $missing_count; - - /** - * Count of modules that will be upgraded. - * - * @var array - */ - public static $available_count; - - /** * {@inheritdoc} */ protected function setUp() { @@ -233,8 +223,8 @@ public function testMigrateUpgrade() { } // Test the total count of missing and available paths. - $session->elementsCount('xpath', "//span[contains(@class, 'upgrade-analysis-report__status-icon--warning')]", (int) static::$missing_count); - $session->elementsCount('xpath', "//span[contains(@class, 'upgrade-analysis-report__status-icon--checked')]", (int) static::$available_count); + $session->elementsCount('xpath', "//span[contains(@class, 'upgrade-analysis-report__status-icon--warning')]", count($this->getMissingPaths())); + $session->elementsCount('xpath', "//span[contains(@class, 'upgrade-analysis-report__status-icon--checked')]", count($this->getAvailablePaths())); $this->drupalPostForm(NULL, [], t('Perform upgrade')); $this->assertText(t('Congratulations, you upgraded Drupal!')); 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 c5a5f318fe..5e3b83c62d 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 @@ -17,16 +17,6 @@ class MigrateUpgrade6Test extends MigrateUpgradeTestBase { /** * {@inheritdoc} */ - public static $missing_count = 6; - - /** - * {@inheritdoc} - */ - public static $available_count = 52; - - /** - * {@inheritdoc} - */ protected function setUp() { parent::setUp(); $this->loadFixture(drupal_get_path('module', 'migrate_drupal') . '/tests/fixtures/drupal6.php'); @@ -75,7 +65,7 @@ protected function getEntityCounts() { 'menu' => 8, 'taxonomy_term' => 8, 'taxonomy_vocabulary' => 7, - 'tour' => 4, + 'tour' => 5, 'user' => 7, 'user_role' => 6, 'menu_link_content' => 5, @@ -106,46 +96,42 @@ protected function getAvailablePaths() { 'filefield', 'filter', 'forum', + 'i18nprofile', 'i18ntaxonomy', 'imagecache', 'imagefield', + 'language', 'link', - 'menu', 'locale', + 'menu', 'node', 'nodereference', 'optionwidgets', 'path', - 'profile', 'search', + 'statistics', 'system', 'taxonomy', 'text', 'translation', + 'update', 'upload', 'user', 'userreference', // Modules that have no upgrade path. - 'blog', - 'color', - 'date_timezone', 'date_api', - 'help', + 'date_timezone', 'i18n', 'i18nstrings', 'imageapi', - 'openid', + 'number', 'php', - 'poll', 'profile', - 'trigger', - 'tracker', - 'variable', 'variable_admin', - 'views', - 'views_export', - // views_ui is added to this list by - // migration_provider_test_form_migrate_drupal_ui_form_alter(). + // To test that contrib modules can alter this list, Event is added here + // by a hook_form_alter(). + // See upgrade_form_alter_test_form_migrate_drupal_ui_form_alter(). + 'event', ]; } @@ -154,10 +140,14 @@ protected function getAvailablePaths() { */ protected function getMissingPaths() { return [ - 'event', + // To test that contrib modules can alter this list, Event is removed from + // here by a hook_form_alter(). + // See upgrade_form_alter_test_form_migrate_drupal_ui_form_alter(). + // 'event', 'i18nblocks', 'i18ncck', 'i18ncontent', + 'i18nmenu', ]; } 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 66b1bb5124..0cbd239883 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 @@ -22,16 +22,6 @@ class MigrateUpgrade7Test extends MigrateUpgradeTestBase { /** * {@inheritdoc} */ - public static $missing_count = 4; - - /** - * {@inheritdoc} - */ - public static $available_count = 51; - - /** - * {@inheritdoc} - */ protected function setUp() { parent::setUp(); $this->loadFixture(drupal_get_path('module', 'migrate_drupal') . '/tests/fixtures/drupal7.php'); @@ -79,7 +69,7 @@ protected function getEntityCounts() { 'menu' => 6, 'taxonomy_term' => 18, 'taxonomy_vocabulary' => 4, - 'tour' => 4, + 'tour' => 5, 'user' => 4, 'user_role' => 3, 'menu_link_content' => 8, @@ -112,6 +102,7 @@ protected function getAvailablePaths() { 'filter', 'forum', 'image', + 'language', 'link', 'list', 'locale', @@ -127,29 +118,26 @@ protected function getAvailablePaths() { 'system', 'taxonomy', 'text', + 'tracker', 'translation', - 'user', 'update', + 'user', // Modules that have no upgrade path. 'blog', 'contextual', - 'dashboard', 'date_api', 'entity', 'field_ui', 'help', - 'openid', - 'overlay', 'php', - 'poll', - 'profile', 'simpletest', 'syslog', - 'trigger', 'toolbar', - 'views', - // views_ui is added to this list by - // migration_provider_test_form_migrate_drupal_ui_form_alter(). + 'trigger', + // To test that contrib modules can alter this list, Book is added here + // by a hook_form_alter(). + // See upgrade_form_alter_test_form_migrate_drupal_ui_form_alter(). + 'book', ]; } @@ -158,7 +146,10 @@ protected function getAvailablePaths() { */ protected function getMissingPaths() { return [ - 'book', + // To test that contrib modules can alter this list, Book is removed from + // here by a hook_form_alter(). + // See upgrade_form_alter_test_form_migrate_drupal_ui_form_alter(). + // 'book', 'color', 'rdf', ];