Commit dfecbdd4 authored by webchick's avatar webchick

Issue #2281553 by benjy, Sutharsan, ultimate: D6->D8 Node Revision migration is incomplete.

parent 2c1fe04e
......@@ -8,13 +8,15 @@ process:
nid: nid
vid: vid
type: type
langcode: language
langcode:
plugin: default_value
source: language
default_value: "und"
title: title
uid: uid
status: status
created: created
changed: changed
revision_timestamp: timestamp
promote: promote
sticky: sticky
'body/format':
......@@ -22,6 +24,10 @@ process:
migration: d6_filter_format
source: format
'body/value': body
'body/summary': teaser
revision_uid: uid
revision_log: log
revision_timestamp: timestamp
# unmapped d6 fields.
# tnid
......
......@@ -8,7 +8,10 @@ process:
nid: nid
vid: vid
type: type
langcode: language
langcode:
plugin: default_value
source: language
default_value: "und"
title: title
uid: uid
status: status
......@@ -21,6 +24,10 @@ process:
migration: d6_filter_format
source: format
'body/value': body
'body/summary': teaser
revision_uid: uid
revision_log: log
revision_timestamp: timestamp
# unmapped d6 fields.
# tnid
......
......@@ -50,8 +50,9 @@ public function query() {
'title',
'body',
'teaser',
'format',
'log',
'timestamp',
'format',
));
$query->innerJoin('node', 'n', static::JOIN);
......@@ -76,7 +77,6 @@ public function fields() {
'promote' => $this->t('Promoted to front page'),
'sticky' => $this->t('Sticky at top of lists'),
'revision' => $this->t('Create new revision'),
'log' => $this->t('Revision Log message'),
'language' => $this->t('Language (fr, en, ...)'),
'tnid' => $this->t('The translation set id for this node'),
'timestamp' => $this->t('The timestamp the latest revision of this node was created.'),
......
......@@ -26,7 +26,11 @@ class NodeRevision extends Node {
*/
public function fields() {
// Use all the node fields plus the vid that identifies the version.
return parent::fields() + array('vid' => t('The primary identifier for this version.'));
return parent::fields() + array(
'vid' => t('The primary identifier for this version.'),
'log' => $this->t('Revision Log message'),
'timestamp' => $this->t('Revision timestamp'),
);
}
/**
......
......@@ -31,10 +31,21 @@ public function load() {
'vid' => 2,
'uid' => 2,
'title' => 'Test title rev 2',
'body' => 'test rev 2',
'teaser' => 'test rev 2',
'log' => '',
'timestamp' => 1390095701,
'body' => 'body test rev 2',
'teaser' => 'teaser test rev 2',
'log' => 'modified rev 2',
'timestamp' => 1390095702,
'format' => 1,
))
->values(array(
'nid' => 1,
'vid' => 4,
'uid' => 1,
'title' => 'Test title rev 3',
'body' => 'body test rev 3',
'teaser' => 'teaser test rev 3',
'log' => 'modified rev 3',
'timestamp' => 1390095703,
'format' => 1,
))
->execute();
......
......@@ -43,9 +43,23 @@ protected function setUp() {
*/
public function testNodeRevision() {
$node = \Drupal::entityManager()->getStorage('node')->loadRevision(2);
/** @var \Drupal\node\NodeInterface $node */
$this->assertEqual($node->id(), 1);
$this->assertEqual($node->getRevisionId(), 2);
$this->assertEqual($node->body->value, 'test rev 2');
$this->assertEqual($node->langcode->value, 'und');
$this->assertEqual($node->getTitle(), 'Test title rev 2');
$this->assertEqual($node->body->value, 'body test rev 2');
$this->assertEqual($node->body->summary, 'teaser test rev 2');
$this->assertEqual($node->getRevisionAuthor()->id(), 1);
$this->assertEqual($node->revision_log->value, 'modified rev 2');
$this->assertEqual($node->getRevisionCreationTime(), '1390095702');
$node = \Drupal::entityManager()->getStorage('node')->loadRevision(4);
$this->assertEqual($node->id(), 1);
$this->assertEqual($node->body->value, 'body test rev 3');
$this->assertEqual($node->getRevisionAuthor()->id(), 1);
$this->assertEqual($node->revision_log->value, 'modified rev 3');
$this->assertEqual($node->getRevisionCreationTime(), '1390095703');
}
}
......@@ -38,7 +38,9 @@ protected function setUp() {
public function testNode() {
$node = node_load(1);
$this->assertEqual($node->id(), 1, 'Node 1 loaded.');
$this->assertEqual($node->langcode->value, 'und');
$this->assertEqual($node->body->value, 'test');
$this->assertEqual($node->body->summary, '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.');
......@@ -47,6 +49,13 @@ public function testNode() {
$this->assertEqual($node->getOwnerId(), 1);
$this->assertEqual($node->getRevisionCreationTime(), 1390095701, 'Node has the correct revision timestamp.');
/** @var \Drupal\node\NodeInterface $node_revision */
$node_revision = \Drupal::entityManager()->getStorage('node')->loadRevision(1);
$this->assertEqual($node_revision->getTitle(), 'Test title');
$this->assertEqual($node_revision->getRevisionAuthor()->id(), 1, 'Node revision has the correct user');
// This is empty on the first revision.
$this->assertEqual($node_revision->revision_log->value, '');
// It is pointless to run the second half from MigrateDrupal6Test.
if (empty($this->standalone)) {
return;
......
......@@ -40,7 +40,6 @@ class NodeTest extends MigrateSqlSourceTestCase {
'title' => 'node title 1',
'uid' => 1,
'status' => 1,
'timestamp' => 1279051598,
'created' => 1279051598,
'changed' => 1279051598,
'comment' => 2,
......@@ -52,6 +51,8 @@ class NodeTest extends MigrateSqlSourceTestCase {
// Node revision fields.
'body' => 'body for node 1',
'teaser' => 'teaser for node 1',
'log' => '',
'timestamp' => 1279051598,
'format' => 1,
),
array(
......@@ -63,7 +64,6 @@ class NodeTest extends MigrateSqlSourceTestCase {
'title' => 'node title 2',
'uid' => 1,
'status' => 1,
'timestamp' => 1279290908,
'created' => 1279290908,
'changed' => 1279308993,
'comment' => 0,
......@@ -75,6 +75,8 @@ class NodeTest extends MigrateSqlSourceTestCase {
// Node revision fields.
'body' => 'body for node 2',
'teaser' => 'teaser for node 2',
'log' => '',
'timestamp' => 1279308993,
'format' => 1,
),
array(
......@@ -86,7 +88,6 @@ class NodeTest extends MigrateSqlSourceTestCase {
'title' => 'node title 5',
'uid' => 1,
'status' => 1,
'timestamp' => 1279290908,
'created' => 1279290908,
'changed' => 1279308993,
'comment' => 0,
......@@ -98,6 +99,8 @@ class NodeTest extends MigrateSqlSourceTestCase {
// Node revision fields.
'body' => 'body for node 5',
'teaser' => 'body for node 5',
'log' => '',
'timestamp' => 1279308993,
'format' => 1,
),
);
......@@ -107,7 +110,7 @@ class NodeTest extends MigrateSqlSourceTestCase {
*/
protected function setUp() {
foreach ($this->expectedResults as $k => $row) {
foreach (array('nid', 'vid', 'title', 'uid', 'body', 'teaser', 'format', 'timestamp') as $i => $field) {
foreach (array('nid', 'vid', 'title', 'uid', 'body', 'teaser', 'log', 'timestamp', 'format') as $i => $field) {
$this->databaseContents['node_revisions'][$k][$field] = $row[$field];
// Keep nid and vid.
if ($i > 1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment