You are here

public function MigrateNodeTest::testNode in Zircon Profile 8.0

Same name in this branch
  1. 8.0 core/modules/node/src/Tests/Migrate/d6/MigrateNodeTest.php \Drupal\node\Tests\Migrate\d6\MigrateNodeTest::testNode()
  2. 8.0 core/modules/node/src/Tests/Migrate/d7/MigrateNodeTest.php \Drupal\node\Tests\Migrate\d7\MigrateNodeTest::testNode()
Same name and namespace in other branches
  1. 8 core/modules/node/src/Tests/Migrate/d6/MigrateNodeTest.php \Drupal\node\Tests\Migrate\d6\MigrateNodeTest::testNode()

Test node migration from Drupal 6 to 8.

File

core/modules/node/src/Tests/Migrate/d6/MigrateNodeTest.php, line 35
Contains \Drupal\node\Tests\Migrate\d6\MigrateNodeTest.

Class

MigrateNodeTest
Node content migration.

Namespace

Drupal\node\Tests\Migrate\d6

Code

public function testNode() {
  $node = Node::load(1);
  $this
    ->assertIdentical('1', $node
    ->id(), 'Node 1 loaded.');
  $this
    ->assertIdentical('und', $node->langcode->value);
  $this
    ->assertIdentical('test', $node->body->value);
  $this
    ->assertIdentical('test', $node->body->summary);
  $this
    ->assertIdentical('filtered_html', $node->body->format);
  $this
    ->assertIdentical('story', $node
    ->getType(), 'Node has the correct bundle.');
  $this
    ->assertIdentical('Test title', $node
    ->getTitle(), 'Node has the correct title.');
  $this
    ->assertIdentical('1388271197', $node
    ->getCreatedTime(), 'Node has the correct created time.');
  $this
    ->assertIdentical(FALSE, $node
    ->isSticky());
  $this
    ->assertIdentical('1', $node
    ->getOwnerId());
  $this
    ->assertIdentical('1420861423', $node
    ->getRevisionCreationTime());

  /** @var \Drupal\node\NodeInterface $node_revision */
  $node_revision = \Drupal::entityManager()
    ->getStorage('node')
    ->loadRevision(1);
  $this
    ->assertIdentical('Test title', $node_revision
    ->getTitle());
  $this
    ->assertIdentical('1', $node_revision
    ->getRevisionAuthor()
    ->id(), 'Node revision has the correct user');

  // This is empty on the first revision.
  $this
    ->assertIdentical(NULL, $node_revision->revision_log->value);

  // 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();
  $migration = Migration::load('d6_node__story');
  $this
    ->executeMigration($migration);
  $node = Node::load(1);
  $this
    ->assertIdentical('New node title', $node
    ->getTitle());

  // Test a multi-column fields are correctly upgraded.
  $this
    ->assertIdentical('test', $node->body->value);
  $this
    ->assertIdentical('full_html', $node->body->format);
}