diff --git a/core/modules/migrate_drupal/src/Tests/d7/MigrateDrupal7TestBase.php b/core/modules/migrate_drupal/src/Tests/d7/MigrateDrupal7TestBase.php index 95e89f1..be99383 100644 --- a/core/modules/migrate_drupal/src/Tests/d7/MigrateDrupal7TestBase.php +++ b/core/modules/migrate_drupal/src/Tests/d7/MigrateDrupal7TestBase.php @@ -7,6 +7,7 @@ namespace Drupal\migrate_drupal\Tests\d7; +use Drupal\migrate\Entity\Migration; use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase; /** @@ -17,6 +18,21 @@ /** * {@inheritdoc} */ + public static $modules = [ + 'comment', + 'datetime', + 'entity_reference', + 'image', + 'link', + 'node', + 'taxonomy', + 'telephone', + 'text', + ]; + + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp(); $this->installMigrations('Drupal 7'); @@ -29,4 +45,87 @@ protected function getDumpDirectory() { return parent::getDumpDirectory() . '/d7'; } + /** + * Executes all user migrations. + * + * @param bool $include_pictures + * If TRUE, migrates user pictures. + */ + protected function migrateUsers($include_pictures = TRUE) { + $this->executeMigrations(['d7_filter_format', 'd7_user_role']); + + if ($include_pictures) { + $this->installEntitySchema('file'); + $this->executeMigrations([ + 'd7_file', + 'user_picture_field', + 'user_picture_field_instance', + 'user_picture_entity_display', + 'user_picture_entity_form_display', + ]); + } + else { + // These are optional dependencies of d7_user, but we don't need them if + // we're not migrating user pictures. + Migration::load('user_picture_entity_display')->delete(); + Migration::load('user_picture_entity_form_display')->delete(); + } + + $this->executeMigration('d7_user'); + } + + /** + * Migrates node types. + */ + protected function migrateContentTypes() { + $this->installConfig(['node']); + $this->executeMigration('d7_node_type'); + } + + /** + * Executes all field migrations. + */ + protected function migrateFields() { + $this->migrateContentTypes(); + $this->executeMigrations([ + 'd7_field', + 'd7_field_instance', + 'd7_field_instance_widget_settings', + 'd7_view_modes', + 'd7_field_formatter_settings', + 'd7_upload_field', + 'd7_upload_field_instance', + ]); + } + + /** + * Executes all content migrations. + * + * @param bool $include_revisions + * If TRUE, migrates node revisions. + */ + protected function migrateContent($include_revisions = FALSE) { + $this->migrateUsers(FALSE); + $this->migrateFields(); + + $this->installEntitySchema('node'); + $this->executeMigrations(['d7_node_settings', 'd7_node:*']); + + if ($include_revisions) { + $this->executeMigrations(['d7_node_revision:*']); + } + } + + /** + * Executes all taxonomy migrations. + */ + protected function migrateTaxonomy() { + $this->migrateContentTypes(); + $this->installEntitySchema('taxonomy_term'); + $this->executeMigrations([ + 'd7_taxonomy_vocabulary', + 'd7_taxonomy_term', + ]); + } + }