executeMigration example

/** * {@inheritdoc} */
  protected static $modules = ['contact'];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->executeMigration('contact_category');
    $this->executeMigration('d7_contact_settings');
  }

  /** * Tests migration of Contact's variables to configuration. */
  public function testContactSettings() {
    $config = $this->config('contact.settings');
    $this->assertTrue($config->get('user_default_enabled'));
    $this->assertSame(33, $config->get('flood.limit'));
    $this->assertEquals('website_testing', $config->get('default_form'));
  }
/** * {@inheritdoc} */
  protected static $modules = ['filter'];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->installConfig(static::$modules);
    $this->executeMigration('d7_filter_format');
  }

  /** * {@inheritdoc} */
  public static function migrateDumpAlter(KernelTestBase $test) {
    $db = Database::getConnection('default', 'migrate');
    $fields = [
      'format' => 'image_resize_filter',
      'name' => 'Image resize',
      'cache' => '1',
      
'ids' => $ids,
      ],
      'process' => [
        'uid' => 'id',
        'name' => 'username',
        'mail' => 'email',
        'pass' => 'password',
      ],
      'destination' => ['plugin' => 'entity:user'],
    ];
    $migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
    $this->executeMigration($migration);

    // Verify that admin username and email were changed, but password was not.     /** @var \Drupal\user\Entity\User $admin_account */
    $admin_account = User::load(1);
    $this->assertSame('site_admin', $admin_account->getAccountName());
    $this->assertSame('site_admin@example.com', $admin_account->getEmail());
    $this->assertSame($this->originalPasswords[1]$admin_account->getPassword());

    // Verify that everything changed for the regular user.     /** @var \Drupal\user\Entity\User $user_account */
    $user_account = User::load(2);
    

  protected static $modules = ['contact'];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->executeMigration('contact_category');
  }

  /** * Performs various assertions on a single contact form entity. * * @param string $id * The contact form ID. * @param string $expected_label * The expected label. * @param string[] $expected_recipients * The recipient e-mail addresses the form should have. * @param string $expected_reply * The expected reply message. * @param int $expected_weight * The contact form's expected weight. * * @internal */
'description' => 'Text item 3',
      ])
      ->values([
        'name' => 'Item 4',
        'description' => 'Text item 4',
      ])
      ->execute();

    $this->installEntitySchema('taxonomy_term');
    $this->installEntitySchema('user');

    $this->executeMigration('track_changes_test');
  }

  /** * Tests track changes property of SqlBase. */
  public function testTrackChanges() {
    // Assert all of the terms have been imported.     $this->assertTermExists('name', 'Item 1');
    $this->assertTermExists('name', 'Item 2');
    $this->assertTermExists('description', 'Text item 3');
    $this->assertTermExists('description', 'Text item 4');

    

class MigrateUserMailTest extends MigrateDrupal7TestBase {

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->installConfig(['user']);
    $this->executeMigration('d7_user_mail');
  }

  /** * Tests the migration. */
  public function testMigration() {
    $config = $this->config('user.mail');
    $this->assertSame('Your account is approved!', $config->get('status_activated.subject'));
    $this->assertSame('Your account was activated, and there was much rejoicing.', $config->get('status_activated.body'));
    $this->assertSame('Fix your password', $config->get('password_reset.subject'));
    $this->assertSame("Nope! You're locked out forever.", $config->get('password_reset.body'));
    

class MigrateSearchSettingsTest extends MigrateDrupal7TestBase {

  protected static $modules = ['search'];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->executeMigration('d7_search_settings');
  }

  /** * Tests the migration of Search's variables to configuration. */
  public function testSearchSettings() {
    $config = $this->config('search.settings');
    $this->assertSame('node_search', $config->get('default_page'));
    $this->assertSame(4, $config->get('index.minimum_word_size'));
    $this->assertTrue($config->get('index.overlap_cjk'));
    $this->assertSame(100, $config->get('index.cron_limit'));
    

class MigrateMenuTest extends MigrateDrupal6TestBase {

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->executeMigration('d6_menu');
  }

  /** * Tests the Drupal 6 menu to Drupal 8 migration. */
  public function testMenu() {
    $navigation_menu = Menu::load('navigation');
    $this->assertSame('navigation', $navigation_menu->id());
    $this->assertSame('Navigation', $navigation_menu->label());
    $expected = <<<EOT The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.


  /** * Tests migration of node counter. */
  public function testStatisticsSettings() {
    $this->assertNodeCounter(1, 2, 0, 1421727536);
    $this->assertNodeCounter(2, 1, 0, 1471428059);
    $this->assertNodeCounter(4, 1, 1, 1478755275);

    // Tests that translated node counts include all translation counts.     $this->executeMigration('statistics_node_translation_counter');
    $this->assertNodeCounter(2, 2, 0, 1471428153);
    $this->assertNodeCounter(4, 2, 2, 1478755314);
  }

  /** * Asserts various aspects of a node counter. * * @param int $nid * The node ID. * @param int $total_count * The expected total count. * @param int $day_count * The expected day count. * @param int $timestamp * The expected timestamp. * * @internal */
/** * {@inheritdoc} */
  protected static $modules = ['menu_ui'];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->installConfig(['node']);
    $this->executeMigration('d6_node_type');
  }

  /** * Tests Drupal 6 node type to Drupal 8 migration. */
  public function testNodeType() {
    $id_map = $this->getMigration('d6_node_type')->getIdMap();
    // Test the test_page content type.     $node_type_page = NodeType::load('test_page');
    $this->assertSame('test_page', $node_type_page->id(), 'Node type test_page loaded');
    $this->assertTrue($node_type_page->displaySubmitted());
    

  protected static $modules = ['contact'];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->migrateUsers(FALSE);
    $this->installSchema('user', ['users_data']);
    $this->executeMigration('d6_user_contact_settings');
  }

  /** * Tests the Drupal6 user contact settings migration. */
  public function testUserContactSettings() {
    $user_data = \Drupal::service('user.data');
    $module = $key = 'contact';
    $uid = 2;
    $setting = $user_data->get($module$uid$key);
    $this->assertSame('1', $setting);

    

class MigrateImageSettingsTest extends MigrateDrupal7TestBase {

  protected static $modules = ['image'];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->executeMigration('d7_image_settings');
  }

  /** * Tests the migration. */
  public function testMigration() {
    $config = $this->config('image.settings');
    // These settings are not recommended...     $this->assertTrue($config->get('allow_insecure_derivatives'));
    $this->assertTrue($config->get('suppress_itok_output'));
    $this->assertSame("core/modules/image/testsample.png", $config->get('preview_image'));
  }
/** * {@inheritdoc} */
  protected static $modules = ['comment', 'forum', 'taxonomy'];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->executeMigration('d6_taxonomy_vocabulary');
    $this->executeMigration('d6_forum_settings');
  }

  /** * Gets the path to the fixture file. */
  protected function getFixtureFilePath() {
    return __DIR__ . '/../../../../fixtures/drupal6.php';
  }

  /** * Tests migration of forum variables to forum.settings.yml. */

class MigrateMenuTest extends MigrateDrupal7TestBase {

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->executeMigration('d7_menu');
  }

  /** * Asserts various aspects of a menu. * * @param string $id * The menu ID. * @param string $language * The menu language. * @param $label * The menu label. * @param $description * The menu description. * * @internal */
'destination' => [
        'plugin' => 'entity_revision:node',
        'translations' => TRUE,
      ],
    ];

    /** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
    $migration = $this->container
      ->get('plugin.manager.migration')
      ->createStubMigration($migration);

    $this->executeMigration($migration);

    // The entity_revision destination uses the revision ID and langcode as its     // keys (the langcode is only used if the destination is configured for     // translation), so we should be able to look up the source IDs by revision     // ID and langcode.     $source_ids = $migration->getIdMap()->lookupSourceID([
      'vid' => $node->getRevisionId(),
      'langcode' => 'fr',
    ]);
    $this->assertNotEmpty($source_ids);
    $this->assertSame($node->id()$source_ids['nid']);
    
Home | Imprint | This part of the site doesn't use cookies.