WebformMigrateTestBase.php in Webform: Migrate 8
File
tests/src/Kernel/Migrate/d7/WebformMigrateTestBase.php
View source
<?php
namespace Drupal\Tests\webform_migrate\Kernel\Migrate\d7;
use Drupal\Core\Site\Settings;
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
abstract class WebformMigrateTestBase extends MigrateDrupalTestBase {
public abstract function getDatabaseFixtureFilePath();
public abstract function getFilesystemFixturePath();
public function setUp() {
parent::setUp();
$this
->loadFixture($this
->getDatabaseFixtureFilePath());
$module_handler = \Drupal::moduleHandler();
$this
->installEntitySchema('file');
$this
->installSchema('file', 'file_usage');
if ($module_handler
->moduleExists('node')) {
$this
->installEntitySchema('node');
$this
->installSchema('node', 'node_access');
}
if ($module_handler
->moduleExists('comment')) {
$this
->installEntitySchema('comment');
$this
->installSchema('comment', 'comment_entity_statistics');
}
if ($module_handler
->moduleExists('webform')) {
$this
->installEntitySchema('webform_submission');
$this
->installSchema('webform', 'webform');
}
$module_list = array_keys($module_handler
->getModuleList());
$this
->installConfig($module_list);
}
protected function setClassicNodeMigration(bool $classic_node_migration) {
$current_method = Settings::get('migrate_node_migrate_type_classic', FALSE);
if ($current_method !== $classic_node_migration) {
$this
->setSetting('migrate_node_migrate_type_classic', $classic_node_migration);
}
}
protected function executeWebformMigrations(bool $classic_node_migration = FALSE) {
$fs_fixture_path = $this
->getFilesystemFixturePath();
$file_migration = $this
->getMigration('d7_file');
$source = $file_migration
->getSourceConfiguration();
$source['constants']['source_base_path'] = $fs_fixture_path;
$file_migration
->set('source', $source);
$this
->startCollectingMessages();
$this
->executeMigration($file_migration);
$this
->executeMigrations([
'd7_view_modes',
'd7_field',
'd7_node_type',
'd7_field_instance',
'd7_field_formatter_settings',
'd7_field_instance_widget_settings',
'd7_filter_format',
'd7_user_role',
'd7_user',
$classic_node_migration ? 'd7_node' : 'd7_node_complete',
]);
$this
->stopCollectingMessages();
$this
->startCollectingMessages();
$this
->executeMigrations([
'd7_webform',
]);
$this
->stopCollectingMessages();
$this
->assertEmpty($this->migrateMessages);
$this
->startCollectingMessages();
$this
->executeMigrations([
'd7_webform_submission',
]);
$this
->stopCollectingMessages();
$this
->assertEmpty($this->migrateMessages);
}
}