Commit b0a7be53 authored by catch's avatar catch

Issue #2902766 by maxocub, masipila, Jo Fitzgerald: Node 'comment open /...

Issue #2902766 by maxocub, masipila, Jo Fitzgerald: Node 'comment open / closed' status not migrated
parent 6487eda3
......@@ -7284,6 +7284,39 @@
'mysql_character_set' => 'utf8',
));
$connection->insert('field_data_taxonomy_forums')
->fields(array(
'entity_type',
'bundle',
'deleted',
'entity_id',
'revision_id',
'language',
'delta',
'taxonomy_forums_tid',
))
->values(array(
'entity_type' => 'node',
'bundle' => 'forum',
'deleted' => '0',
'entity_id' => '6',
'revision_id' => '6',
'language' => 'und',
'delta' => '0',
'taxonomy_forums_tid' => '1',
))
->values(array(
'entity_type' => 'node',
'bundle' => 'forum',
'deleted' => '0',
'entity_id' => '7',
'revision_id' => '7',
'language' => 'und',
'delta' => '0',
'taxonomy_forums_tid' => '1',
))
->execute();
$connection->schema()->createTable('field_revision_body', array(
'fields' => array(
'entity_type' => array(
......@@ -10475,6 +10508,39 @@
'mysql_character_set' => 'utf8',
));
$connection->insert('field_revision_taxonomy_forums')
->fields(array(
'entity_type',
'bundle',
'deleted',
'entity_id',
'revision_id',
'language',
'delta',
'taxonomy_forums_tid',
))
->values(array(
'entity_type' => 'node',
'bundle' => 'forum',
'deleted' => '0',
'entity_id' => '6',
'revision_id' => '6',
'language' => 'und',
'delta' => '0',
'taxonomy_forums_tid' => '1',
))
->values(array(
'entity_type' => 'node',
'bundle' => 'forum',
'deleted' => '0',
'entity_id' => '7',
'revision_id' => '7',
'language' => 'und',
'delta' => '0',
'taxonomy_forums_tid' => '1',
))
->execute();
$connection->schema()->createTable('file_managed', array(
'fields' => array(
'fid' => array(
......@@ -11075,6 +11141,24 @@
'mysql_character_set' => 'utf8',
));
$connection->insert('forum')
->fields(array(
'nid',
'vid',
'tid',
))
->values(array(
'nid' => '6',
'vid' => '6',
'tid' => '1',
))
->values(array(
'nid' => '7',
'vid' => '7',
'tid' => '1',
))
->execute();
$connection->schema()->createTable('forum_index', array(
'fields' => array(
'nid' => array(
......@@ -11127,6 +11211,36 @@
'mysql_character_set' => 'utf8',
));
$connection->insert('forum_index')
->fields(array(
'nid',
'title',
'tid',
'sticky',
'created',
'last_comment_timestamp',
'comment_count',
))
->values(array(
'nid' => '6',
'title' => 'Comments are closed :-(',
'tid' => '1',
'sticky' => '0',
'created' => '1504715414',
'last_comment_timestamp' => '1504715414',
'comment_count' => '0',
))
->values(array(
'nid' => '7',
'title' => 'Comments are open :-)',
'tid' => '1',
'sticky' => '0',
'created' => '1504715432',
'last_comment_timestamp' => '1504715432',
'comment_count' => '0',
))
->execute();
$connection->schema()->createTable('history', array(
'fields' => array(
'uid' => array(
......@@ -33197,7 +33311,7 @@
'status' => '1',
'created' => '1478755274',
'changed' => '1478755274',
'comment' => '2',
'comment' => '1',
'promote' => '1',
'sticky' => '0',
'tnid' => '4',
......@@ -33213,12 +33327,44 @@
'status' => '1',
'created' => '1478755314',
'changed' => '1478755314',
'comment' => '2',
'comment' => '1',
'promote' => '1',
'sticky' => '0',
'tnid' => '4',
'translate' => '0',
))
->values(array(
'nid' => '6',
'vid' => '6',
'type' => 'forum',
'language' => 'en',
'title' => 'Comments are closed :-(',
'uid' => '1',
'status' => '1',
'created' => '1504715414',
'changed' => '1504715414',
'comment' => '1',
'promote' => '0',
'sticky' => '0',
'tnid' => '0',
'translate' => '0',
))
->values(array(
'nid' => '7',
'vid' => '7',
'type' => 'forum',
'language' => 'en',
'title' => 'Comments are open :-)',
'uid' => '1',
'status' => '1',
'created' => '1504715432',
'changed' => '1504715432',
'comment' => '2',
'promote' => '0',
'sticky' => '0',
'tnid' => '0',
'translate' => '0',
))
->execute();
$connection->schema()->createTable('node_access', array(
......@@ -33379,6 +33525,22 @@
'last_comment_uid' => '1',
'comment_count' => '0',
))
->values(array(
'nid' => '6',
'cid' => '0',
'last_comment_timestamp' => '1504715414',
'last_comment_name' => NULL,
'last_comment_uid' => '1',
'comment_count' => '0',
))
->values(array(
'nid' => '7',
'cid' => '0',
'last_comment_timestamp' => '1504715432',
'last_comment_name' => NULL,
'last_comment_uid' => '1',
'comment_count' => '0',
))
->execute();
$connection->schema()->createTable('node_counter', array(
......@@ -33454,6 +33616,18 @@
'daycount' => '1',
'timestamp' => '1478755314',
))
->values(array(
'nid' => '6',
'totalcount' => '2',
'daycount' => '2',
'timestamp' => '1504715439',
))
->values(array(
'nid' => '7',
'totalcount' => '2',
'daycount' => '2',
'timestamp' => '1504715438',
))
->execute();
$connection->schema()->createTable('node_revision', array(
......@@ -33582,7 +33756,7 @@
'log' => '',
'timestamp' => '1478755274',
'status' => '1',
'comment' => '2',
'comment' => '1',
'promote' => '1',
'sticky' => '0',
))
......@@ -33594,10 +33768,34 @@
'log' => '',
'timestamp' => '1478755314',
'status' => '1',
'comment' => '2',
'comment' => '1',
'promote' => '1',
'sticky' => '0',
))
->values(array(
'nid' => '6',
'vid' => '6',
'uid' => '1',
'title' => 'Comments are closed :-(',
'log' => '',
'timestamp' => '1504715414',
'status' => '1',
'comment' => '1',
'promote' => '0',
'sticky' => '0',
))
->values(array(
'nid' => '7',
'vid' => '7',
'uid' => '1',
'title' => 'Comments are open :-)',
'log' => '',
'timestamp' => '1504715432',
'status' => '1',
'comment' => '2',
'promote' => '0',
'sticky' => '0',
))
->execute();
$connection->schema()->createTable('node_type', array(
......@@ -44779,6 +44977,18 @@
'sticky' => '0',
'created' => '1421727515',
))
->values(array(
'nid' => '6',
'tid' => '1',
'sticky' => '0',
'created' => '1504715414',
))
->values(array(
'nid' => '7',
'tid' => '1',
'sticky' => '0',
'created' => '1504715432',
))
->execute();
$connection->schema()->createTable('taxonomy_term_data', array(
......@@ -57,7 +57,7 @@ protected function getEntityCounts() {
'image_style' => 6,
'language_content_settings' => 2,
'migration' => 73,
'node' => 3,
'node' => 5,
'node_type' => 6,
'rdf_mapping' => 7,
'search_page' => 2,
......
......@@ -35,3 +35,4 @@ migration_dependencies:
- d7_node_type
optional:
- d7_field_instance
- d7_comment_field_instance
......@@ -141,6 +141,16 @@ public function getDerivativeDefinitions($base_plugin_definition) {
$values['source']['node_type'] = $node_type;
$values['destination']['default_bundle'] = $node_type;
// Comment status must be mapped to correct comment type.
// Comment type migration creates a separate comment type for each
// node type except for Forum which uses 'comment_forum'.
$comment_type = 'comment_node_' . $node_type;
if ($node_type == 'forum') {
$comment_type = 'comment_forum';
}
$nested_key = $comment_type . '/0/status';
$values['process'][$nested_key] = 'comment';
// If this migration is based on the d7_node_revision migration or
// is for translations of nodes, it should explicitly depend on the
// corresponding d7_node variant.
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\node\Kernel\Migrate\d7;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Tests\file\Kernel\Migrate\d7\FileMigrationSetupTrait;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\node\Entity\Node;
......@@ -25,6 +26,7 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
'datetime',
'file',
'filter',
'forum',
'image',
'language',
'link',
......@@ -47,6 +49,8 @@ protected function setUp() {
$this->installEntitySchema('comment');
$this->installEntitySchema('taxonomy_term');
$this->installConfig(static::$modules);
$this->installSchema('comment', ['comment_entity_statistics']);
$this->installSchema('forum', ['forum', 'forum_index']);
$this->installSchema('node', ['node_access']);
$this->installSchema('system', ['sequences']);
......@@ -57,6 +61,8 @@ protected function setUp() {
'd7_node_type',
'd7_language_content_settings',
'd7_comment_type',
'd7_comment_field',
'd7_comment_field_instance',
'd7_taxonomy_vocabulary',
'd7_field',
'd7_field_instance',
......@@ -92,18 +98,18 @@ protected function setUp() {
protected function assertEntity($id, $type, $langcode, $title, $uid, $status, $created, $changed, $promoted, $sticky) {
/** @var \Drupal\node\NodeInterface $node */
$node = Node::load($id);
$this->assertTrue($node instanceof NodeInterface);
$this->assertIdentical($type, $node->getType());
$this->assertIdentical($langcode, $node->langcode->value);
$this->assertIdentical($title, $node->getTitle());
$this->assertIdentical($uid, $node->getOwnerId());
$this->assertIdentical($status, $node->isPublished());
$this->assertIdentical($created, $node->getCreatedTime());
$this->assertInstanceOf(NodeInterface::class, $node);
$this->assertEquals($type, $node->getType());
$this->assertEquals($langcode, $node->langcode->value);
$this->assertEquals($title, $node->getTitle());
$this->assertEquals($uid, $node->getOwnerId());
$this->assertEquals($status, $node->isPublished());
$this->assertEquals($created, $node->getCreatedTime());
if (isset($changed)) {
$this->assertIdentical($changed, $node->getChangedTime());
$this->assertEquals($changed, $node->getChangedTime());
}
$this->assertIdentical($promoted, $node->isPromoted());
$this->assertIdentical($sticky, $node->isSticky());
$this->assertEquals($promoted, $node->isPromoted());
$this->assertEquals($sticky, $node->isSticky());
}
/**
......@@ -122,11 +128,11 @@ protected function assertEntity($id, $type, $langcode, $title, $uid, $status, $c
*/
protected function assertRevision($id, $title, $uid, $log, $timestamp) {
$revision = \Drupal::entityManager()->getStorage('node')->loadRevision($id);
$this->assertTrue($revision instanceof NodeInterface);
$this->assertIdentical($title, $revision->getTitle());
$this->assertIdentical($uid, $revision->getRevisionUser()->id());
$this->assertIdentical($log, $revision->revision_log->value);
$this->assertIdentical($timestamp, $revision->getRevisionCreationTime());
$this->assertInstanceOf(NodeInterface::class, $revision);
$this->assertEquals($title, $revision->getTitle());
$this->assertEquals($uid, $revision->getRevisionUser()->id());
$this->assertEquals($log, $revision->revision_log->value);
$this->assertEquals($timestamp, $revision->getRevisionCreationTime());
}
/**
......@@ -138,53 +144,64 @@ public function testNode() {
$node = Node::load(1);
$this->assertTrue($node->field_boolean->value);
$this->assertIdentical('99-99-99-99', $node->field_phone->value);
// Use assertEqual() here instead, since SQLite interprets floats strictly.
$this->assertEqual('1', $node->field_float->value);
$this->assertIdentical('5', $node->field_integer->value);
$this->assertIdentical('Some more text', $node->field_text_list[0]->value);
$this->assertIdentical('7', $node->field_integer_list[0]->value);
$this->assertIdentical('qwerty', $node->field_text->value);
$this->assertIdentical('2', $node->field_file->target_id);
$this->assertIdentical('file desc', $node->field_file->description);
$this->assertEquals('99-99-99-99', $node->field_phone->value);
$this->assertEquals('1', $node->field_float->value);
$this->assertEquals('5', $node->field_integer->value);
$this->assertEquals('Some more text', $node->field_text_list[0]->value);
$this->assertEquals('7', $node->field_integer_list[0]->value);
$this->assertEquals('qwerty', $node->field_text->value);
$this->assertEquals('2', $node->field_file->target_id);
$this->assertEquals('file desc', $node->field_file->description);
$this->assertTrue($node->field_file->display);
$this->assertIdentical('1', $node->field_images->target_id);
$this->assertIdentical('alt text', $node->field_images->alt);
$this->assertIdentical('title text', $node->field_images->title);
$this->assertIdentical('93', $node->field_images->width);
$this->assertIdentical('93', $node->field_images->height);
$this->assertIdentical('http://google.com', $node->field_link->uri);
$this->assertIdentical('Click Here', $node->field_link->title);
$this->assertEquals('1', $node->field_images->target_id);
$this->assertEquals('alt text', $node->field_images->alt);
$this->assertEquals('title text', $node->field_images->title);
$this->assertEquals('93', $node->field_images->width);
$this->assertEquals('93', $node->field_images->height);
$this->assertEquals('http://google.com', $node->field_link->uri);
$this->assertEquals('Click Here', $node->field_link->title);
// Test that an email field is migrated.
$this->assertSame('default@example.com', $node->field_email->value);
$this->assertSame('another@example.com', $node->field_email[1]->value);
$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);
$node = Node::load(2);
$this->assertSame('en', $node->langcode->value);
$this->assertIdentical("...is that it's the absolute best show ever. Trust me, I would know.", $node->body->value);
$this->assertSame('The thing about Deep Space 9', $node->label());
$this->assertIdentical('internal:/', $node->field_link->uri);
$this->assertIdentical('Home', $node->field_link->title);
$this->assertEquals('en', $node->langcode->value);
$this->assertEquals("...is that it's the absolute best show ever. Trust me, I would know.", $node->body->value);
$this->assertEquals('The thing about Deep Space 9', $node->label());
$this->assertEquals('internal:/', $node->field_link->uri);
$this->assertEquals('Home', $node->field_link->title);
$this->assertEquals(CommentItemInterface::OPEN, $node->comment_node_article->status);
$this->assertTrue($node->hasTranslation('is'), "Node 2 has an Icelandic translation");
$translation = $node->getTranslation('is');
$this->assertSame('is', $translation->langcode->value);
$this->assertSame("is - ...is that it's the absolute best show ever. Trust me, I would know.", $translation->body->value);
$this->assertSame('is - The thing about Deep Space 9', $translation->label());
$this->assertSame('internal:/', $translation->field_link->uri);
$this->assertSame('Home', $translation->field_link->title);
$this->assertEquals('is', $translation->langcode->value);
$this->assertEquals("is - ...is that it's the absolute best show ever. Trust me, I would know.", $translation->body->value);
$this->assertEquals('is - The thing about Deep Space 9', $translation->label());
$this->assertEquals('internal:/', $translation->field_link->uri);
$this->assertEquals(CommentItemInterface::OPEN, $translation->comment_node_article->status);
$this->assertEquals('Home', $translation->field_link->title);
// Test that content_translation_source is set.
$manager = $this->container->get('content_translation.manager');
$this->assertSame('en', $manager->getTranslationMetadata($node->getTranslation('is'))->getSource());
$this->assertEquals('en', $manager->getTranslationMetadata($node->getTranslation('is'))->getSource());
// Node 3 is a translation of node 2, and should not be imported separately.
$this->assertNull(Node::load(3), "Node 3 doesn't exist in D8, it was a translation");
// Test that content_translation_source for a source other than English.
$node = Node::load(4);
$this->assertSame('is', $manager->getTranslationMetadata($node->getTranslation('en'))->getSource());
$this->assertEquals('is', $manager->getTranslationMetadata($node->getTranslation('en'))->getSource());
$this->assertEquals(CommentItemInterface::CLOSED, $node->comment_node_article->status);
$translation = $node->getTranslation('en');
$this->assertEquals(CommentItemInterface::CLOSED, $translation->comment_node_article->status);
$node = Node::load(6);
$this->assertEquals(CommentItemInterface::CLOSED, $node->comment_forum->status);
$node = Node::load(7);
$this->assertEquals(CommentItemInterface::OPEN, $node->comment_forum->status);
}
}
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