protected function MigrateUpgradeTestBase::testMigrateUpgrade in Migrate Upgrade 8
Executes all steps of migrations upgrade.
File
- src/
Tests/ MigrateUpgradeTestBase.php, line 107 - Contains \Drupal\migrate_upgrade\Tests\MigrateUpgradeTestBase.
Class
- MigrateUpgradeTestBase
- Provides a base class for testing migration upgrades in the UI.
Namespace
Drupal\migrate_upgrade\TestsCode
protected function testMigrateUpgrade() {
$connection_options = $this->sourceDatabase
->getConnectionOptions();
$this
->drupalGet('/upgrade');
$this
->assertText('Upgrade a Drupal site by importing it into a clean and empty new install of Drupal 8. You will lose any existing configuration once you import your site into it. See the upgrading handbook for more detailed information.');
$this
->drupalPostForm(NULL, [], t('Continue'));
$this
->assertText('Provide credentials for the database of the Drupal site you want to upgrade.');
$this
->assertFieldByName('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']);
$edits = $this
->translatePostValues([
'driver' => $driver,
$driver => $connection_options,
'source_base_path' => $this
->getSourceBasePath(),
]);
$this
->drupalPostForm(NULL, $edits, t('Review upgrade'));
$this
->assertResponse(200);
$this
->assertText('Are you sure?');
$this
->drupalPostForm(NULL, [], t('Perform upgrade'));
$this
->assertText(t('Congratulations, you upgraded Drupal!'));
// Have to reset all the statics after migration to ensure entities are
// loadable.
$this
->resetAll();
$expected_counts = $this
->getEntityCounts();
foreach (array_keys(\Drupal::entityTypeManager()
->getDefinitions()) as $entity_type) {
$real_count = count(\Drupal::entityTypeManager()
->getStorage($entity_type)
->loadMultiple());
$expected_count = isset($expected_counts[$entity_type]) ? $expected_counts[$entity_type] : 0;
$this
->assertEqual($expected_count, $real_count, "Found {$real_count} {$entity_type} entities, expected {$expected_count}.");
}
}