Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / node / tests / src / Kernel / Migrate / d7 / MigrateNodeTest.php
index dc053a8b9e62b5d22812aa763a1c109fcf036bfe..4bbd6ef49c393f5ee724e28a007dfb6c053a62b7 100644 (file)
@@ -31,6 +31,8 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
     'language',
     'link',
     'menu_ui',
+    // Required for translation migrations.
+    'migrate_drupal_multilingual',
     'node',
     'taxonomy',
     'telephone',
@@ -68,9 +70,23 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
       'd7_field_instance',
       'd7_node',
       'd7_node_translation',
+      'd7_entity_translation_settings',
+      'd7_node_entity_translation',
     ]);
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  protected function getFileMigrationInfo() {
+    return [
+      'path' => 'public://sites/default/files/cube.jpeg',
+      'size' => '3620',
+      'base_path' => 'public://',
+      'plugin_id' => 'd7_file',
+    ];
+  }
+
   /**
    * Asserts various aspects of a node.
    *
@@ -139,8 +155,8 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
    * Test node migration from Drupal 7 to 8.
    */
   public function testNode() {
-    $this->assertEntity(1, 'test_content_type', 'en', 'A Node', '2', TRUE, '1421727515', '1441032132', TRUE, FALSE);
-    $this->assertRevision(1, 'A Node', '1', NULL, '1441032132');
+    $this->assertEntity(1, 'test_content_type', 'en', 'An English Node', '2', TRUE, '1421727515', '1441032132', TRUE, FALSE);
+    $this->assertRevision(1, 'An English Node', '1', NULL, '1441032132');
 
     $node = Node::load(1);
     $this->assertTrue($node->field_boolean->value);
@@ -164,6 +180,7 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
     $this->assertEquals('default@example.com', $node->field_email->value);
     $this->assertEquals('another@example.com', $node->field_email[1]->value);
     $this->assertEquals(CommentItemInterface::OPEN, $node->comment_node_test_content_type->status);
+    $this->assertEquals('3.1416', $node->field_float_list[0]->value);
 
     $node = Node::load(2);
     $this->assertEquals('en', $node->langcode->value);
@@ -204,4 +221,42 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
     $this->assertEquals(CommentItemInterface::OPEN, $node->comment_forum->status);
   }
 
+  /**
+   * Test node entity translations migration from Drupal 7 to 8.
+   */
+  public function testNodeEntityTranslations() {
+    $manager = $this->container->get('content_translation.manager');
+
+    // Get the node and its translations.
+    $node = Node::load(1);
+    $node_fr = $node->getTranslation('fr');
+    $node_is = $node->getTranslation('is');
+
+    // Test that fields translated with Entity Translation are migrated.
+    $this->assertSame('An English Node', $node->getTitle());
+    $this->assertSame('A French Node', $node_fr->getTitle());
+    $this->assertSame('An Icelandic Node', $node_is->getTitle());
+    $this->assertSame('5', $node->field_integer->value);
+    $this->assertSame('6', $node_fr->field_integer->value);
+    $this->assertSame('7', $node_is->field_integer->value);
+
+    // Test that the French translation metadata is correctly migrated.
+    $metadata_fr = $manager->getTranslationMetadata($node_fr);
+    $this->assertSame('en', $metadata_fr->getSource());
+    $this->assertTrue($metadata_fr->isOutdated());
+    $this->assertSame('2', $node_fr->getOwnerId());
+    $this->assertSame('1529615802', $node_fr->getCreatedTime());
+    $this->assertSame('1529615802', $node_fr->getChangedTime());
+    $this->assertTrue($node_fr->isPublished());
+
+    // Test that the Icelandic translation metadata is correctly migrated.
+    $metadata_is = $manager->getTranslationMetadata($node_is);
+    $this->assertSame('en', $metadata_is->getSource());
+    $this->assertFalse($metadata_is->isOutdated());
+    $this->assertSame('1', $node_is->getOwnerId());
+    $this->assertSame('1529615813', $node_is->getCreatedTime());
+    $this->assertSame('1529615813', $node_is->getChangedTime());
+    $this->assertFalse($node_is->isPublished());
+  }
+
 }