MigrateDrupal7TestBase.php in Drupal 9
File
core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7TestBase.php
View source
<?php
namespace Drupal\Tests\migrate_drupal\Kernel\d7;
use Drupal\migrate_drupal\NodeMigrateType;
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
use Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait;
abstract class MigrateDrupal7TestBase extends MigrateDrupalTestBase {
use NodeMigrateTypeTestTrait;
protected function setUp() {
parent::setUp();
$this
->makeNodeMigrateMapTable(NodeMigrateType::NODE_MIGRATE_TYPE_CLASSIC, '7');
$this
->loadFixture($this
->getFixtureFilePath());
}
protected function getFixtureFilePath() {
return __DIR__ . '/../../../fixtures/drupal7.php';
}
protected function migrateFields() {
$this
->executeMigration('d7_field');
$this
->migrateContentTypes();
$this
->migrateCommentTypes();
$this
->executeMigrations([
'd7_taxonomy_vocabulary',
'd7_field_instance',
]);
}
protected function migrateUsers($include_pictures = TRUE) {
$migrations = [
'd7_user_role',
'd7_user',
];
if ($include_pictures) {
$this
->installEntitySchema('file');
$migrations = array_merge([
'user_picture_field',
'user_picture_field_instance',
], $migrations);
}
$this
->executeMigrations($migrations);
}
protected function migrateContentTypes() {
$this
->installConfig([
'node',
]);
$this
->installEntitySchema('node');
$this
->executeMigration('d7_node_type');
}
protected function migrateCommentTypes() {
$this
->installConfig([
'comment',
]);
$this
->executeMigration('d7_comment_type');
}
protected function migrateContent($include_revisions = FALSE) {
$this
->migrateContentTypes();
$this
->migrateCommentTypes();
$this
->migrateUsers(FALSE);
$this
->executeMigrations([
'd7_node',
]);
if ($include_revisions) {
$this
->executeMigrations([
'd7_node_revision',
]);
}
}
protected function migrateTaxonomyTerms() {
$this
->installEntitySchema('taxonomy_term');
$this
->migrateFields();
$this
->executeMigrations([
'd7_taxonomy_term',
]);
}
}