View source
<?php
namespace Drupal\Tests\migrate_drupal_ui\Functional;
use Drupal\migrate_drupal\MigrationConfigurationTrait;
use Drupal\Tests\migrate_drupal\Traits\CreateTestContentEntitiesTrait;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\WebAssert;
class MigrateUpgradeFormStepsTest extends BrowserTestBase {
use MigrationConfigurationTrait;
use CreateTestContentEntitiesTrait;
protected static $modules = [
'migrate_drupal_ui',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
$this
->drupalLogin($this->rootUser);
}
protected function getSourceBasePath() {
return __DIR__ . '/files';
}
public function testMigrateUpgradeReviewPage() {
$store = \Drupal::service('tempstore.private')
->get('migrate_drupal_ui');
$state = \Drupal::service('state');
$session = $this
->assertSession();
list($destination_site_version) = explode('.', \Drupal::VERSION, 2);
$expected['initial'] = "Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal {$destination_site_version}.";
$expected['incremental'] = "An upgrade has already been performed on this site.";
foreach ([
'/upgrade',
'/upgrade/incremental',
] as $expected) {
if ($expected === '/upgrade/incremental') {
$state
->set('migrate_drupal_ui.performed', 1);
}
$store
->set('step', 'foo');
$this
->assertFirstForm($session, $expected);
$store
->delete('step');
$this
->assertFirstForm($session, $expected);
$store
->delete('migrations');
$store
->set('step', 'idconflict');
$this
->drupalGet('/upgrade/idconflict');
$session
->addressEquals($expected);
$store
->delete('version');
$store
->set('migrations', [
'foo',
'bar',
]);
$store
->set('system_data', [
'bar',
'foo',
]);
$store
->set('step', 'review');
$this
->drupalGet('/upgrade/review');
$session
->addressEquals($expected);
$store
->set('version', '6');
$store
->delete('migrations');
$store
->set('system_data', [
'bar',
'foo',
]);
$store
->set('step', 'review');
$this
->drupalGet('/upgrade/review');
$session
->addressEquals($expected);
$store
->set('version', '6');
$store
->set('migrations', [
'foo',
'bar',
]);
$store
->delete('system_data');
$store
->set('step', 'review');
$this
->drupalGet('/upgrade/review');
$session
->addressEquals($expected);
}
$store
->set('step', 'overview');
$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 {$destination_site_version}. Rollbacks are not yet supported through the user interface.");
$this
->submitForm([], 'Import new configuration and content from old site');
$session
->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
}
protected function assertFirstForm(WebAssert $session, $expected) {
$paths = [
'',
'/incremental',
'/credentials',
'/idconflict',
'/review',
];
foreach ($paths as $path) {
$this
->drupalGet('/upgrade' . $path);
$session
->addressEquals($expected);
}
}
}