Skip to content
Snippets Groups Projects
Commit 4df1ca4f authored by catch's avatar catch
Browse files

Issue #3143719 by quietone, pavnish, benjifisher: Add a getCredentials helper...

Issue #3143719 by quietone, pavnish, benjifisher: Add a getCredentials helper method to migrate_drupal_ui functional tests
parent b829de68
Branches
Tags
8 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,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage",!13Resolve #2903456
......@@ -49,31 +49,10 @@ public function testMigrateUpgradeExecute() {
$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);
// Get valid credentials.
$edits = $this->translatePostValues($this->getCredentials());
// Ensure submitting the form with invalid database credentials gives us a
// nice warning.
......@@ -91,6 +70,7 @@ public function testMigrateUpgradeExecute() {
// Test the file sources.
$this->drupalGet('/upgrade');
$this->drupalPostForm(NULL, [], t('Continue'));
$version = $this->getLegacyDrupalVersion($this->sourceDatabase);
if ($version == 6) {
$paths['d6_source_base_path'] = DRUPAL_ROOT . '/wrong-path';
}
......
......@@ -260,4 +260,43 @@ protected function assertMigrationResults(array $expected_counts, $version) {
}
}
/**
* Creates an array of credentials for the Credential form.
*
* Before submitting to the Credential form the array must be processed by
* BrowserTestBase::translatePostValues() before submitting.
*
* @return array
* An array of values suitable for BrowserTestBase::translatePostValues().
*
* @see \Drupal\migrate_drupal_ui\Form\CredentialForm
*/
protected function getCredentials() {
$connection_options = $this->sourceDatabase->getConnectionOptions();
$version = $this->getLegacyDrupalVersion($this->sourceDatabase);
$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']);
$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;
}
return $edit;
}
}
......@@ -13,13 +13,6 @@ abstract class MultilingualReviewPageTestBase extends MigrateUpgradeTestBase {
use CreateTestContentEntitiesTrait;
/**
* An array suitable for drupalPostForm().
*
* @var array
*/
protected $edits = [];
/**
* {@inheritdoc}
*/
......@@ -52,7 +45,11 @@ public function testMigrateUpgradeReviewPage() {
// Start the upgrade process.
$this->drupalGet('/upgrade');
$this->drupalPostForm(NULL, [], t('Continue'));
$this->drupalPostForm(NULL, $this->edits, t('Review upgrade'));
// Get valid credentials.
$edits = $this->translatePostValues($this->getCredentials());
$this->drupalPostForm(NULL, $edits, t('Review upgrade'));
$this->drupalPostForm(NULL, [], t('I acknowledge I may lose data. Continue anyway.'));
// Ensure there are no errors about missing modules from the test module.
......@@ -81,7 +78,7 @@ public function testMigrateUpgradeReviewPage() {
// Start the upgrade process.
$this->drupalGet('/upgrade');
$this->drupalPostForm(NULL, [], t('Continue'));
$this->drupalPostForm(NULL, $this->edits, t('Review upgrade'));
$this->drupalPostForm(NULL, $edits, t('Review upgrade'));
$this->drupalPostForm(NULL, [], t('I acknowledge I may lose data. Continue anyway.'));
// Test the upgrade paths. First remove the module from the available paths
......@@ -99,32 +96,6 @@ public function testMigrateUpgradeReviewPage() {
* is loaded.
*/
public function prepare() {
$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;
}
$this->edits = $this->translatePostValues($edit);
// Enable all modules in the source except test and example modules, but
// include simpletest.
/** @var \Drupal\Core\Database\Query\SelectInterface $update */
......
......@@ -17,7 +17,11 @@ public function testMigrateUpgradeReviewPage() {
// Start the upgrade process.
$this->drupalGet('/upgrade');
$this->drupalPostForm(NULL, [], t('Continue'));
$this->drupalPostForm(NULL, $this->edits, t('Review upgrade'));
// Get valid credentials.
$edits = $this->translatePostValues($this->getCredentials());
$this->drupalPostForm(NULL, $edits, t('Review upgrade'));
$session = $this->assertSession();
$session->pageTextContains('WARNING: Content may be overwritten on your new site.');
......
......@@ -71,7 +71,6 @@ protected function getMissingPaths() {
* Tests ID Conflict form.
*/
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 $this->destinationSiteVersion.");
......@@ -80,25 +79,8 @@ public function testMigrateUpgradeExecute() {
$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,
];
$edit['d6_source_base_path'] = $this->getSourceBasePath();
if (count($drivers) !== 1) {
$edit['driver'] = $driver;
}
$edits = $this->translatePostValues($edit);
// Get valid credentials.
$edits = $this->translatePostValues($this->getCredentials());
// Start the upgrade process.
$this->drupalGet('/upgrade');
......
......@@ -81,7 +81,6 @@ public function testMigrateUpgradeExecute() {
// Add a node classic migrate table to d8.
$this->makeNodeMigrateMapTable(NodeMigrateType::NODE_MIGRATE_TYPE_CLASSIC, '6');
$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 $this->destinationSiteVersion.");
......@@ -90,25 +89,8 @@ public function testMigrateUpgradeExecute() {
$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,
];
$edit['d6_source_base_path'] = $this->getSourceBasePath();
if (count($drivers) !== 1) {
$edit['driver'] = $driver;
}
$edits = $this->translatePostValues($edit);
// Get valid credentials.
$edits = $this->translatePostValues($this->getCredentials());
// Start the upgrade process.
$this->drupalGet('/upgrade');
......
......@@ -73,7 +73,6 @@ protected function getMissingPaths() {
* Tests ID Conflict form.
*/
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 $this->destinationSiteVersion.");
......@@ -82,25 +81,8 @@ public function testMigrateUpgradeExecute() {
$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,
];
$edit['source_base_path'] = $this->getSourceBasePath();
if (count($drivers) !== 1) {
$edit['driver'] = $driver;
}
$edits = $this->translatePostValues($edit);
// Get valid credentials.
$edits = $this->translatePostValues($this->getCredentials());
// Start the upgrade process.
$this->drupalGet('/upgrade');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment