diff -u b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6I18nTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6I18nTest.php --- b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6I18nTest.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6I18nTest.php @@ -104,9 +104,6 @@ $counts = $this->getEntityCounts(); $counts['block_content'] = 3; $counts['comment'] = 7; - $counts['entity_view_display'] = 55; - $counts['entity_view_mode'] = 14; - $counts['file'] = 9; $counts['menu_link_content'] = 9; $counts['node'] = 18; $counts['taxonomy_term'] = 9; @@ -278,7 +275,7 @@ $this->assertReviewPage($session, $available_paths, $missing_paths); $this->drupalPostForm(NULL, [], t('Perform upgrade')); - $this->assertText(t('Congratulations, you upgraded Drupal!')); + $session->pageTextContains(t('Congratulations, you upgraded Drupal!')); $this->assertMigrationResults($this->getEntityCounts(), $version); \Drupal::service('module_installer')->install(['forum']); @@ -325,8 +322,7 @@ /** * Tests that follow-up migrations have been run successfully. */ - protected - function assertFollowUpMigrationResults() { + protected function assertFollowUpMigrationResults() { $node = Node::load(10); $this->assertSame('13', $node->get('field_reference')->target_id); $this->assertSame('13', $node->get('field_reference_2')->target_id); @@ -341,8 +337,7 @@ /** * {@inheritdoc} */ - protected - function assertIdConflict(WebAssert $session) { + protected function assertIdConflict(WebAssert $session) { $session->pageTextContains('WARNING: Content may be overwritten on your new site.'); $session->pageTextContains('There is conflicting content of these types:'); $session->pageTextContains('aggregator feed items'); diff -u b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php --- b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php @@ -23,7 +23,6 @@ public static $modules = [ 'file', 'language', - 'content_translation', 'migrate_drupal_ui', 'telephone', 'aggregator', only in patch2: unchanged: --- /dev/null +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7I18nTest.php @@ -0,0 +1,360 @@ +loadFixture(drupal_get_path('module', 'migrate_drupal') . '/tests/fixtures/drupal7.php'); + } + + /** + * {@inheritdoc} + */ + protected function getSourceBasePath() { + return __DIR__ . '/files'; + } + + /** + * {@inheritdoc} + */ + protected function getEntityCounts() { + return [ + 'aggregator_item' => 11, + 'aggregator_feed' => 1, + 'block' => 25, + 'block_content' => 1, + 'block_content_type' => 1, + 'comment' => 1, + // The 'standard' profile provides the 'comment' comment type, and the + // migration creates 6 comment types, one per node type. + 'comment_type' => 7, + // Module 'language' comes with 'en', 'und', 'zxx'. Migration adds 'is'. + 'configurable_language' => 4, + 'contact_form' => 3, + 'editor' => 2, + 'field_config' => 66, + 'field_storage_config' => 49, + 'file' => 3, + 'filter_format' => 7, + 'image_style' => 6, + 'language_content_settings' => 2, + 'migration' => 73, + 'node' => 5, + 'node_type' => 6, + 'rdf_mapping' => 7, + 'search_page' => 2, + 'shortcut' => 6, + 'shortcut_set' => 2, + 'action' => 17, + 'menu' => 6, + 'taxonomy_term' => 18, + 'taxonomy_vocabulary' => 4, + 'tour' => 4, + 'user' => 4, + 'user_role' => 3, + 'menu_link_content' => 10, + 'view' => 16, + 'date_format' => 11, + 'entity_form_display' => 17, + 'entity_form_mode' => 1, + 'entity_view_display' => 28, + 'entity_view_mode' => 14, + 'base_field_override' => 9, + ]; + } + + /** + * {@inheritdoc} + */ + protected function getEntityCountsIncremental() { + $counts = $this->getEntityCounts(); + $counts['block_content'] = 2; + $counts['comment'] = 2; + $counts['file'] = 4; + $counts['menu_link_content'] = 11; + $counts['node'] = 6; + $counts['taxonomy_term'] = 19; + $counts['user'] = 5; + return $counts; + } + + /** + * {@inheritdoc} + */ + protected function getAvailablePaths() { + return [ + 'aggregator', + 'block', + 'book', + 'color', + 'comment', + 'contact', + 'date', + 'dblog', + 'email', + 'entityreference', + 'field', + 'field_sql_storage', + 'file', + 'filter', + 'forum', + 'image', + 'language', + 'link', + 'list', + 'locale', + 'menu', + 'node', + 'number', + 'options', + 'path', + 'phone', + 'search', + 'shortcut', + 'statistics', + 'system', + 'taxonomy', + 'text', + 'user', + // Include modules that do not have an upgrade path and are enabled in the + // source database, defined in the $noUpgradePath property + // in MigrateUpgradeForm. + 'blog', + 'contextual', + 'date_api', + 'entity', + 'field_ui', + 'help', + 'php', + 'simpletest', + 'toolbar', + 'translation', + 'trigger', + ]; + } + + /** + * {@inheritdoc} + */ + protected function getMissingPaths() { + return [ + 'rdf', + // These modules are in the missing path list because they are installed + // on the source site but they are not installed on the destination site. + 'syslog', + 'tracker', + 'update', + ]; + } + + /** + * {@inheritdoc} + */ + public function testMigrateUpgradeExecute() { + + $connection_options = $this->sourceDatabase->getConnectionOptions(); + $this->drupalGet('/upgrade'); + $session = $this->assertSession(); + $session->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.'); + + $this->drupalPostForm(NULL, [], t('Continue')); + $session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.'); + $session->fieldExists('mysql[host]'); + + $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); + + // Ensure submitting the form with invalid database credentials gives us a + // nice warning. + $this->drupalPostForm(NULL, [$driver . '[database]' => 'wrong'] + $edits, t('Review upgrade')); + $session->pageTextContains('Resolve all issues below to continue the upgrade.'); + + $this->drupalPostForm(NULL, $edits, t('Review upgrade')); + // Ensure we get errors about missing modules. + $session->pageTextContains(t('Resolve all issues below to continue the upgrade.')); + $session->pageTextContains(t('The no_source_module plugin must define the source_module property.')); + + // Uninstall the module causing the missing module error messages. + $this->container->get('module_installer') + ->uninstall(['migration_provider_test'], TRUE); + + // Test the file sources. + $this->drupalGet('/upgrade'); + $this->drupalPostForm(NULL, [], t('Continue')); + if ($version == 6) { + $paths['d6_source_base_path'] = DRUPAL_ROOT . '/wrong-path'; + } + else { + $paths['source_base_path'] = 'https://example.com/wrong-path'; + $paths['source_private_file_path'] = DRUPAL_ROOT . '/wrong-path'; + } + $this->drupalPostForm(NULL, $paths + $edits, t('Review upgrade')); + if ($version == 6) { + $session->responseContains('Unable to read from Files directory.'); + } + else { + $session->responseContains('Unable to read from Public files directory.'); + $session->responseContains('Unable to read from Private files directory.'); + } + + // Restart the upgrade process. + $this->drupalGet('/upgrade'); + $session->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.'); + + $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')); + $this->assertIdConflict($session); + + $this->drupalPostForm(NULL, [], t('I acknowledge I may lose data. Continue anyway.')); + $session->statusCodeEquals(200); + + // Ensure there are no errors about missing modules from the test module. + $session->pageTextNotContains(t('Source module not found for migration_provider_no_annotation.')); + $session->pageTextNotContains(t('Source module not found for migration_provider_test.')); + // Ensure there are no errors about any other missing migration providers. + $session->pageTextNotContains(t('module not found')); + + // Test the upgrade paths. + $available_paths = $this->getAvailablePaths(); + $missing_paths = $this->getMissingPaths(); + $this->assertReviewPage($session, $available_paths, $missing_paths); + + $this->drupalPostForm(NULL, [], t('Perform upgrade')); + $session->pageTextContains(t('Congratulations, you upgraded Drupal!')); + $this->assertMigrationResults($this->getEntityCounts(), $version); + + \Drupal::service('module_installer')->install(['forum']); + \Drupal::service('module_installer')->install(['book']); + + // Test incremental migration. + $this->createContentPostUpgrade(); + + $this->drupalGet('/upgrade'); + $session->pageTextContains('An upgrade has already been performed on this site. To perform a new migration, create a clean and empty new install of Drupal 8. Rollbacks are not yet supported through the user interface.'); + $this->drupalPostForm(NULL, [], t('Import new configuration and content from old site')); + $this->drupalPostForm(NULL, $edits, t('Review upgrade')); + $session->pageTextContains('WARNING: Content may be overwritten on your new site.'); + $session->pageTextContains('There is conflicting content of these types:'); + $session->pageTextContains('comments'); + $session->pageTextContains('content item revisions'); + $session->pageTextContains('content items'); + $session->pageTextContains('custom blocks'); + $session->pageTextContains('custom menu links'); + $session->pageTextContains('files'); + $session->pageTextContains('taxonomy terms'); + $session->pageTextContains('users'); + + $this->drupalPostForm(NULL, [], t('I acknowledge I may lose data. Continue anyway.')); + $session->statusCodeEquals(200); + + // Need to update available and missing path lists. + $all_available = $this->getAvailablePaths(); + $all_available[] = 'aggregator'; + $all_missing = $this->getMissingPaths(); + $all_missing = array_diff($all_missing, ['aggregator']); + $this->assertReviewPage($session, $all_available, $all_missing); + $this->drupalPostForm(NULL, [], t('Perform upgrade')); + $session->pageTextContains(t('Congratulations, you upgraded Drupal!')); + $this->assertMigrationResults($this->getEntityCountsIncremental(), $version); + + // Ensure migrated users can log in. + $user = User::load(2); + $user->passRaw = 'john.doe_pass'; + $this->drupalLogin($user); + $this->assertFollowUpMigrationResults(); + } + + /** + * Tests that follow-up migrations have been run successfully. + */ + protected function assertFollowUpMigrationResults() { + $node = Node::load(10); + $this->assertSame('13', $node->get('field_reference')->target_id); + $this->assertSame('13', $node->get('field_reference_2')->target_id); + $this->assertFalse($node->hasTranslation('fr')); + + $node = Node::load(12); + $this->assertFalse($node->hasTranslation('en')); + $this->assertNull($node->get('field_reference')->target_id); + $this->assertNull($node->get('field_reference_2')->target_id); + } + + /** + * {@inheritdoc} + */ + protected function assertIdConflict(WebAssert $session) { + $session->pageTextContains('WARNING: Content may be overwritten on your new site.'); + $session->pageTextContains('There is conflicting content of these types:'); + $session->pageTextContains('aggregator feed items'); + $session->pageTextContains('aggregator feeds'); + $session->pageTextContains('files'); + $session->pageTextContains('comments'); + $session->pageTextContains('content item revisions'); + $session->pageTextContains('content items'); + $session->pageTextContains('custom blocks'); + $session->pageTextContains('custom menu links'); + $session->pageTextContains('files'); + $session->pageTextContains('taxonomy terms'); + $session->pageTextContains('users'); + } + +}