You are here

public function MigrateNodeBuilderTest::testCreateMigrations in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/Tests/Migrate/d6/MigrateNodeBuilderTest.php \Drupal\node\Tests\Migrate\d6\MigrateNodeBuilderTest::testCreateMigrations()

Tests creating migrations from a template, using a builder plugin.

File

core/modules/node/src/Tests/Migrate/d6/MigrateNodeBuilderTest.php, line 42
Contains \Drupal\node\Tests\Migrate\d6\MigrateNodeBuilderTest.

Class

MigrateNodeBuilderTest
@group migrate_drupal_6

Namespace

Drupal\node\Tests\Migrate\d6

Code

public function testCreateMigrations() {
  $templates = [
    'd6_node' => [
      'id' => 'd6_node',
      'label' => 'Drupal 6 nodes',
      'builder' => [
        'plugin' => 'd6_node',
      ],
      'source' => [
        'plugin' => 'd6_node',
      ],
      'process' => [
        'nid' => 'nid',
        'vid' => 'vid',
        'uid' => 'uid',
      ],
      'destination' => [
        'plugin' => 'entity:node',
      ],
    ],
  ];
  $migrations = \Drupal::service('migrate.migration_builder')
    ->createMigrations($templates);

  // Key the array.
  foreach ($migrations as $migration) {
    $this->builtMigrations[$migration
      ->id()] = $migration;
  }
  $this
    ->assertIdentical(11, count($this->builtMigrations));
  $this
    ->assertEntity('d6_node__article', 'Drupal 6 nodes (article)');
  $this
    ->assertEntity('d6_node__company', 'Drupal 6 nodes (company)');
  $this
    ->assertEntity('d6_node__employee', 'Drupal 6 nodes (employee)');
  $this
    ->assertEntity('d6_node__event', 'Drupal 6 nodes (event)');
  $this
    ->assertEntity('d6_node__page', 'Drupal 6 nodes (page)');
  $this
    ->assertEntity('d6_node__sponsor', 'Drupal 6 nodes (sponsor)');
  $this
    ->assertEntity('d6_node__story', 'Drupal 6 nodes (story)');
  $this
    ->assertEntity('d6_node__test_event', 'Drupal 6 nodes (test_event)');
  $this
    ->assertEntity('d6_node__test_page', 'Drupal 6 nodes (test_page)');
  $this
    ->assertEntity('d6_node__test_planet', 'Drupal 6 nodes (test_planet)');
  $this
    ->assertEntity('d6_node__test_story', 'Drupal 6 nodes (test_story)');
}