diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateAggregatorFeedTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateAggregatorFeedTest.php new file mode 100644 index 0000000..a32d37b --- /dev/null +++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateAggregatorFeedTest.php @@ -0,0 +1,64 @@ + 'Migrate variables to aggregator_feed entities.', + 'description' => 'Upgrade variables to aggregator_feed entities', + 'group' => 'Migrate Drupal', + ); + } + + /** + * {@inheritdoc} + */ + public function setUp() { + parent::setUp(); + $migration = entity_load('migration', 'd6_aggregator_feed'); + $dumps = array( + drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6AggregatorFeed.php', + ); + $this->prepare($migration, $dumps); + $executable = new MigrateExecutable($migration, $this); + $executable->import(); + } + + /** + * Tests migration of aggregator feeds. + */ + public function testAggregatorFeedImport() { + /** @var Feed $feed */ + $feed = entity_load('aggregator_feed', 5); + $this->assertNotNull($feed->uuid()); + $this->assertEqual($feed->title->value, 'Know Your Meme'); + $this->assertEqual($feed->language()->id, Language::LANGCODE_NOT_SPECIFIED); + $this->assertEqual($feed->url->value, 'http://knowyourmeme.com/newsfeed.rss'); + $this->assertEqual($feed->refresh->value, 900); + $this->assertEqual($feed->checked->value, 1387659487); + $this->assertEqual($feed->queued->value, 0); + $this->assertEqual($feed->link->value, 'http://knowyourmeme.com'); + $this->assertEqual($feed->description->value, 'New items added to the News Feed'); + $this->assertEqual($feed->image->value, 'http://b.thumbs.redditmedia.com/harEHsUUZVajabtC.png'); + $this->assertEqual($feed->hash->value, ''); + $this->assertEqual($feed->etag->value, '"213cc1365b96c310e92053c5551f0504"'); + $this->assertEqual($feed->modified->value, 0); + } +} diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateAggregatorItemTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateAggregatorItemTest.php new file mode 100644 index 0000000..6668c53 --- /dev/null +++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateAggregatorItemTest.php @@ -0,0 +1,85 @@ + 'Migrate aggregator items', + 'description' => 'Upgrade aggregator items', + 'group' => 'Migrate Drupal', + ); + } + + /** + * {@inheritdoc} + */ + public function setUp() { + parent::setUp(); + // Add some id mappings for the dependant migrations. + $id_mappings = array( + 'd6_aggregator_feed' => array( + array(array(5), array(5)), + ), + ); + $this->prepareIdMappings($id_mappings); + + $entity = entity_create('aggregator_feed', array( + 'fid' => 5, + 'title' => 'Drupal Core', + 'url' => 'https://groups.drupal.org/not_used/167169', + 'refresh' => 900, + 'checked' => 1389919932, + 'description' => 'Drupal Core Group feed', + )); + $entity->enforceIsNew(); + $entity->save(); + /** @var \Drupal\migrate\entity\Migration $migration */ + $migration = entity_load('migration', 'd6_aggregator_item'); + $path = drupal_get_path('module', 'migrate_drupal'); + $dumps = array( + $path . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6AggregatorItem.php', + ); + $this->prepare($migration, $dumps); + $executable = new MigrateExecutable($migration, $this); + $executable->import(); + } + + /** + * Test Drupal 6 aggregator item migration to Drupal 8. + */ + public function testAggregatorItem() { + /** @var Item $item */ + $item = entity_load('aggregator_item', 1); + $this->assertEqual($item->id(), 1); + $this->assertEqual($item->getFeedId(), 5); + $this->assertEqual($item->label(), 'This (three) weeks in Drupal Core - January 10th 2014'); + $this->assertEqual($item->getAuthor(), 'larowlan'); + $this->assertEqual($item->getDescription(), "
-
-
- ');
+ $this->assertIdentical($filters['filter_html_escape']['settings']['filter_html_help'], '1');
+ $this->assertIdentical($filters['filter_html']['settings']['filter_html_nofollow'], false);
+ $this->assertIdentical($filters['filter_url']['settings']['filter_url_length'], 72);
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateMenuTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateMenuTest.php
new file mode 100644
index 0000000..95e95c7
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateMenuTest.php
@@ -0,0 +1,70 @@
+ 'Migrate menus',
+ 'description' => 'Upgrade menus to system.menu.*.yml',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_menu');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6Menu.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, new MigrateMessage());
+ $executable->import();
+ }
+
+ /**
+ * Tests the Drupal 6 menu to Drupal 8 migration.
+ */
+ public function testMenu() {
+ $navigation_menu = entity_load('menu', 'navigation');
+ $this->assertEqual($navigation_menu->id(), 'navigation');
+ $this->assertEqual($navigation_menu->label(), 'Navigation');
+ $this->assertEqual($navigation_menu->description , '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.');
+
+ // Test that we can re-import using the ConfigEntityBase destination.
+ Database::getConnection('default', 'migrate')
+ ->update('menu_custom')
+ ->fields(array('title' => 'Home Navigation'))
+ ->condition('menu_name', 'navigation')
+ ->execute();
+
+ db_truncate(entity_load('migration', 'd6_menu')->getIdMap()->mapTableName())->execute();
+ $migration = entity_load_unchanged('migration', 'd6_menu');
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+
+ $navigation_menu = entity_load_unchanged('menu', 'navigation');
+ $this->assertEqual($navigation_menu->label(), 'Home Navigation');
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateNodeRevisionTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateNodeRevisionTest.php
new file mode 100644
index 0000000..7f456cf
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateNodeRevisionTest.php
@@ -0,0 +1,61 @@
+ 'Migrate nodes',
+ 'description' => 'Node content revisions migration',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $id_mappings = array(
+ 'd6_node' => array(
+ array(array(1), array(1)),
+ ),
+ );
+ $this->prepareIdMappings($id_mappings);
+
+ $path = drupal_get_path('module', 'migrate_drupal');
+ $dumps = array(
+ $path . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6NodeRevision.php',
+ );
+ $this->loadDumps($dumps);
+ /** @var \Drupal\migrate\entity\Migration $migration */
+ $migration = entity_load('migration', 'd6_node_revision');
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Test node revisions migration from Drupal 6 to 8.
+ */
+ public function testNodeRevision() {
+ $node = \Drupal::entityManager()->getStorage('node')->loadRevision(2);
+ $this->assertEqual($node->id(), 1);
+ $this->assertEqual($node->getRevisionId(), 2);
+ $this->assertEqual($node->body->value, 'test rev 2');
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateNodeTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateNodeTest.php
new file mode 100644
index 0000000..e08d85f
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateNodeTest.php
@@ -0,0 +1,90 @@
+ 'Migrate nodes',
+ 'description' => 'Node content migration',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp() {
+ parent::setUp();
+ /** @var \Drupal\migrate\entity\Migration $migration */
+ $migration = entity_load('migration', 'd6_node');
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+
+ // This is required for the second import below.
+ db_truncate($migration->getIdMap()->mapTableName())->execute();
+ $this->standalone = TRUE;
+ }
+
+ /**
+ * Test node migration from Drupal 6 to 8.
+ */
+ public function testNode() {
+ $node = node_load(1);
+ $this->assertEqual($node->id(), 1, 'Node 1 loaded.');
+ $this->assertEqual($node->body->value, 'test');
+ $this->assertEqual($node->body->format, 'filtered_html');
+ $this->assertEqual($node->getType(), 'story', 'Node has the correct bundle.');
+ $this->assertEqual($node->getTitle(), 'Test title', 'Node has the correct title.');
+ $this->assertEqual($node->getCreatedTime(), 1388271197, 'Node has the correct created time.');
+ $this->assertEqual($node->isSticky(), FALSE);
+ $this->assertEqual($node->getOwnerId(), 1);
+ //$this->assertEqual($node->getRevisionCreationTime(), 1390095701, 'Node has the correct revision timestamp.');
+
+ // It is pointless to run the second half from MigrateDrupal6Test.
+ if (empty($this->standalone)) {
+ return;
+ }
+
+ // Test that we can re-import using the EntityContentBase destination.
+ $connection = Database::getConnection('default', 'migrate');
+ $connection->update('node_revisions')
+ ->fields(array(
+ 'title' => 'New node title',
+ 'format' => 2,
+ ))
+ ->condition('vid', 1)
+ ->execute();
+ $connection->delete('content_field_test_two')
+ ->condition('delta', 1)
+ ->execute();
+
+ /** @var \Drupal\migrate\entity\Migration $migration */
+ $migration = entity_load('migration', 'd6_node');
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+
+ $node = node_load(1);
+ $this->assertEqual($node->getTitle(), 'New node title');
+ // Test a multi-column fields are correctly upgraded.
+ $this->assertEqual($node->body->value, 'test');
+ $this->assertEqual($node->body->format, 'full_html');
+
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateNodeTypeTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateNodeTypeTest.php
new file mode 100644
index 0000000..857d6de
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateNodeTypeTest.php
@@ -0,0 +1,96 @@
+ 'Migrate node type to node.type.*.yml',
+ 'description' => 'Upgrade node types to node.type.*.yml',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_node_type');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6NodeType.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests Drupal 6 node type to Drupal 8 migration.
+ */
+ public function testNodeType() {
+ $migration = entity_load('migration', 'd6_node_type');
+ // Test the test_page content type.
+ $node_type_page = entity_load('node_type', 'test_page');
+ $this->assertEqual($node_type_page->id(), 'test_page', 'Node type test_page loaded');
+ $expected = array(
+ 'options' => array(
+ 'status' => TRUE,
+ 'promote' => TRUE,
+ 'sticky' => FALSE,
+ 'revision' => FALSE,
+ ),
+ 'preview' => 1,
+ 'submitted' => TRUE,
+ );
+
+ $this->assertEqual($node_type_page->settings['node'], $expected, 'Node type test_page settings correct.');
+ $this->assertEqual(array('test_page'), $migration->getIdMap()->lookupDestinationID(array('test_page')));
+
+ // Test we have a body field.
+ $instance = field_info_instance('node', 'body', 'test_page');
+ $this->assertEqual($instance->getLabel(), 'Body', 'Body field was found.');
+
+ // Test the test_story content type.
+ $node_type_story = entity_load('node_type', 'test_story');
+ $this->assertEqual($node_type_story->id(), 'test_story', 'Node type test_story loaded');
+ $expected = array(
+ 'options' => array(
+ 'status' => TRUE,
+ 'promote' => TRUE,
+ 'sticky' => FALSE,
+ 'revision' => FALSE,
+ ),
+ 'preview' => 1,
+ 'submitted' => TRUE,
+ );
+ $this->assertEqual($node_type_page->settings['node'], $expected, 'Node type test_page settings correct.');
+ $this->assertEqual(array('test_story'), $migration->getIdMap()->lookupDestinationID(array('test_story')));
+
+ // Test we don't have a body field.
+ $instance = field_info_instance('node', 'body', 'test_story');
+ $this->assertEqual($instance, NULL, 'No body field found');
+ }
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateProfileValuesTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateProfileValuesTest.php
new file mode 100644
index 0000000..e2b73b8
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateProfileValuesTest.php
@@ -0,0 +1,155 @@
+ 'Migrate user profile values',
+ 'description' => 'User profile values migration',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ // Create some fields so the data gets stored.
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_color',
+ 'type' => 'text',
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_biography',
+ 'type' => 'text_long',
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_sell_address',
+ 'type' => 'list_integer',
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_sold_to',
+ 'type' => 'list_text',
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_bands',
+ 'type' => 'text',
+ 'cardinality' => -1,
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_blog',
+ 'type' => 'link',
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_birthdate',
+ 'type' => 'datetime',
+ ))->save();
+
+ // Create the field instances.
+ foreach (Drupal6UserProfileFields::getData('profile_fields') as $field) {
+ entity_create('field_instance_config', array(
+ 'label' => $field['title'],
+ 'description' => '',
+ 'field_name' => $field['name'],
+ 'entity_type' => 'user',
+ 'bundle' => 'user',
+ 'required' => 0,
+ ))->save();
+ }
+
+ // Create some users to migrate the profile data to.
+ foreach (Drupal6User::getData('users') as $u) {
+ $user = entity_create('user', $u);
+ $user->enforceIsNew();
+ $user->save();
+ }
+ // Add some id mappings for the dependant migrations.
+ $id_mappings = array(
+ 'd6_user_profile_field_instance' => array(
+ array(array(1), array('user', 'user', 'fieldname')),
+ ),
+ 'd6_user_profile_entity_display' => array(
+ array(array(1), array('user', 'user', 'default', 'fieldname')),
+ ),
+ 'd6_user_profile_entity_form_display' => array(
+ array(array(1), array('user', 'user', 'default', 'fieldname')),
+ ),
+ 'd6_user' => array(
+ array(array(2), array(2)),
+ array(array(8), array(8)),
+ array(array(15), array(15)),
+ ),
+ );
+ $this->prepareIdMappings($id_mappings);
+
+ // Load database dumps to provide source data.
+ $path = drupal_get_path('module', 'migrate_drupal');
+ $dumps = array(
+ $path . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UserProfileFields.php',
+ $path . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6User.php',
+ );
+ $this->loadDumps($dumps);
+
+ // Migrate profile fields.
+ $migration_format = entity_load('migration', 'd6_profile_values:user');
+ $executable = new MigrateExecutable($migration_format, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests Drupal 6 profile values to Drupal 8 migration.
+ */
+ public function testUserProfileValues() {
+ $user = user_load(2);
+ $this->assertFalse(is_null($user));
+ $this->assertEqual($user->profile_color->value, 'red');
+ $this->assertEqual($user->profile_biography->value, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam nulla sapien, congue nec risus ut, adipiscing aliquet felis. Maecenas quis justo vel nulla varius euismod. Quisque metus metus, cursus sit amet sem non, bibendum vehicula elit. Cras dui nisl, eleifend at iaculis vitae, lacinia ut felis. Nullam aliquam ligula volutpat nulla consectetur accumsan. Maecenas tincidunt molestie diam, a accumsan enim fringilla sit amet. Morbi a tincidunt tellus. Donec imperdiet scelerisque porta. Sed quis sem bibendum eros congue sodales. Vivamus vel fermentum est, at rutrum orci. Nunc consectetur purus ut dolor pulvinar, ut volutpat felis congue. Cras tincidunt odio sed neque sollicitudin, vehicula tempor metus scelerisque.');
+ $this->assertEqual($user->profile_sell_address->value, '1');
+ $this->assertEqual($user->profile_sold_to->value, 'Fitness spammers');
+ $this->assertEqual($user->profile_bands[0]->value, 'AC/DC');
+ $this->assertEqual($user->profile_bands[1]->value, 'Eagles');
+ #$this->assertEqual($user->profile_blog->url, 'http://example.com/blog');
+ $this->assertEqual($user->profile_birthdate->value, '1974-06-02');
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSearchPageTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSearchPageTest.php
new file mode 100644
index 0000000..6540099
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSearchPageTest.php
@@ -0,0 +1,85 @@
+ 'Migrate search settings to search.page.*.yml',
+ 'description' => 'Upgrade search rank settings to search.page.*.yml',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ /** @var \Drupal\migrate\entity\Migration $migration */
+ $migration = entity_load('migration', 'd6_search_page');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6SearchPage.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests Drupal 6 search settings to Drupal 8 search page entity migration.
+ */
+ public function testSearchPage() {
+ $id = 'node_search';
+ /** @var \Drupal\search\Entity\SearchPage $search_page */
+ $search_page = entity_load('search_page', $id);
+ $this->assertEqual($search_page->id(), $id);
+ $configuration = $search_page->getPlugin()->getConfiguration();
+ $this->assertEqual($configuration['rankings'], array(
+ 'comments' => 5,
+ 'relevance' => 2,
+ 'sticky' => 8,
+ 'views' => 1,
+ ));
+ $this->assertEqual($search_page->getPath(), 'node');
+
+ // Test that we can re-import using the EntitySearchPage destination.
+ Database::getConnection('default', 'migrate')
+ ->update('variable')
+ ->fields(array('value' => serialize(4)))
+ ->condition('name', 'node_rank_comments')
+ ->execute();
+
+ $migration = entity_load_unchanged('migration', 'd6_search_page');
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+
+ $search_page = entity_load('search_page', $id);
+ $configuration = $search_page->getPlugin()->getConfiguration();
+ $this->assertEqual($configuration['rankings']['comments'], 4);
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemCronTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemCronTest.php
new file mode 100644
index 0000000..e159c8a
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemCronTest.php
@@ -0,0 +1,53 @@
+ 'Migrate cron variable to system.*.yml',
+ 'description' => 'Upgrade cron variable to system.*.yml',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_system_cron');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6SystemCron.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, new MigrateMessage());
+ $executable->import();
+ }
+
+ /**
+ * Tests migration of system (cron) variables to system.cron.yml.
+ */
+ public function testSystemCron() {
+ $config = \Drupal::config('system.cron');
+ $this->assertIdentical($config->get('threshold.warning'), 172800);
+ $this->assertIdentical($config->get('threshold.error'), 1209600);
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemFileTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemFileTest.php
new file mode 100644
index 0000000..797ee71
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemFileTest.php
@@ -0,0 +1,53 @@
+ 'Migrate variables to system.*.yml',
+ 'description' => 'Upgrade variables to system.*.yml',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_system_file');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6SystemFile.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, new MigrateMessage());
+ $executable->import();
+ }
+
+ /**
+ * Tests migration of system (file) variables to system.file.yml.
+ */
+ public function testSystemFile() {
+ $old_state = \Drupal::configFactory()->getOverrideState();
+ \Drupal::configFactory()->setOverrideState(FALSE);
+ $config = \Drupal::config('system.file');
+ $this->assertIdentical($config->get('path.private'), 'core/modules/simpletest/files');
+ $this->assertIdentical($config->get('path.temporary'), 'files/temp');
+ \Drupal::configFactory()->setOverrideState($old_state);
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemFilterTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemFilterTest.php
new file mode 100644
index 0000000..418e0c8
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemFilterTest.php
@@ -0,0 +1,52 @@
+ 'Migrate filter variables to system.*.yml',
+ 'description' => 'Upgrade filter variables to system.*.yml',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_system_filter');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6SystemFilter.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, new MigrateMessage());
+ $executable->import();
+ }
+
+ /**
+ * Tests migration of system (filter) variables to system.filter.yml.
+ */
+ public function testSystemFilter() {
+ $config = \Drupal::config('system.filter');
+ $this->assertIdentical($config->get('protocols'), array('http', 'https', 'ftp', 'news', 'nntp', 'tel', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal', 'rtsp'));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemImageGdTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemImageGdTest.php
new file mode 100644
index 0000000..23d3373
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemImageGdTest.php
@@ -0,0 +1,49 @@
+ 'Migrate image gd variables to system.*.yml',
+ 'description' => 'Upgrade image gd variables to system.*.yml',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_system_image_gd');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6SystemImageGd.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, new MigrateMessage());
+ $executable->import();
+ }
+
+ /**
+ * Tests migration of system (image GD) variables to system.image.gd.yml.
+ */
+ public function testSystemImageGd() {
+ $config = \Drupal::config('system.image.gd');
+ $this->assertIdentical($config->get('jpeg_quality'), 75);
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemImageTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemImageTest.php
new file mode 100644
index 0000000..1894f4f
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemImageTest.php
@@ -0,0 +1,49 @@
+ 'Migrate image variables to system.*.yml',
+ 'description' => 'Upgrade image variables to system.*.yml',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_system_image');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6SystemImage.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, new MigrateMessage());
+ $executable->import();
+ }
+
+ /**
+ * Tests migration of system (image) variables to system.image.yml.
+ */
+ public function testSystemImage() {
+ $config = \Drupal::config('system.image');
+ $this->assertIdentical($config->get('toolkit'), 'gd');
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemMaintenanceTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemMaintenanceTest.php
new file mode 100644
index 0000000..d08f9c7
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemMaintenanceTest.php
@@ -0,0 +1,50 @@
+ 'Migrate maintenance variables to system.*.yml',
+ 'description' => 'Upgrade maintenance variables to system.*.yml',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_system_maintenance');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6SystemMaintenance.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, new MigrateMessage());
+ $executable->import();
+ }
+
+ /**
+ * Tests migration of system (maintenance) variables to system.maintenance.yml.
+ */
+ public function testSystemMaintenance() {
+ $config = \Drupal::config('system.maintenance');
+ $this->assertIdentical($config->get('enable'), 0);
+ $this->assertIdentical($config->get('message'), 'Drupal is currently under maintenance. We should be back shortly. Thank you for your patience.');
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemPerformanceTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemPerformanceTest.php
new file mode 100644
index 0000000..ff3feb8
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemPerformanceTest.php
@@ -0,0 +1,51 @@
+ 'Migrate performance variables to system.*.yml',
+ 'description' => 'Upgrade performance variables to system.*.yml',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_system_performance');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6SystemPerformance.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, new MigrateMessage());
+ $executable->import();
+ }
+
+ /**
+ * Tests migration of system (Performance) variables to system.performance.yml.
+ */
+ public function testSystemPerformance() {
+ $config = \Drupal::config('system.performance');
+ $this->assertIdentical($config->get('css.preprocess'), FALSE);
+ $this->assertIdentical($config->get('js.preprocess'), FALSE);
+ $this->assertIdentical($config->get('cache.page.max_age'), 0);
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemRssTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemRssTest.php
new file mode 100644
index 0000000..69bc4e6
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemRssTest.php
@@ -0,0 +1,49 @@
+ 'Migrate rss variable to system.*.yml',
+ 'description' => 'Upgrade rss variable to system.*.yml',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_system_rss');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6SystemRss.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, new MigrateMessage());
+ $executable->import();
+ }
+
+ /**
+ * Tests migration of system (rss) variables to system.rss.yml.
+ */
+ public function testSystemRss() {
+ $config = \Drupal::config('system.rss');
+ $this->assertIdentical($config->get('items.limit'), 10);
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemSiteTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemSiteTest.php
new file mode 100644
index 0000000..bd17eb0
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemSiteTest.php
@@ -0,0 +1,55 @@
+ 'Migrate site variables to system.*.yml',
+ 'description' => 'Upgrade site variables to system.*.yml',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_system_site');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6SystemSite.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, new MigrateMessage());
+ $executable->import();
+ }
+
+ /**
+ * Tests migration of system (site) variables to system.site.yml.
+ */
+ public function testSystemSite() {
+ $config = \Drupal::config('system.site');
+ $this->assertIdentical($config->get('name'), 'site_name');
+ $this->assertIdentical($config->get('mail'), 'site_mail@example.com');
+ $this->assertIdentical($config->get('slogan'), 'Migrate rocks');
+ $this->assertIdentical($config->get('page.403'), 'user');
+ $this->assertIdentical($config->get('page.404'), 'page-not-found');
+ $this->assertIdentical($config->get('page.front'), 'node');
+ $this->assertIdentical($config->get('admin_compact_mode'), FALSE);
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemThemeTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemThemeTest.php
new file mode 100644
index 0000000..31bef18
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateSystemThemeTest.php
@@ -0,0 +1,50 @@
+ 'Migrate theme variables to system.*.yml',
+ 'description' => 'Upgrade theme variables to system.*.yml',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_system_theme');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6SystemTheme.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, new MigrateMessage());
+ $executable->import();
+ }
+
+ /**
+ * Tests migration of system (theme) variables to system.theme.yml.
+ */
+ public function testSystemTheme() {
+ $config = \Drupal::config('system.theme');
+ $this->assertIdentical($config->get('admin'), '0');
+ $this->assertIdentical($config->get('default'), 'garland');
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateTaxonomyTermTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateTaxonomyTermTest.php
new file mode 100644
index 0000000..6f963ae
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateTaxonomyTermTest.php
@@ -0,0 +1,115 @@
+ 'Migrate taxonomy terms',
+ 'description' => 'Upgrade taxonomy terms',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $this->prepareIdMappings(array(
+ 'd6_taxonomy_vocabulary' => array(
+ array(array(1), array('vocabulary_1_i_0_')),
+ array(array(2), array('vocabulary_2_i_1_')),
+ array(array(3), array('vocabulary_3_i_2_')),
+ )));
+ /** @var \Drupal\migrate\entity\Migration $migration */
+ $migration = entity_load('migration', 'd6_taxonomy_term');
+ $path = drupal_get_path('module', 'migrate_drupal');
+ $dumps = array(
+ $path . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6TaxonomyTerm.php',
+ $path . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6TaxonomyVocabulary.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests the Drupal 6 taxonomy term to Drupal 8 migration.
+ */
+ public function testTaxonomyTerms() {
+ $expected_results = array(
+ '1' => array(
+ 'source_vid' => 1,
+ 'vid' => 'vocabulary_1_i_0_',
+ 'weight' => 0,
+ ),
+ '2' => array(
+ 'source_vid' => 2,
+ 'vid' => 'vocabulary_2_i_1_',
+ 'weight' => 3,
+ ),
+ '3' => array(
+ 'source_vid' => 2,
+ 'vid' => 'vocabulary_2_i_1_',
+ 'weight' => 4,
+ 'parent' => array(2),
+ ),
+ '4' => array(
+ 'source_vid' => 3,
+ 'vid' => 'vocabulary_3_i_2_',
+ 'weight' => 6,
+ ),
+ '5' => array(
+ 'source_vid' => 3,
+ 'vid' => 'vocabulary_3_i_2_',
+ 'weight' => 7,
+ 'parent' => array(4),
+ ),
+ '6' => array(
+ 'source_vid' => 3,
+ 'vid' => 'vocabulary_3_i_2_',
+ 'weight' => 8,
+ 'parent' => array(4, 5),
+ ),
+ );
+ $terms = entity_load_multiple('taxonomy_term', array_keys($expected_results));
+ foreach ($expected_results as $tid => $values) {
+ /** @var Term $term */
+ $term = $terms[$tid];
+ $this->assertIdentical($term->name->value, "term {$tid} of vocabulary {$values['source_vid']}");
+ $this->assertIdentical($term->description->value, "description of term {$tid} of vocabulary {$values['source_vid']}");
+ $this->assertEqual($term->vid->value, $values['vid']);
+ $this->assertEqual($term->weight->value, $values['weight']);
+ if (empty($values['parent'])) {
+ $this->assertNull($term->parent->value);
+ }
+ else {
+ $parents = array();
+ foreach (taxonomy_term_load_parents($tid) as $parent) {
+ $parents[] = $parent->id();
+ }
+ $this->assertEqual($values['parent'], $parents);
+ }
+ }
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateTaxonomyVocabularyTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateTaxonomyVocabularyTest.php
new file mode 100644
index 0000000..52977b5
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateTaxonomyVocabularyTest.php
@@ -0,0 +1,66 @@
+ 'Migrate taxonomy vocabularies.',
+ 'description' => 'Migrate taxonomy vocabularies to taxonomy.vocabulary.*.yml',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_taxonomy_vocabulary');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6TaxonomyVocabulary.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests the Drupal 6 taxonomy vocabularies to Drupal 8 migration.
+ */
+ public function testTaxonomyVocabulary() {
+ for ($i = 0; $i < 3; $i++) {
+ $j = $i + 1;
+ $vocabulary = entity_load('taxonomy_vocabulary', "vocabulary_{$j}_i_{$i}_");
+ $this->assertEqual(array($vocabulary->id()), entity_load('migration', 'd6_taxonomy_vocabulary')->getIdMap()->lookupDestinationID(array($j)));
+ $this->assertEqual($vocabulary->name, "vocabulary $j (i=$i)");
+ $this->assertEqual($vocabulary->description, "description of vocabulary $j (i=$i)");
+ $this->assertEqual($vocabulary->hierarchy, $i);
+ $this->assertEqual($vocabulary->weight, 4 + $i);
+ }
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateTermNodeRevisionTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateTermNodeRevisionTest.php
new file mode 100644
index 0000000..325bb73
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateTermNodeRevisionTest.php
@@ -0,0 +1,60 @@
+ 'Migrate taxonomy term node revisions',
+ 'description' => 'Upgrade taxonomy term node associations',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $id_mappings = array(
+ 'd6_term_node' => array(
+ array(array(2), array(1)),
+ ),
+ 'd6_node_revision' => array(
+ array(array(2), array(2)),
+ ),
+ );
+ $this->prepareIdMappings($id_mappings);
+ /** @var \Drupal\migrate\entity\Migration $migration */
+ $migrations = entity_load_multiple('migration', array('d6_term_node_revision:*'));
+ foreach ($migrations as $migration) {
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+ }
+
+ /**
+ * Tests the Drupal 6 term-node revision association to Drupal 8 migration.
+ */
+ public function testTermRevisionNode() {
+ $node = \Drupal::entityManager()->getStorage('node')->loadRevision(2);
+ $this->assertEqual(count($node->vocabulary_3_i_2_), 2);
+ $this->assertEqual($node->vocabulary_3_i_2_[0]->value, 4);
+ $this->assertEqual($node->vocabulary_3_i_2_[1]->value, 5);
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateTermNodeTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateTermNodeTest.php
new file mode 100644
index 0000000..8d24dfc
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateTermNodeTest.php
@@ -0,0 +1,55 @@
+ 'Migrate taxonomy term node',
+ 'description' => 'Upgrade taxonomy term node associations',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ /** @var \Drupal\migrate\entity\Migration $migration */
+ $migrations = entity_load_multiple('migration', array('d6_term_node:*'));
+ foreach ($migrations as $migration) {
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+ }
+
+ /**
+ * Tests the Drupal 6 term-node association to Drupal 8 migration.
+ */
+ public function testTermNode() {
+ $nodes = node_load_multiple(array(1, 2), TRUE);
+ $node = $nodes[1];
+ $this->assertEqual(count($node->vocabulary_1_i_0_), 1);
+ $this->assertEqual($node->vocabulary_1_i_0_[0]->value, 1);
+ $node = $nodes[2];
+ $this->assertEqual(count($node->vocabulary_2_i_1_), 2);
+ $this->assertEqual($node->vocabulary_2_i_1_[0]->value, 2);
+ $this->assertEqual($node->vocabulary_2_i_1_[1]->value, 3);
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUploadEntityDisplayTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUploadEntityDisplayTest.php
new file mode 100644
index 0000000..3d312ba
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUploadEntityDisplayTest.php
@@ -0,0 +1,82 @@
+ 'Migrate upload entity display.',
+ 'description' => 'Upload entity display',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+
+ entity_create('node_type', array('type' => 'article'))->save();
+ entity_create('node_type', array('type' => 'story'))->save();
+ entity_create('node_type', array('type' => 'page'))->save();
+
+ $id_mappings = array(
+ 'd6_upload_field_instance' => array(
+ array(array(1), array('node', 'page', 'upload')),
+ ),
+ );
+ $this->prepareIdMappings($id_mappings);
+
+ $migration = entity_load('migration', 'd6_upload_entity_display');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UploadInstance.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests the Drupal 6 upload settings to Drupal 8 entity display migration.
+ */
+ public function testUploadEntityDisplay() {
+ $display = entity_get_display('node', 'page', 'default');
+ $component = $display->getComponent('upload');
+ $this->assertEqual($component['type'], 'file_default');
+
+ $display = entity_get_display('node', 'story', 'default');
+ $component = $display->getComponent('upload');
+ $this->assertEqual($component['type'], 'file_default');
+
+ // Assure this doesn't exist.
+ $display = entity_get_display('node', 'article', 'default');
+ $component = $display->getComponent('upload');
+ $this->assertTrue(is_null($component));
+
+ $this->assertEqual(array('node', 'page', 'default', 'upload'), entity_load('migration', 'd6_upload_entity_display')->getIdMap()->lookupDestinationID(array('page')));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUploadEntityFormDisplayTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUploadEntityFormDisplayTest.php
new file mode 100644
index 0000000..fd74202
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUploadEntityFormDisplayTest.php
@@ -0,0 +1,83 @@
+ 'Migrate upload entity form display.',
+ 'description' => 'Upload form entity display',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+
+ entity_create('node_type', array('type' => 'article'))->save();
+ entity_create('node_type', array('type' => 'story'))->save();
+ entity_create('node_type', array('type' => 'page'))->save();
+
+ $id_mappings = array(
+ 'd6_upload_field_instance' => array(
+ array(array(1), array('node', 'page', 'upload')),
+ ),
+ );
+ $this->prepareIdMappings($id_mappings);
+
+ $migration = entity_load('migration', 'd6_upload_entity_form_display');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UploadInstance.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+
+ }
+
+ /**
+ * Tests the Drupal 6 upload settings to Drupal 8 entity form display migration.
+ */
+ public function testUploadEntityFormDisplay() {
+ $display = entity_get_form_display('node', 'page', 'default');
+ $component = $display->getComponent('upload');
+ $this->assertEqual($component['type'], 'file_generic');
+
+ $display = entity_get_form_display('node', 'story', 'default');
+ $component = $display->getComponent('upload');
+ $this->assertEqual($component['type'], 'file_generic');
+
+ // Assure this doesn't exist.
+ $display = entity_get_form_display('node', 'article', 'default');
+ $component = $display->getComponent('upload');
+ $this->assertTrue(is_null($component));
+
+ $this->assertEqual(array('node', 'page', 'default', 'upload'), entity_load('migration', 'd6_upload_entity_form_display')->getIdMap()->lookupDestinationID(array('page')));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUploadFieldTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUploadFieldTest.php
new file mode 100644
index 0000000..83edcfb
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUploadFieldTest.php
@@ -0,0 +1,59 @@
+ 'Migrate uploads',
+ 'description' => 'Uploads migration',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_upload_field');
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UploadField.php',
+ );
+ $this->prepare($migration, $dumps);
+ }
+
+ /**
+ * Tests the Drupal 6 upload settings to Drupal 8 field migration.
+ */
+ public function testUpload() {
+ $field = entity_load('field_config', 'node.upload');
+ $this->assertEqual($field->id(), 'node.upload');
+ $this->assertEqual(array('node', 'upload'), entity_load('migration', 'd6_upload_field')->getIdMap()->lookupDestinationID(array('')));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUploadInstanceTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUploadInstanceTest.php
new file mode 100644
index 0000000..ee293df
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUploadInstanceTest.php
@@ -0,0 +1,89 @@
+ 'Migrate upload field instance.',
+ 'description' => 'Upload field instance migration',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ // Add some node mappings to get past checkRequirements().
+ $id_mappings = array(
+ 'd6_upload_field' => array(
+ array(array(1), array('node', 'upload')),
+ ),
+ );
+ $this->prepareIdMappings($id_mappings);
+
+ foreach (array('page', 'story') as $type) {
+ entity_create('node_type', array('type' => $type))->save();
+ }
+ entity_create('field_config', array(
+ 'entity_type' => 'node',
+ 'name' => 'upload',
+ 'type' => 'file',
+ 'translatable' => '0',
+ ))->save();
+
+ $migration = entity_load('migration', 'd6_upload_field_instance');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UploadInstance.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests the Drupal 6 upload settings to Drupal 8 field instance migration.
+ */
+ public function testUploadFieldInstance() {
+ $field = entity_load('field_instance_config', 'node.page.upload');
+ $settings = $field->getSettings();
+ $this->assertEqual($field->id(), 'node.page.upload');
+ $this->assertEqual($settings['file_extensions'], 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp');
+ $this->assertEqual($settings['max_filesize'], '1MB');
+ $this->assertEqual($settings['description_field'], TRUE);
+
+ $field = entity_load('field_instance_config', 'node.story.upload');
+ $this->assertEqual($field->id(), 'node.story.upload');
+
+ // Shouldn't exist.
+ $field = entity_load('field_instance_config', 'node.article.upload');
+ $this->assertTrue(is_null($field));
+
+ $this->assertEqual(array('node', 'page', 'upload'), entity_load('migration', 'd6_upload_field_instance')->getIdMap()->lookupDestinationID(array('page')));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUploadTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUploadTest.php
new file mode 100644
index 0000000..0c10228
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUploadTest.php
@@ -0,0 +1,60 @@
+ 'Migrate upload',
+ 'description' => 'Migrate association data between nodes and files.',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp() {
+ parent::setUp();
+ /** @var \Drupal\migrate\entity\Migration $migration */
+ $migration = entity_load('migration', 'd6_upload');
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Test upload migration from Drupal 6 to Drupal 8.
+ */
+ function testUpload() {
+ $nodes = node_load_multiple(array(1, 2), TRUE);
+ $node = $nodes[1];
+ $this->assertEqual(count($node->upload), 1);
+ $this->assertEqual($node->upload[0]->target_id, 1);
+ $this->assertEqual($node->upload[0]->description, 'file 1-1-1');
+ $this->assertEqual($node->upload[0]->isDisplayed(), FALSE);
+ // @TODO: remove this.
+ return;
+ $node = $nodes[2];
+ $this->assertEqual(count($node->upload), 2);
+ $this->assertEqual($node->upload[0]->target_id, 3);
+ $this->assertEqual($node->upload[0]->description, 'file 2-3-3');
+ $this->assertEqual($node->upload[0]->isDisplayed(), FALSE);
+ $this->assertEqual($node->upload[1]->target_id, 2);
+ $this->assertEqual($node->upload[1]->isDisplayed(), TRUE);
+ $this->assertEqual($node->upload[1]->description, 'file 2-3-2');
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUrlAliasTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUrlAliasTest.php
new file mode 100644
index 0000000..29e3ac9
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUrlAliasTest.php
@@ -0,0 +1,85 @@
+ 'Url alias migration.',
+ 'description' => 'Url alias migration',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_url_alias');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UrlAlias.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Test the url alias migration.
+ */
+ public function testUrlAlias() {
+ $migration = entity_load('migration', 'd6_url_alias');
+ // Test that the field exists.
+ $conditions = array(
+ 'source' => 'node/1',
+ 'alias' => 'alias-one',
+ 'langcode' => 'en',
+ );
+ $path = \Drupal::service('path.alias_storage')->load($conditions);
+ $this->assertNotNull($path, "Path alias for node/1 successfully loaded.");
+ $this->assertEqual(array(1), $migration->getIdMap()->lookupDestinationID(array($path['pid'])), "Test IdMap");
+ $conditions = array(
+ 'source' => 'node/2',
+ 'alias' => 'alias-two',
+ 'langcode' => 'en',
+ );
+ $path = \Drupal::service('path.alias_storage')->load($conditions);
+ $this->assertNotNull($path, "Path alias for node/2 successfully loaded.");
+
+ // Test that we can re-import using the UrlAlias destination.
+ Database::getConnection('default', 'migrate')
+ ->update('url_alias')
+ ->fields(array('dst' => 'new-url-alias'))
+ ->condition('src', 'node/2')
+ ->execute();
+
+ db_update($migration->getIdMap()->mapTableName())
+ ->fields(array('source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE))
+ ->execute();
+ $migration = entity_load_unchanged('migration', 'd6_url_alias');
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+
+ $path = \Drupal::service('path.alias_storage')->load(array('pid' => $path['pid']));
+ $this->assertEqual($path['alias'], 'new-url-alias');
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserPictureEntityDisplayTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserPictureEntityDisplayTest.php
new file mode 100644
index 0000000..3919c7f
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserPictureEntityDisplayTest.php
@@ -0,0 +1,66 @@
+ 'Migrate user picture entity display.',
+ 'description' => 'User picture entity display',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp() {
+ parent::setUp();
+
+ $id_mappings = array(
+ 'd6_user_picture_field_instance' => array(
+ array(array(1), array('user', 'user', 'user_picture')),
+ ),
+ );
+ $this->prepareIdMappings($id_mappings);
+
+ $migration = entity_load('migration', 'd6_user_picture_entity_display');
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests the Drupal 6 user picture to Drupal 8 entity display migration.
+ */
+ public function testUserPictureEntityDisplay() {
+ $display = entity_get_display('user', 'user', 'default');
+ $component = $display->getComponent('user_picture');
+ $this->assertEqual($component['type'], 'image');
+ $this->assertEqual($component['settings']['image_link'], 'content');
+
+ $this->assertEqual(array('user', 'user', 'default', 'user_picture'), entity_load('migration', 'd6_user_picture_entity_display')->getIdMap()->lookupDestinationID(array('')));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserPictureEntityFormDisplayTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserPictureEntityFormDisplayTest.php
new file mode 100644
index 0000000..c4de81b
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserPictureEntityFormDisplayTest.php
@@ -0,0 +1,65 @@
+ 'Migrate user picture entity form display.',
+ 'description' => 'User picture entity form display',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp() {
+ parent::setUp();
+ $id_mappings = array(
+ 'd6_user_picture_field_instance' => array(
+ array(array(1), array('user', 'user', 'user_picture')),
+ ),
+ );
+ $this->prepareIdMappings($id_mappings);
+
+ $migration = entity_load('migration', 'd6_user_picture_entity_form_display');
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests the Drupal 6 user picture to Drupal 8 entity form display migration.
+ */
+ public function testUserPictureEntityFormDisplay() {
+ $display = entity_get_form_display('user', 'user', 'default');
+ $component = $display->getComponent('user_picture');
+ $this->assertEqual($component['type'], 'image_image');
+ $this->assertEqual($component['settings']['progress_indicator'], 'throbber');
+
+ $this->assertEqual(array('user', 'user', 'default', 'user_picture'), entity_load('migration', 'd6_user_picture_entity_form_display')->getIdMap()->lookupDestinationID(array('')));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserPictureFieldTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserPictureFieldTest.php
new file mode 100644
index 0000000..9184d2c
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserPictureFieldTest.php
@@ -0,0 +1,50 @@
+ 'Migrate user picture field',
+ 'description' => 'User picture field migration',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_user_picture_field');
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Test the user picture field migration.
+ */
+ public function testUserPictureField() {
+ $field = entity_load('field_config', 'user.user_picture');
+ $this->assertEqual($field->id(), 'user.user_picture');
+ $this->assertEqual(array('user', 'user_picture'), entity_load('migration', 'd6_user_picture_field')->getIdMap()->lookupDestinationID(array('')));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserPictureFileTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserPictureFileTest.php
new file mode 100644
index 0000000..0bf5947
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserPictureFileTest.php
@@ -0,0 +1,74 @@
+ 'Migrate user pictures',
+ 'description' => 'User pictures migration',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp() {
+ parent::setUp();
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6User.php',
+ );
+ /** @var \Drupal\migrate\entity\Migration $migration */
+ $migration = entity_load('migration', 'd6_user_picture_file');
+ $migration->source['conf_path'] = 'core/modules/simpletest';
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests the Drupal 6 user pictures to Drupal 8 migration.
+ */
+ public function testUserPictures() {
+ $file_ids = array();
+ foreach (entity_load('migration', 'd6_user_picture_file')->getIdMap() as $destination_ids) {
+ $file_ids[] = reset($destination_ids);
+ }
+ $files = entity_load_multiple('file', $file_ids);
+ /** @var \Drupal\file\FileInterface $file */
+ $file = array_shift($files);
+ $this->assertEqual($file->getFilename(), 'image-test.jpg');
+ $this->assertEqual($file->getFileUri(), 'public://image-test.jpg');
+ $this->assertEqual($file->getSize(), 1901);
+ $this->assertEqual($file->getMimeType(), 'image/jpeg');
+
+ $file = array_shift($files);
+ $this->assertEqual($file->getFilename(), 'image-test.png');
+ $this->assertEqual($file->getFileUri(), 'public://image-test.png');
+ $this->assertFalse($files);
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserPictureInstanceTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserPictureInstanceTest.php
new file mode 100644
index 0000000..f6881de
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserPictureInstanceTest.php
@@ -0,0 +1,74 @@
+ 'Migrate user picture field instance.',
+ 'description' => 'User picture field instance migration',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp() {
+ parent::setUp();
+ // Add some node mappings to get past checkRequirements().
+ $id_mappings = array(
+ 'd6_user_picture_field' => array(
+ array(array('user_upload'), array('name', 'bundle')),
+ ),
+ );
+ $this->prepareIdMappings($id_mappings);
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'user_picture',
+ 'type' => 'image',
+ 'translatable' => '0',
+ ))->save();
+
+ $migration = entity_load('migration', 'd6_user_picture_field_instance');
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests the Drupal 6 user picture to Drupal 8 picture field instance migration.
+ */
+ public function testUserPictureFieldInstance() {
+ $field = entity_load('field_instance_config', 'user.user.user_picture');
+ $settings = $field->getSettings();
+ $this->assertEqual($settings['file_extensions'], 'png gif jpg jpeg');
+ $this->assertEqual($settings['file_directory'], 'pictures');
+ $this->assertEqual($settings['max_filesize'], '30KB');
+ $this->assertEqual($settings['max_resolution'], '85x85');
+
+ $this->assertEqual(array('user', 'user', 'user_picture'), entity_load('migration', 'd6_user_picture_field_instance')->getIdMap()->lookupDestinationID(array('')));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileEntityDisplayTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileEntityDisplayTest.php
new file mode 100644
index 0000000..62ece55
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileEntityDisplayTest.php
@@ -0,0 +1,127 @@
+ 'Migrate user profile entity display',
+ 'description' => 'Test the user profile entity display migration.',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+
+ // Create some fields so the data gets stored.
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_color',
+ 'type' => 'text',
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_biography',
+ 'type' => 'text_long',
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_sell_address',
+ 'type' => 'list_integer',
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_sold_to',
+ 'type' => 'list_text',
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_bands',
+ 'type' => 'text',
+ 'cardinality' => -1,
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_blog',
+ 'type' => 'link',
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_birthdate',
+ 'type' => 'datetime',
+ ))->save();
+ $field_data = Drupal6UserProfileFields::getData('profile_fields');
+ foreach ($field_data as $field) {
+ entity_create('field_instance_config', array(
+ 'label' => $field['title'],
+ 'description' => '',
+ 'field_name' => $field['name'],
+ 'entity_type' => 'user',
+ 'bundle' => 'user',
+ 'required' => 1,
+ ))->save();
+ }
+
+ $migration = entity_load('migration', 'd6_user_profile_entity_display');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UserProfileFields.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+
+ }
+
+ /**
+ * Tests migration of user profile fields.
+ */
+ public function testUserProfileFields() {
+ $display = entity_get_display('user', 'user', 'default');
+
+ // Test a text field.
+ $component = $display->getComponent('profile_color');
+ $this->assertEqual($component['type'], 'text_default');
+
+ // Test a list field.
+ $component = $display->getComponent('profile_bands');
+ $this->assertEqual($component['type'], 'text_default');
+
+ // Test a date field.
+ $component = $display->getComponent('profile_birthdate');
+ $this->assertEqual($component['type'], 'datetime_default');
+
+ // Test PROFILE_PRIVATE field is hidden.
+ $this->assertNull($display->getComponent('profile_sell_address'));
+
+ // Test PROFILE_HIDDEN field is hidden.
+ $this->assertNull($display->getComponent('profile_sold_to'));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileEntityFormDisplayTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileEntityFormDisplayTest.php
new file mode 100644
index 0000000..028f465
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileEntityFormDisplayTest.php
@@ -0,0 +1,121 @@
+ 'Migrate user profile entity form display',
+ 'description' => 'Test the user profile entity form display migration.',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+
+ // Create some fields so the data gets stored.
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_color',
+ 'type' => 'text',
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_biography',
+ 'type' => 'text_long',
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_sell_address',
+ 'type' => 'list_integer',
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_sold_to',
+ 'type' => 'list_text',
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_bands',
+ 'type' => 'text',
+ 'cardinality' => -1,
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_blog',
+ 'type' => 'link',
+ ))->save();
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'profile_birthdate',
+ 'type' => 'datetime',
+ ))->save();
+ $field_data = Drupal6UserProfileFields::getData('profile_fields');
+ foreach ($field_data as $field) {
+ entity_create('field_instance_config', array(
+ 'label' => $field['title'],
+ 'description' => '',
+ 'field_name' => $field['name'],
+ 'entity_type' => 'user',
+ 'bundle' => 'user',
+ 'required' => 1,
+ ))->save();
+ }
+
+ $migration = entity_load('migration', 'd6_user_profile_entity_form_display');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UserProfileFields.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests migration of user profile fields.
+ */
+ public function testUserProfileEntityFormDisplay() {
+ $display = entity_get_form_display('user', 'user', 'default');
+
+ // Test a text field.
+ $component = $display->getComponent('profile_color');
+ $this->assertEqual($component['type'], 'text_textfield');
+
+ // Test a list field.
+ $component = $display->getComponent('profile_bands');
+ $this->assertEqual($component['type'], 'text_textfield');
+
+ // Test a date field.
+ $component = $display->getComponent('profile_birthdate');
+ $this->assertEqual($component['type'], 'datetime_default');
+
+ // Test PROFILE_PRIVATE field is hidden.
+ $this->assertNull($display->getComponent('profile_sell_address'));
+
+ // Test PROFILE_HIDDEN field is hidden.
+ $this->assertNull($display->getComponent('profile_sold_to'));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileFieldInstanceTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileFieldInstanceTest.php
new file mode 100644
index 0000000..3dd1d9f
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileFieldInstanceTest.php
@@ -0,0 +1,119 @@
+ 'Migrate user profile field instance',
+ 'description' => 'Test the user profile field instance migration.',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ // Add some id mappings for the dependant migrations.
+ $id_mappings = array(
+ 'd6_user_profile_field' => array(
+ array(array(1), array('user', 'profile_color')),
+ ),
+ );
+ $this->prepareIdMappings($id_mappings);
+ $this->createFields();
+ /** @var \Drupal\migrate\entity\Migration $migration */
+ $migration = entity_load('migration', 'd6_user_profile_field_instance');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UserProfileFields.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+
+ }
+
+ /**
+ * Tests migration of user profile fields.
+ */
+ public function testUserProfileFields() {
+ // Migrated a text field.
+ $field = entity_load('field_instance_config', 'user.user.profile_color');
+ $this->assertEqual($field->label(), 'Favorite color');
+ $this->assertEqual($field->getDescription(), 'List your favorite color');
+
+ // Migrated a textarea.
+ $field = entity_load('field_instance_config', 'user.user.profile_biography');
+ $this->assertEqual($field->label(), 'Biography');
+ $this->assertEqual($field->getDescription(), 'Tell people a little bit about yourself');
+
+ // Migrated checkbox field.
+ $field = entity_load('field_instance_config', 'user.user.profile_sell_address');
+ $this->assertEqual($field->label(), 'Sell your e-mail address?');
+ $this->assertEqual($field->getDescription(), "If you check this box, we'll sell your address to spammers to help line the pockets of our shareholders. Thanks!");
+
+ // Migrated selection field.
+ $field = entity_load('field_instance_config', 'user.user.profile_sold_to');
+ $this->assertEqual($field->label(), 'Sales Category');
+ $this->assertEqual($field->getDescription(), "Select the sales categories to which this user's address was sold.");
+
+ // Migrated list field.
+ $field = entity_load('field_instance_config', 'user.user.profile_bands');
+ $this->assertEqual($field->label(), 'Favorite bands');
+ $this->assertEqual($field->getDescription(), "Enter your favorite bands. When you've saved your profile, you'll be able to find other people with the same favorites.");
+
+/*
+ // Migrated URL field.
+ $field = entity_load('field_instance_config', 'user.user.profile_blog');
+ $this->assertEqual($field->label(), 'Your blog');
+ $this->assertEqual($field->getDescription(), "Paste the full URL, including http://, of your personal blog.");
+*/
+
+ // Migrated date field.
+ $field = entity_load('field_instance_config', 'user.user.profile_birthdate');
+ $this->assertEqual($field->label(), 'Birthdate');
+ $this->assertEqual($field->getDescription(), "Enter your birth date and we'll send you a coupon.");
+ }
+
+ /**
+ * Helper to create fields.
+ */
+ protected function createFields() {
+ $fields = array(
+ 'profile_color' => 'text',
+ 'profile_biography' => 'text_long',
+ 'profile_sell_address' => 'list_integer',
+ 'profile_sold_to' => 'list_text',
+ 'profile_bands' => 'text',
+ 'profile_blog' => 'link',
+ 'profile_birthdate' => 'datetime',
+ );
+ foreach ($fields as $name => $type) {
+ entity_create('field_config', array(
+ 'name' => $name,
+ 'entity_type' => 'user',
+ 'type' => $type,
+ ))->save();
+ }
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileFieldTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileFieldTest.php
new file mode 100644
index 0000000..2d1a773
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileFieldTest.php
@@ -0,0 +1,83 @@
+ 'Migrate user profile fields',
+ 'description' => 'Test the user profile field migration.',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_user_profile_field');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UserProfileFields.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+
+ }
+
+ /**
+ * Tests migration of user profile fields.
+ */
+ public function testUserProfileFields() {
+ // Migrated a text field.
+ $field = entity_load('field_config', 'user.profile_color');
+ $this->assertEqual($field->type, 'text', 'Field type is text.');
+ $this->assertEqual($field->cardinality, 1, 'Text field has correct cardinality');
+
+ // Migrated a textarea.
+ $field = entity_load('field_config', 'user.profile_biography');
+ $this->assertEqual($field->type, 'text_long', 'Field type is text_long.');
+
+ // Migrated checkbox field.
+ $field = entity_load('field_config', 'user.profile_sell_address');
+ $this->assertEqual($field->type, 'list_integer', 'Field type is list_integer.');
+
+ // Migrated selection field.
+ $field = entity_load('field_config', 'user.profile_sold_to');
+ $this->assertEqual($field->type, 'list_text', 'Field type is list_text.');
+
+ // Migrated list field.
+ $field = entity_load('field_config', 'user.profile_bands');
+ $this->assertEqual($field->type, 'text', 'Field type is text.');
+ $this->assertEqual($field->cardinality, -1, 'List field has correct cardinality');
+
+/*
+ // Migrated URL field.
+ $field = entity_load('field_config', 'user.profile_blog');
+ $this->assertEqual($field->type, 'link', 'Field type is link.');
+*/
+
+ // Migrated date field.
+ $field = entity_load('field_config', 'user.profile_birthdate');
+ $this->assertEqual($field->type, 'datetime', 'Field type is datetime.');
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserTest.php
new file mode 100644
index 0000000..bc071ae
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserTest.php
@@ -0,0 +1,200 @@
+ 'Migrate users',
+ 'description' => 'Users migration',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ // Create the user profile field and instance.
+ entity_create('field_config', array(
+ 'entity_type' => 'user',
+ 'name' => 'user_picture',
+ 'type' => 'image',
+ 'translatable' => '0',
+ ))->save();
+ entity_create('field_instance_config', array(
+ 'label' => 'User Picture',
+ 'description' => '',
+ 'field_name' => 'user_picture',
+ 'entity_type' => 'user',
+ 'bundle' => 'user',
+ 'required' => 0,
+ ))->save();
+
+ $file = entity_create('file', array(
+ 'fid' => 2,
+ 'uid' => 2,
+ 'filename' => 'image-test.jpg',
+ 'uri' => "public://image-test.jpg",
+ 'filemime' => 'image/jpeg',
+ 'created' => 1,
+ 'changed' => 1,
+ 'status' => FILE_STATUS_PERMANENT,
+ ));
+ $file->enforceIsNew();
+ file_put_contents($file->getFileUri(), file_get_contents('core/modules/simpletest/files/image-1.png'));
+ $file->save();
+
+ $file = entity_create('file', array(
+ 'fid' => 8,
+ 'uid' => 8,
+ 'filename' => 'image-test.png',
+ 'uri' => "public://image-test.png",
+ 'filemime' => 'image/png',
+ 'created' => 1,
+ 'changed' => 1,
+ 'status' => FILE_STATUS_PERMANENT,
+ ));
+ $file->enforceIsNew();
+ file_put_contents($file->getFileUri(), file_get_contents('core/modules/simpletest/files/image-2.jpg'));
+ $file->save();
+
+ // Load database dumps to provide source data.
+ $path = drupal_get_path('module', 'migrate_drupal');
+ $dumps = array(
+ $path . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6FilterFormat.php',
+ $path . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UserProfileFields.php',
+ $path . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UserRole.php',
+ $path . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6User.php',
+ );
+ $this->loadDumps($dumps);
+
+ $id_mappings = array(
+ 'd6_filter_format' => array(
+ array(array(1), array('filtered_html')),
+ array(array(2), array('full_html')),
+ array(array(3), array('escape_html_filter')),
+ ),
+ 'd6_user_role' => array(
+ array(array(1), array('anonymous user')),
+ array(array(2), array('authenticated user')),
+ array(array(3), array('migrate test role 1')),
+ array(array(4), array('migrate test role 2')),
+ array(array(5), array('migrate test role 3')),
+ ),
+ 'd6_user_picture_entity_display' => array(
+ array(array(1), array('user', 'user', 'default', 'user_picture')),
+ ),
+ 'd6_user_picture_entity_form_display' => array(
+ array(array(1), array('user', 'user', 'default', 'user_picture')),
+ ),
+ 'd6_user_picture_file' => array(
+ array(array(2), array(2)),
+ array(array(8), array(8)),
+ ),
+ );
+
+ $this->prepareIdMappings($id_mappings);
+
+ // Migrate users.
+ $migration = entity_load('migration', 'd6_user');
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests the Drupal6 user to Drupal 8 migration.
+ */
+ public function testUser() {
+ $users = Database::getConnection('default', 'migrate')
+ ->select('users', 'u')
+ ->fields('u')
+ ->execute()
+ ->fetchAll();
+
+ foreach ($users as $source) {
+ // Get roles directly from the source.
+ $rids = Database::getConnection('default', 'migrate')
+ ->select('users_roles', 'ur')
+ ->fields('ur', array('rid'))
+ ->condition('ur.uid', $source->uid)
+ ->execute()
+ ->fetchCol();
+ $roles = array(DRUPAL_AUTHENTICATED_RID);
+ $migration_role = entity_load('migration', 'd6_user_role');
+ foreach ($rids as $rid) {
+ $role = $migration_role->getIdMap()->lookupDestinationId(array($rid));
+ $roles[] = reset($role);
+ }
+ // Get the user signature format.
+ $migration_format = entity_load('migration', 'd6_filter_format');
+ $signature_format = $migration_format->getIdMap()->lookupDestinationId(array($source->signature_format));
+
+ $user = user_load($source->uid);
+ $this->assertEqual($user->id(), $source->uid);
+ $this->assertEqual($user->label(), $source->name);
+ $this->assertEqual($user->getEmail(), $source->mail);
+ $this->assertEqual($user->getSignature(), $source->signature);
+ $this->assertEqual($user->getSignatureFormat(), reset($signature_format));
+ $this->assertEqual($user->getCreatedTime(), $source->created);
+ $this->assertEqual($user->getLastAccessedTime(), $source->access);
+ $this->assertEqual($user->getLastLoginTime(), $source->login);
+ $is_blocked = $source->status == 0;
+ $this->assertEqual($user->isBlocked(), $is_blocked);
+ // $user->getPreferredLangcode() might fallback to default language if the
+ // user preferred language is not configured on the site. We just want to
+ // test if the value was imported correctly.
+ $this->assertEqual($user->preferred_langcode->value, $source->language);
+ $time_zone = $source->expected_timezone ?: \Drupal::config('system.date')->get('timezone.default');
+ $this->assertEqual($user->getTimeZone(), $time_zone);
+ $this->assertEqual($user->getInitialEmail(), $source->init);
+ $this->assertEqual($user->getRoles(), $roles);
+
+ // We have one empty picture in the data so don't try load that.
+ if (!empty($source->picture)) {
+ // Test the user picture.
+ $file = file_load($user->user_picture->target_id);
+ $this->assertEqual($file->getFilename(), basename($source->picture));
+ }
+
+ // Use the UI to check if the password has been salted and re-hashed to
+ // conform the Drupal >= 7.
+ $credentials = array('name' => $source->name, 'pass' => $source->pass_plain);
+ $this->drupalPostForm('user/login', $credentials, t('Log in'));
+ $this->assertNoRaw(t('Sorry, unrecognized username or password. Have you forgotten your password?', array('@password' => url('user/password', array('query' => array('name' => $source->name))))));
+ $this->drupalLogout();
+ }
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateViewModesTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateViewModesTest.php
new file mode 100644
index 0000000..81f8279
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateViewModesTest.php
@@ -0,0 +1,62 @@
+ 'Migrate view modes to entity.view_mode.*.*.yml',
+ 'description' => 'Migrate view modes',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp() {
+ parent::setUp();
+ $migration = entity_load('migration', 'd6_view_modes');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6FieldInstance.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests Drupal 6 view modes to Drupal 8 migration.
+ */
+ public function testViewModes() {
+ // Test a new view mode.
+ $view_mode = entity_load('view_mode', 'node.preview');
+ $this->assertEqual(is_null($view_mode), FALSE, 'Preview view mode loaded.');
+ $this->assertEqual($view_mode->label(), 'Preview', 'View mode has correct label.');
+ // Test the Id Map.
+ $this->assertEqual(array('node', 'preview'), entity_load('migration', 'd6_view_modes')->getIdMap()->lookupDestinationID(array(1)));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateVocabularyEntityDisplayTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateVocabularyEntityDisplayTest.php
new file mode 100644
index 0000000..891fb23
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateVocabularyEntityDisplayTest.php
@@ -0,0 +1,92 @@
+ 'Vocabulary entity display migration',
+ 'description' => 'Vocabulary entity display migration',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+
+ entity_create('field_config', array(
+ 'entity_type' => 'node',
+ 'name' => 'tags',
+ 'type' => 'taxonomy_term_reference',
+ ))->save();
+
+ foreach (array('page', 'article', 'story') as $type) {
+ entity_create('node_type', array('type' => $type))->save();
+ entity_create('field_instance_config', array(
+ 'label' => 'Tags',
+ 'description' => '',
+ 'field_name' => 'tags',
+ 'entity_type' => 'node',
+ 'bundle' => $type,
+ 'required' => 1,
+ ))->save();
+ }
+
+ // Add some id mappings for the dependant migrations.
+ $id_mappings = array(
+ 'd6_taxonomy_vocabulary' => array(
+ array(array(4), array('tags')),
+ ),
+ 'd6_vocabulary_field_instance' => array(
+ array(array(4, 'page'), array('node', 'page', 'tags')),
+ )
+ );
+ $this->prepareIdMappings($id_mappings);
+
+ $migration = entity_load('migration', 'd6_vocabulary_entity_display');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6VocabularyField.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
+ */
+ public function testVocabularyEntityDisplay() {
+ // Test that the field exists.
+ $component = entity_get_display('node', 'page', 'default')->getComponent('tags');
+ $this->assertEqual($component['type'], 'taxonomy_term_reference_link');
+ $this->assertEqual($component['weight'], 20);
+ // Test the Id map.
+ $this->assertEqual(array('node', 'article', 'default', 'tags'), entity_load('migration', 'd6_vocabulary_entity_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateVocabularyEntityFormDisplayTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateVocabularyEntityFormDisplayTest.php
new file mode 100644
index 0000000..dcabea4
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateVocabularyEntityFormDisplayTest.php
@@ -0,0 +1,93 @@
+ 'Vocabulary entity form display migration',
+ 'description' => 'Vocabulary entity form display migration',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+
+ entity_create('field_config', array(
+ 'entity_type' => 'node',
+ 'name' => 'tags',
+ 'type' => 'taxonomy_term_reference',
+ ))->save();
+
+ foreach (array('page', 'article', 'story') as $type) {
+ entity_create('node_type', array('type' => $type))->save();
+ entity_create('field_instance_config', array(
+ 'label' => 'Tags',
+ 'description' => '',
+ 'field_name' => 'tags',
+ 'entity_type' => 'node',
+ 'bundle' => $type,
+ 'required' => 1,
+ ))->save();
+ }
+
+ // Add some id mappings for the dependant migrations.
+ $id_mappings = array(
+ 'd6_taxonomy_vocabulary' => array(
+ array(array(4), array('tags')),
+ ),
+ 'd6_vocabulary_field_instance' => array(
+ array(array(4, 'page'), array('node', 'page', 'tags')),
+ )
+ );
+ $this->prepareIdMappings($id_mappings);
+
+ $migration = entity_load('migration', 'd6_vocabulary_entity_form_display');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6VocabularyField.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+
+ }
+
+ /**
+ * Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
+ */
+ public function testVocabularyEntityFormDisplay() {
+ // Test that the field exists.
+ $component = entity_get_form_display('node', 'page', 'default')->getComponent('tags');
+ $this->assertEqual($component['type'], 'options_select');
+ $this->assertEqual($component['weight'], 20);
+ // Test the Id map.
+ $this->assertEqual(array('node', 'article', 'default', 'tags'), entity_load('migration', 'd6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateVocabularyFieldInstanceTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateVocabularyFieldInstanceTest.php
new file mode 100644
index 0000000..74abb07
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateVocabularyFieldInstanceTest.php
@@ -0,0 +1,100 @@
+ 'Vocabulary field instance migration',
+ 'description' => 'Vocabulary field instance migration',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+
+ entity_create('node_type', array('type' => 'page'))->save();
+ entity_create('node_type', array('type' => 'article'))->save();
+ entity_create('node_type', array('type' => 'story'))->save();
+
+ // Add some id mappings for the dependant migrations.
+ $id_mappings = array(
+ 'd6_taxonomy_vocabulary' => array(
+ array(array(4), array('tags')),
+ ),
+ 'd6_vocabulary_field' => array(
+ array(array(4), array('node', 'tags')),
+ )
+ );
+ $this->prepareIdMappings($id_mappings);
+
+ // Create the vocab.
+ entity_create('taxonomy_vocabulary', array(
+ 'name' => 'Test Vocabulary',
+ 'description' => 'Test Vocabulary',
+ 'vid' => 'tags',
+ ))->save();
+ // Create the field itself.
+ entity_create('field_config', array(
+ 'entity_type' => 'node',
+ 'name' => 'tags',
+ 'type' => 'taxonomy_term_reference',
+ ))->save();
+
+ $migration = entity_load('migration', 'd6_vocabulary_field_instance');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6VocabularyField.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
+ */
+ public function testVocabularyFieldInstance() {
+ // Test that the field exists.
+ $field_id = 'node.article.tags';
+ $field = entity_load('field_instance_config', $field_id);
+ $this->assertEqual($field->id(), $field_id, 'Field instance exists on article bundle.');
+ $settings = $field->getSettings();
+ $this->assertEqual('tags', $settings['allowed_values'][0]['vocabulary'], "Vocabulary has correct settings.");
+
+ // Test the page bundle as well.
+ $field_id = 'node.page.tags';
+ $field = entity_load('field_instance_config', $field_id);
+ $this->assertEqual($field->id(), $field_id, 'Field instance exists on page bundle.');
+ $settings = $field->getSettings();
+ $this->assertEqual('tags', $settings['allowed_values'][0]['vocabulary'], "Vocabulary has correct settings.");
+
+ $this->assertEqual(array('node', 'article', 'tags'), entity_load('migration', 'd6_vocabulary_field_instance')->getIdMap()->lookupDestinationID(array(4, 'article')));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateVocabularyFieldTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateVocabularyFieldTest.php
new file mode 100644
index 0000000..7127c77
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateVocabularyFieldTest.php
@@ -0,0 +1,79 @@
+ 'Vocabulary field migration',
+ 'description' => 'Vocabulary field migration',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+
+ // Add some id mappings for the dependant migrations.
+ $id_mappings = array(
+ 'd6_taxonomy_vocabulary' => array(
+ array(array(4), array('tags')),
+ ),
+ );
+ $this->prepareIdMappings($id_mappings);
+
+ entity_create('taxonomy_vocabulary', array(
+ 'name' => 'Test Vocabulary',
+ 'description' => 'Test Vocabulary',
+ 'vid' => 'test_vocab',
+ ))->save();
+
+ $migration = entity_load('migration', 'd6_vocabulary_field');
+ $dumps = array(
+ drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6VocabularyField.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $executable->import();
+ }
+
+ /**
+ * Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
+ */
+ public function testVocabularyField() {
+ // Test that the field exists.
+ $field_id = 'node.tags';
+ $field = entity_load('field_config', $field_id);
+ $this->assertEqual($field->id(), $field_id);
+ $settings = $field->getSettings();
+ $this->assertEqual('tags', $settings['allowed_values'][0]['vocabulary'], "Vocabulary has correct settings.");
+ $this->assertEqual(array('node', 'tags'), entity_load('migration', 'd6_vocabulary_field')->getIdMap()->lookupDestinationID(array(4)), "Test IdMap");
+
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/dependencies/MigrateDependenciesTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/dependencies/MigrateDependenciesTest.php
new file mode 100644
index 0000000..7caf5e1
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/dependencies/MigrateDependenciesTest.php
@@ -0,0 +1,71 @@
+ 'Migrate dependency tests',
+ 'description' => 'Ensure the consistency among the dependencies for migrate',
+ 'group' => 'Migrate Drupal',
+ );
+ }
+
+ /**
+ * Tests that the order is correct when loading several migrations.
+ */
+ public function testMigrateDependenciesOrder() {
+ $migration_items = array('d6_comment', 'd6_filter_format', 'd6_node');
+ $migrations = entity_load_multiple('migration', $migration_items);
+ $expected_order = array('d6_filter_format', 'd6_node', 'd6_comment');
+ $this->assertEqual(array_keys($migrations), $expected_order);
+ $expected_requirements = array('d6_node', 'd6_node_type', 'd6_filter_format', 'd6_user', '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->assertEqual(count($actual_requirements), count($expected_requirements));
+ foreach ($expected_requirements as $requirement) {
+ $this->assertEqual($actual_requirements[$requirement], $requirement);
+ }
+ }
+
+ /**
+ * Tests dependencies on the migration of aggregator feeds & items.
+ */
+ public function testAggregatorMigrateDependencies() {
+ /** @var \Drupal\migrate\entity\Migration $migration */
+ $migration = entity_load('migration', 'd6_aggregator_item');
+ $path = drupal_get_path('module', 'migrate_drupal');
+ $dumps = array(
+ $path . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6AggregatorItem.php',
+ );
+ $this->prepare($migration, $dumps);
+ $executable = new MigrateExecutable($migration, $this);
+ $this->startCollectingMessages();
+ $executable->import();
+ $this->assertEqual($this->migrateMessages['error'], array(String::format('Migration @id did not meet the requirements', array('@id' => $migration->id()))));
+ $this->collectMessages = FALSE;
+ }
+
+}
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/destination/ConfigDestinationTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/destination/ConfigDestinationTest.php
new file mode 100644
index 0000000..971e0e0
--- /dev/null
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/destination/ConfigDestinationTest.php
@@ -0,0 +1,64 @@
+ 'x',
+ );
+ $migration = $this->getMockBuilder('Drupal\migrate\Entity\Migration')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $config = $this->getMockBuilder('Drupal\Core\Config\Config')
+ ->disableOriginalConstructor()
+ ->getMock();
+ foreach ($source as $key => $val) {
+ $config->expects($this->once())
+ ->method('set')
+ ->with($this->equalTo($key), $this->equalTo($val))
+ ->will($this->returnValue($config));
+ }
+ $config->expects($this->once())
+ ->method('save');
+ $row = $this->getMockBuilder('Drupal\migrate\Row')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $row->expects($this->once())
+ ->method('getRawDestination')
+ ->will($this->returnValue($source));
+ $destination = new Config(array(), 'd8_config', array('pluginId' => 'd8_config'), $migration, $config);
+ $destination->import($row);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getInfo() {
+ return array(
+ 'name' => 'Destination test',
+ 'description' => 'Tests for destination plugin.',
+ 'group' => 'Migrate',
+ );
+ }
+
+}