View source
<?php
namespace Drupal\Tests\migrate_drupal\Kernel\d6;
use Drupal\migrate_drupal\NodeMigrateType;
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
use Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait;
abstract class MigrateDrupal6TestBase extends MigrateDrupalTestBase {
use NodeMigrateTypeTestTrait;
protected static $modules = [
'datetime',
'filter',
'image',
'link',
'node',
'options',
'telephone',
'text',
];
protected function setUp() : void {
parent::setUp();
$this
->makeNodeMigrateMapTable(NodeMigrateType::NODE_MIGRATE_TYPE_CLASSIC, '6');
$this
->loadFixture($this
->getFixtureFilePath());
}
protected function getFixtureFilePath() {
return __DIR__ . '/../../../fixtures/drupal6.php';
}
protected function migrateUsers($include_pictures = TRUE) {
$this
->executeMigrations([
'd6_filter_format',
'd6_user_role',
]);
if ($include_pictures) {
$this
->installEntitySchema('file');
$this
->executeMigrations([
'd6_file',
'd6_user_picture_file',
'user_picture_field',
'user_picture_field_instance',
'user_picture_entity_display',
'user_picture_entity_form_display',
]);
}
$this
->executeMigration('d6_user');
}
protected function migrateContentTypes() {
$this
->installConfig([
'node',
]);
$this
->executeMigration('d6_node_type');
}
protected function migrateFields() {
$this
->migrateContentTypes();
$this
->executeMigrations([
'd6_field',
'd6_field_instance',
'd6_field_instance_widget_settings',
'd6_view_modes',
'd6_field_formatter_settings',
'd6_upload_field',
'd6_upload_field_instance',
]);
}
protected function migrateContent(array $include = []) {
if (in_array('translations', $include)) {
$this
->executeMigrations([
'language',
]);
}
$this
->migrateUsers(FALSE);
$this
->migrateFields();
$this
->installEntitySchema('node');
$this
->executeMigrations([
'd6_node_settings',
'd6_node',
]);
if (in_array('translations', $include)) {
$this
->executeMigrations([
'd6_node_translation',
]);
}
if (in_array('revisions', $include)) {
$this
->executeMigrations([
'd6_node_revision',
]);
}
}
protected function migrateTaxonomy() {
$this
->migrateContentTypes();
$this
->installEntitySchema('taxonomy_term');
$this
->executeMigrations([
'd6_taxonomy_vocabulary',
'd6_vocabulary_field',
'd6_vocabulary_field_instance',
'd6_vocabulary_entity_display',
'd6_vocabulary_entity_form_display',
'd6_taxonomy_term',
]);
}
}