You are here

public function MigrateDependenciesTest::testMigrateDependenciesOrder in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/migrate_drupal/src/Tests/dependencies/MigrateDependenciesTest.php \Drupal\migrate_drupal\Tests\dependencies\MigrateDependenciesTest::testMigrateDependenciesOrder()

Tests that the order is correct when loading several migrations.

File

core/modules/migrate_drupal/src/Tests/dependencies/MigrateDependenciesTest.php, line 30
Contains \Drupal\migrate_drupal\Tests\dependencies\MigrateDependenciesTest.

Class

MigrateDependenciesTest
Ensure the consistency among the dependencies for migrate.

Namespace

Drupal\migrate_drupal\Tests\dependencies

Code

public function testMigrateDependenciesOrder() {
  $migration_items = array(
    'd6_comment',
    'd6_filter_format',
    'd6_node__page',
  );
  $migrations = Migration::loadMultiple($migration_items);
  $expected_order = array(
    'd6_filter_format',
    'd6_node__page',
    'd6_comment',
  );
  $this
    ->assertIdentical(array_keys($migrations), $expected_order);
  $expected_requirements = array(
    // d6_comment depends on d6_node:*, which the storage controller expands
    // into every variant of d6_node created by the MigrationBuilder.
    'd6_node__article',
    'd6_node__company',
    'd6_node__employee',
    'd6_node__event',
    'd6_node__page',
    'd6_node__sponsor',
    'd6_node__story',
    'd6_node__test_event',
    'd6_node__test_page',
    'd6_node__test_planet',
    'd6_node__test_story',
    'd6_node_type',
    'd6_node_settings',
    'd6_filter_format',
    'd6_user',
    'd6_comment_type',
    'd6_comment_entity_display',
    'd6_comment_entity_form_display',
  );

  // Migration dependencies for comment include dependencies for node
  // migration as well.
  $actual_requirements = $migrations['d6_comment']
    ->get('requirements');
  $this
    ->assertIdentical(count($actual_requirements), count($expected_requirements));
  foreach ($expected_requirements as $requirement) {
    $this
      ->assertIdentical($actual_requirements[$requirement], $requirement);
  }
}