Skip to content
Snippets Groups Projects
Commit 88272aea authored by catch's avatar catch
Browse files

Issue #3175953 by quietone, adityasingh, ayushmishra206, benjifisher: Cleanup...

Issue #3175953 by quietone, adityasingh, ayushmishra206, benjifisher: Cleanup migrate drupal functional tests
parent 5373cd02
Branches
Tags
6 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!16Draft: Resolve #2081585 "History storage"
Showing
with 68 additions and 219 deletions
......@@ -23,55 +23,16 @@ protected function setUp() {
}
/**
* Executes all steps of migrations upgrade.
*
* The upgrade is started three times. The first time is to test that
* providing incorrect database credentials fails as expected. The second
* time is to run the migration and assert the results. The third time is
* to test an incremental migration, by installing the aggregator module,
* and assert the results.
* Executes an upgrade and then an incremental upgrade.
*/
public function testMigrateUpgradeExecute() {
$this->drupalGet('/upgrade');
public function doUpgradeAndIncremental() {
// Start the upgrade process.
$this->submitCredentialForm();
$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 $this->destinationSiteVersion.");
$this->submitForm([], 'Continue');
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
$session->fieldExists('mysql[host]');
// Get valid credentials.
$edits = $this->translatePostValues($this->getCredentials());
$this->submitForm($edits, 'Review upgrade');
// 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 $this->destinationSiteVersion.");
$this->submitForm([], 'Continue');
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
$session->fieldExists('mysql[host]');
$this->submitForm($edits, 'Review upgrade');
$entity_types = [
'block_content',
'menu_link_content',
'file',
'taxonomy_term',
'user',
];
$this->assertIdConflictForm($entity_types);
$this->submitForm([], '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 review form.
$this->assertReviewForm();
......@@ -87,13 +48,7 @@ public function testMigrateUpgradeExecute() {
$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 $this->destinationSiteVersion. Rollbacks are not yet supported through the user interface.");
$this->submitForm([], 'Import new configuration and content from old site');
$this->submitForm($edits, 'Review upgrade');
$session->pageTextContains('WARNING: Content may be overwritten on your new site.');
$session->pageTextContains('There is conflicting content of these types:');
$session->pageTextContains('files');
$session->pageTextContains('There is translated content of these types:');
$session->pageTextContainsOnce('content items');
$this->submitForm($this->edits, 'Review upgrade');
$this->submitForm([], 'I acknowledge I may lose data. Continue anyway.');
$session->statusCodeEquals(200);
......
......@@ -7,7 +7,6 @@
use Drupal\migrate_drupal\MigrationConfigurationTrait;
use Drupal\user\Entity\User;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\migrate_drupal\Traits\CreateTestContentEntitiesTrait;
/**
* Provides a base class for testing migration upgrades in the UI.
......@@ -15,7 +14,6 @@
abstract class MigrateUpgradeTestBase extends BrowserTestBase {
use MigrationConfigurationTrait;
use CreateTestContentEntitiesTrait;
/**
* Use the Standard profile to test help implementations of many core modules.
......@@ -38,6 +36,13 @@ abstract class MigrateUpgradeTestBase extends BrowserTestBase {
*/
protected $destinationSiteVersion;
/**
* Input data for the credential form.
*
* @var array
*/
protected $edits;
/**
* {@inheritdoc}
*/
......@@ -53,6 +58,20 @@ protected function setUp() {
$this->drupalLogin($this->rootUser);
}
/**
* Navigates to the credential form and submits valid credentials.
*/
public function submitCredentialForm() {
$this->drupalGet('/upgrade');
$this->submitForm([], 'Continue');
// Get valid credentials.
$this->edits = $this->translatePostValues($this->getCredentials());
// When the Credential form is submitted the migrate map tables are created.
$this->submitForm($this->edits, 'Review upgrade');
}
/**
* Loads a database fixture into the source database connection.
*
......
......@@ -43,23 +43,9 @@ abstract class MultilingualReviewPageTestBase extends MigrateUpgradeTestBase {
public function testMigrateUpgradeReviewPage() {
$this->prepare();
// Start the upgrade process.
$this->drupalGet('/upgrade');
$this->submitForm([], 'Continue');
// Get valid credentials.
$edits = $this->translatePostValues($this->getCredentials());
$this->submitForm($edits, 'Review upgrade');
$this->submitCredentialForm();
$this->submitForm([], 'I acknowledge I may lose data. Continue anyway.');
// Ensure there are no errors about missing modules from the test module.
$session = $this->assertSession();
$session->pageTextNotContains(t('Source module not found for migration_provider_no_annotation.'));
$session->pageTextNotContains(t('Source module not found for migration_provider_test.'));
$session->pageTextNotContains(t('Destination 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.
$this->assertReviewForm();
......@@ -76,7 +62,7 @@ public function testMigrateUpgradeReviewPage() {
// Start the upgrade process.
$this->drupalGet('/upgrade');
$this->submitForm([], 'Continue');
$this->submitForm($edits, 'Review upgrade');
$this->submitForm($this->edits, 'Review upgrade');
$this->submitForm([], 'I acknowledge I may lose data. Continue anyway.');
// Test the upgrade paths. First remove the module from the available paths
......
......@@ -15,31 +15,12 @@ abstract class NoMultilingualReviewPageTestBase extends MultilingualReviewPageTe
public function testMigrateUpgradeReviewPage() {
$this->prepare();
// Start the upgrade process.
$this->drupalGet('/upgrade');
$this->submitForm([], 'Continue');
// Get valid credentials.
$edits = $this->translatePostValues($this->getCredentials());
$this->submitForm($edits, 'Review upgrade');
$this->submitCredentialForm();
$session = $this->assertSession();
$session->pageTextContains('WARNING: Content may be overwritten on your new site.');
$session->pageTextContains('There is conflicting content of these types:');
$session->pageTextContains('taxonomy terms');
$session->pageTextContains('There is translated content of these types:');
$session->pageTextContainsOnce('content items');
$this->submitForm([], '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.'));
$session->pageTextNotContains(t('Destination 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.
$this->assertReviewForm();
}
......
......@@ -27,39 +27,9 @@ public function testSourceProvider($path_to_database) {
$this->loadFixture(drupal_get_path('module', 'migrate_drupal') . $path_to_database);
$session = $this->assertSession();
$connection_options = $this->sourceDatabase->getConnectionOptions();
$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.
$this->drupalGet('/upgrade');
[$new_site_version] = explode('.', \Drupal::VERSION, 2);
$session->responseContains("Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal $new_site_version.");
$this->submitForm([], 'Continue');
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
$session->fieldExists('mysql[host]');
$this->submitForm($edits, 'Review upgrade');
// Start the upgrade process.
$this->submitCredentialForm();
// Ensure we get errors about missing modules.
$session->pageTextContains(t('Resolve all issues below to continue the upgrade.'));
......@@ -71,11 +41,8 @@ public function testSourceProvider($path_to_database) {
// Restart the upgrade process and test there is no source_module error.
$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 $new_site_version.");
$this->submitForm([], 'Continue');
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
$session->fieldExists('mysql[host]');
$this->submitForm($edits, 'Review upgrade');
$this->submitForm($this->edits, 'Review upgrade');
// Ensure there are no errors about missing modules from the test module.
$session->pageTextNotContains(t('Source module not found for migration_provider_no_annotation.'));
......
......@@ -15,15 +15,15 @@ class IdConflictTest extends MigrateUpgradeExecuteTestBase {
* {@inheritdoc}
*/
protected static $modules = [
'language',
'content_translation',
'config_translation',
'migrate_drupal_ui',
'telephone',
'aggregator',
'book',
'config_translation',
'content_translation',
'forum',
'language',
'migrate_drupal_ui',
'statistics',
'telephone',
// Required for translation migrations.
'migrate_drupal_multilingual',
];
......@@ -70,27 +70,10 @@ protected function getMissingPaths() {
/**
* Tests ID Conflict form.
*/
public function testMigrateUpgradeExecute() {
$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 $this->destinationSiteVersion.");
$this->submitForm([], 'Continue');
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
$session->fieldExists('mysql[host]');
// Get valid credentials.
$edits = $this->translatePostValues($this->getCredentials());
public function testIdConflictForm() {
// Start 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 $this->destinationSiteVersion.");
$this->submitForm([], 'Continue');
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
$session->fieldExists('mysql[host]');
$this->submitCredentialForm();
$this->submitForm($edits, 'Review upgrade');
$entity_types = [
'block_content',
'menu_link_content',
......
......@@ -75,33 +75,14 @@ protected function getMissingPaths() {
}
/**
* Tests ID Conflict form.
* Tests node classic migration via the UI.
*/
public function testMigrateUpgradeExecute() {
public function testNodeClassicUpgrade() {
// Add a node classic migrate table to d8.
$this->makeNodeMigrateMapTable(NodeMigrateType::NODE_MIGRATE_TYPE_CLASSIC, '6');
$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 $this->destinationSiteVersion.");
$this->submitForm([], 'Continue');
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
$session->fieldExists('mysql[host]');
// Get valid credentials.
$edits = $this->translatePostValues($this->getCredentials());
// Start 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 $this->destinationSiteVersion.");
$this->submitForm([], 'Continue');
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
$session->fieldExists('mysql[host]');
// When the Credential form is submitted the migrate map tables are created.
$this->submitForm($edits, 'Review upgrade');
$this->submitCredentialForm();
// Confirm there are only classic node migration map tables. This shows
// that only the classic migration will run.
......
......@@ -15,20 +15,18 @@
class Upgrade6Test extends MigrateUpgradeExecuteTestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
protected static $modules = [
'language',
'content_translation',
'config_translation',
'migrate_drupal_ui',
'telephone',
'aggregator',
'book',
'config_translation',
'content_translation',
'forum',
'language',
'migrate_drupal_ui',
'statistics',
'telephone',
'update',
];
......@@ -199,8 +197,9 @@ protected function getMissingPaths() {
/**
* Executes all steps of migrations upgrade.
*/
public function testMigrateUpgradeExecute() {
parent::testMigrateUpgradeExecute();
public function testUpgradeAndIncremental() {
// Perform upgrade followed by an incremental upgrade.
$this->doUpgradeAndIncremental();
// Ensure a migrated user can log in.
$this->assertUserLogIn(2, 'john.doe_pass');
......
......@@ -15,17 +15,15 @@ class IdConflictTest extends MigrateUpgradeExecuteTestBase {
* {@inheritdoc}
*/
protected static $modules = [
'file',
'language',
'config_translation',
'content_translation',
'migrate_drupal_ui',
'telephone',
'aggregator',
'book',
'config_translation',
'content_translation',
'forum',
'rdf',
'language',
'migrate_drupal_ui',
'statistics',
'telephone',
// Required for translation migrations.
'migrate_drupal_multilingual',
];
......@@ -72,27 +70,10 @@ protected function getMissingPaths() {
/**
* Tests ID Conflict form.
*/
public function testMigrateUpgradeExecute() {
$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 $this->destinationSiteVersion.");
$this->submitForm([], 'Continue');
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
$session->fieldExists('mysql[host]');
// Get valid credentials.
$edits = $this->translatePostValues($this->getCredentials());
public function testIdConflictForm() {
// Start 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 $this->destinationSiteVersion.");
$this->submitForm([], 'Continue');
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
$session->fieldExists('mysql[host]');
$this->submitCredentialForm();
$this->submitForm($edits, 'Review upgrade');
$entity_types = [
'block_content',
'menu_link_content',
......
......@@ -15,22 +15,18 @@
class Upgrade7Test extends MigrateUpgradeExecuteTestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
protected static $modules = [
'file',
'language',
'config_translation',
'content_translation',
'migrate_drupal_ui',
'telephone',
'aggregator',
'book',
'config_translation',
'content_translation',
'forum',
'rdf',
'language',
'migrate_drupal_ui',
'statistics',
'telephone',
];
/**
......@@ -220,8 +216,9 @@ protected function getMissingPaths() {
/**
* Executes all steps of migrations upgrade.
*/
public function testMigrateUpgradeExecute() {
parent::testMigrateUpgradeExecute();
public function testUpgradeAndIncremental() {
// Perform upgrade followed by an incremental upgrade.
$this->doUpgradeAndIncremental();
// Ensure a migrated user can log in.
$this->assertUserLogIn(2, 'a password');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment