MigrateDrupalTestBase.php

Same filename in this branch
  1. 10 core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php
Same filename and directory in other branches
  1. 9 core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php
  2. 9 core/modules/tracker/tests/src/Kernel/Migrate/d7/MigrateDrupalTestBase.php
  3. 8.9.x core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php
  4. 11.x core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php
  5. 11.x core/modules/tracker/tests/src/Kernel/Migrate/d7/MigrateDrupalTestBase.php

Namespace

Drupal\Tests\tracker\Kernel\Migrate\d7

File

core/modules/tracker/tests/src/Kernel/Migrate/d7/MigrateDrupalTestBase.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\tracker\Kernel\Migrate\d7;

use Drupal\migrate_drupal\NodeMigrateType;
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase as CoreMigrateDrupalTestBase;
use Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait;

/**
 * Base class for Tracker Drupal 7 migration tests.
 */
abstract class MigrateDrupalTestBase extends CoreMigrateDrupalTestBase {
  use NodeMigrateTypeTestTrait;
  
  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    // Add a node classic migrate table to the destination site so that tests
    // run by default with the classic node migrations.
    $this->makeNodeMigrateMapTable(NodeMigrateType::NODE_MIGRATE_TYPE_CLASSIC, '7');
    $this->loadFixture($this->getFixtureFilePath());
  }
  
  /**
   * Gets the path to the fixture file.
   */
  protected function getFixtureFilePath() {
    return __DIR__ . '/../../../../fixtures/drupal7.php';
  }
  
  /**
   * Executes all user migrations.
   *
   * @param bool $include_pictures
   *   (optional) If TRUE, migrates user pictures. Defaults to TRUE.
   */
  protected function migrateUsers($include_pictures = TRUE) {
    $migrations = [
      'd7_user_role',
      'd7_user',
    ];
    if ($include_pictures) {
      // Prepare to migrate user pictures as well.
      $this->installEntitySchema('file');
      $migrations = array_merge([
        'user_picture_field',
        'user_picture_field_instance',
      ], $migrations);
    }
    $this->executeMigrations($migrations);
  }
  
  /**
   * Migrates node types.
   */
  protected function migrateContentTypes() {
    $this->installConfig([
      'node',
    ]);
    $this->installEntitySchema('node');
    $this->executeMigration('d7_node_type');
  }

}

Classes

Title Deprecated Summary
MigrateDrupalTestBase Base class for Tracker Drupal 7 migration tests.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.