diff --git a/core/modules/comment/migration_templates/d6_comment.yml b/core/modules/comment/migration_templates/d6_comment.yml
index 06820d4..161820e 100644
--- a/core/modules/comment/migration_templates/d6_comment.yml
+++ b/core/modules/comment/migration_templates/d6_comment.yml
@@ -16,10 +16,15 @@ process:
source: pid
entity_id: nid
entity_type: 'constants/entity_type'
- # field_name & comment_type is calculated in
- # \Drupal\migrate_drupal\Plugin\migrate\source\d6\Comment::prepareRow()
- field_name: field_name
- comment_type: comment_type
+ comment_type:
+ -
+ plugin: migration_lookup
+ source: type
+ migration: d6_comment_type
+ -
+ plugin: skip_on_empty
+ method: row
+ field_name: '@comment_type'
subject: subject
uid: uid
name: name
diff --git a/core/modules/comment/migration_templates/d6_comment_entity_display.yml b/core/modules/comment/migration_templates/d6_comment_entity_display.yml
index c650673..89e159c 100644
--- a/core/modules/comment/migration_templates/d6_comment_entity_display.yml
+++ b/core/modules/comment/migration_templates/d6_comment_entity_display.yml
@@ -3,10 +3,9 @@ label: Comment display configuration
migration_tags:
- Drupal 6
source:
- plugin: d6_comment_variable
+ plugin: d6_node_type
constants:
entity_type: node
- field_name: comment
view_mode: default
options:
label: hidden
@@ -14,10 +13,17 @@ source:
weight: 20
process:
entity_type: 'constants/entity_type'
- field_name: 'constants/field_name'
+ field_name:
+ -
+ plugin: migration_lookup
+ source: type
+ migration: d6_comment_type
+ -
+ plugin: skip_on_empty
+ method: row
view_mode: 'constants/view_mode'
options: 'constants/options'
- bundle: node_type
+ bundle: type
destination:
plugin: component_entity_display
migration_dependencies:
diff --git a/core/modules/comment/migration_templates/d6_comment_entity_form_display.yml b/core/modules/comment/migration_templates/d6_comment_entity_form_display.yml
index c33685f..274f3de 100644
--- a/core/modules/comment/migration_templates/d6_comment_entity_form_display.yml
+++ b/core/modules/comment/migration_templates/d6_comment_entity_form_display.yml
@@ -3,20 +3,26 @@ label: Comment field form display configuration
migration_tags:
- Drupal 6
source:
- plugin: d6_comment_variable
+ plugin: d6_node_type
constants:
entity_type: node
- field_name: comment
form_mode: default
options:
type: comment_default
weight: 20
process:
entity_type: 'constants/entity_type'
- field_name: 'constants/field_name'
+ field_name:
+ -
+ plugin: migration_lookup
+ source: type
+ migration: d6_comment_type
+ -
+ plugin: skip_on_empty
+ method: row
form_mode: 'constants/form_mode'
options: 'constants/options'
- bundle: node_type
+ bundle: type
destination:
plugin: component_entity_form_display
migration_dependencies:
diff --git a/core/modules/comment/migration_templates/d6_comment_entity_form_display_subject.yml b/core/modules/comment/migration_templates/d6_comment_entity_form_display_subject.yml
index abe6191..8a68f31 100644
--- a/core/modules/comment/migration_templates/d6_comment_entity_form_display_subject.yml
+++ b/core/modules/comment/migration_templates/d6_comment_entity_form_display_subject.yml
@@ -3,7 +3,7 @@ label: Comment subject form display configuration
migration_tags:
- Drupal 6
source:
- plugin: d6_comment_variable_per_comment_type
+ plugin: d6_node_type
constants:
entity_type: comment
field_name: subject
@@ -16,14 +16,23 @@ process:
field_name: 'constants/field_name'
form_mode: 'constants/form_mode'
options: 'constants/options'
+ bundle:
+ -
+ plugin: migration_lookup
+ source: type
+ migration: d6_comment_type
+ -
+ plugin: skip_on_empty
+ method: row
hidden:
plugin: static_map
- source: comment_type
- default_value: false
+ source: comment_subject_field
map:
- comment_no_subject: true # Hide subject field
- comment: false
- bundle: comment_type
+ # If comment_subject_field = FALSE, then hidden = TRUE.
+ 0: true
+ # If comment_subject_field = TRUE, then hidden = FALSE.
+ 1: false
+ default_value: false
destination:
plugin: component_entity_form_display
migration_dependencies:
diff --git a/core/modules/comment/migration_templates/d6_comment_field.yml b/core/modules/comment/migration_templates/d6_comment_field.yml
index d14d1aa..5cbf5d4 100644
--- a/core/modules/comment/migration_templates/d6_comment_field.yml
+++ b/core/modules/comment/migration_templates/d6_comment_field.yml
@@ -3,20 +3,24 @@ label: Comment field configuration
migration_tags:
- Drupal 6
source:
- plugin: d6_comment_variable_per_comment_type
+ plugin: d6_node_type
constants:
entity_type: node
type: comment
process:
entity_type: 'constants/entity_type'
- field_name: comment_type
+ field_name:
+ -
+ plugin: migration_lookup
+ source: type
+ migration: d6_comment_type
+ -
+ plugin: skip_on_empty
+ method: row
type: 'constants/type'
- 'settings/comment_type': comment_type
+ 'settings/comment_type': '@field_name'
destination:
plugin: entity:field_storage_config
- dependencies:
- module:
- - comment
migration_dependencies:
required:
- d6_comment_type
diff --git a/core/modules/comment/migration_templates/d6_comment_field_instance.yml b/core/modules/comment/migration_templates/d6_comment_field_instance.yml
index d708619..741ccf2 100644
--- a/core/modules/comment/migration_templates/d6_comment_field_instance.yml
+++ b/core/modules/comment/migration_templates/d6_comment_field_instance.yml
@@ -3,7 +3,7 @@ label: Comment field instance configuration
migration_tags:
- Drupal 6
source:
- plugin: d6_comment_variable
+ plugin: d6_node_type
constants:
entity_type: node
label: Comments
@@ -13,13 +13,24 @@ process:
label: 'constants/label'
required: 'constants/required'
field_name:
+ -
+ plugin: migration_lookup
+ source: type
+ migration: d6_comment_type
+ -
+ plugin: skip_on_empty
+ method: row
+ bundle: type
+ 'default_value/0/status':
+ # We're using static_map instead of default_value otherwise if the source
+ # is 0, the default value of 1 would be used.
plugin: static_map
- source: comment_subject_field
- default_value: comment
+ source: comment
map:
- 0: comment_no_subject
- bundle: node_type
- 'default_value/0/status': comment
+ 0: 0
+ 1: 1
+ 2: 2
+ default_value: 2
'settings/default_mode':
plugin: static_map
source: comment_default_mode
@@ -32,13 +43,31 @@ process:
3: 1
# COMMENT_MODE_THREADED_EXPANDED --> COMMENT_MODE_THREADED
4: 1
- 'settings/per_page': comment_default_per_page
- 'settings/anonymous': comment_anonymous
- 'settings/form_location': comment_form_location
- 'settings/preview': comment_preview
+ default_value: 1
+ 'settings/per_page':
+ plugin: default_value
+ source: comment_default_per_page
+ default_value: 50
+ 'settings/anonymous':
+ plugin: default_value
+ source: comment_anonymous
+ default_value: 0
+ 'settings/form_location':
+ plugin: default_value
+ source: comment_form_location
+ default_value: 0
+ 'settings/preview':
+ # We're using static_map instead of default_value otherwise if the source
+ # is 0, the default value of 1 would be used.
+ plugin: static_map
+ source: comment_preview
+ map:
+ 0: 0
+ 1: 1
+ default_value: 1
destination:
plugin: entity:field_config
migration_dependencies:
required:
- - d6_comment_field
- d6_node_type
+ - d6_comment_field
diff --git a/core/modules/comment/migration_templates/d6_comment_type.yml b/core/modules/comment/migration_templates/d6_comment_type.yml
index 69a2bd8..b86ae24 100644
--- a/core/modules/comment/migration_templates/d6_comment_type.yml
+++ b/core/modules/comment/migration_templates/d6_comment_type.yml
@@ -3,13 +3,31 @@ label: Comment type
migration_tags:
- Drupal 6
source:
- plugin: d6_comment_variable_per_comment_type
+ plugin: d6_node_type
constants:
entity_type: node
+ id_prefix: 'comment_node_'
+ label_suffix: 'comment'
process:
target_entity_type_id: 'constants/entity_type'
- id: comment_type
- label: label
- description: description
+ id:
+ -
+ plugin: concat
+ source:
+ - 'constants/id_prefix'
+ - type
+ -
+ plugin: static_map
+ bypass: true
+ # The Forum module provides its own comment type (comment_forum), which we
+ # want to reuse if it exists.
+ map:
+ comment_node_forum: comment_forum
+ label:
+ plugin: concat
+ source:
+ - name
+ - 'constants/label_suffix'
+ delimiter: ' '
destination:
plugin: entity:comment_type
diff --git a/core/modules/comment/migration_templates/d7_comment.yml b/core/modules/comment/migration_templates/d7_comment.yml
index 5e609a6..dff4b64 100644
--- a/core/modules/comment/migration_templates/d7_comment.yml
+++ b/core/modules/comment/migration_templates/d7_comment.yml
@@ -19,7 +19,7 @@ process:
comment_type:
-
plugin: migration_lookup
- source: comment_type
+ source: node_type
migration: d7_comment_type
-
plugin: skip_on_empty
diff --git a/core/modules/comment/migration_templates/d7_comment_entity_display.yml b/core/modules/comment/migration_templates/d7_comment_entity_display.yml
index 3ae948e..b206552 100644
--- a/core/modules/comment/migration_templates/d7_comment_entity_display.yml
+++ b/core/modules/comment/migration_templates/d7_comment_entity_display.yml
@@ -3,7 +3,7 @@ label: Comment display configuration
migration_tags:
- Drupal 7
source:
- plugin: d7_comment_type
+ plugin: d7_node_type
constants:
entity_type: node
view_mode: default
@@ -16,14 +16,14 @@ process:
field_name:
-
plugin: migration_lookup
- source: bundle
+ source: type
migration: d7_comment_type
-
plugin: skip_on_empty
method: row
view_mode: 'constants/view_mode'
options: 'constants/options'
- bundle: node_type
+ bundle: type
destination:
plugin: component_entity_display
migration_dependencies:
diff --git a/core/modules/comment/migration_templates/d7_comment_entity_form_display.yml b/core/modules/comment/migration_templates/d7_comment_entity_form_display.yml
index 0315c4a..48bb7bc 100644
--- a/core/modules/comment/migration_templates/d7_comment_entity_form_display.yml
+++ b/core/modules/comment/migration_templates/d7_comment_entity_form_display.yml
@@ -3,20 +3,26 @@ label: Comment field form display configuration
migration_tags:
- Drupal 7
source:
- plugin: d7_comment_type
+ plugin: d7_node_type
constants:
entity_type: node
- field_name: comment
form_mode: default
options:
type: comment_default
weight: 20
process:
entity_type: 'constants/entity_type'
- field_name: 'constants/field_name'
+ field_name:
+ -
+ plugin: migration_lookup
+ source: type
+ migration: d7_comment_type
+ -
+ plugin: skip_on_empty
+ method: row
form_mode: 'constants/form_mode'
options: 'constants/options'
- bundle: node_type
+ bundle: type
destination:
plugin: component_entity_form_display
migration_dependencies:
diff --git a/core/modules/comment/migration_templates/d7_comment_entity_form_display_subject.yml b/core/modules/comment/migration_templates/d7_comment_entity_form_display_subject.yml
index 46f231d..b131c0a 100644
--- a/core/modules/comment/migration_templates/d7_comment_entity_form_display_subject.yml
+++ b/core/modules/comment/migration_templates/d7_comment_entity_form_display_subject.yml
@@ -3,7 +3,7 @@ label: Comment subject form display configuration
migration_tags:
- Drupal 7
source:
- plugin: d7_comment_type
+ plugin: d7_node_type
constants:
entity_type: comment
field_name: subject
@@ -16,20 +16,23 @@ process:
field_name: 'constants/field_name'
form_mode: 'constants/form_mode'
options: 'constants/options'
- hidden:
- plugin: static_map
- source: subject
- map:
- 0: true
- 1: false
bundle:
-
plugin: migration_lookup
- source: bundle
+ source: type
migration: d7_comment_type
-
plugin: skip_on_empty
method: row
+ hidden:
+ plugin: static_map
+ source: comment_subject_field
+ map:
+ # If comment_subject_field = FALSE, then hidden = TRUE.
+ 0: true
+ # If comment_subject_field = TRUE, then hidden = FALSE.
+ 1: false
+ default_value: false
destination:
plugin: component_entity_form_display
migration_dependencies:
diff --git a/core/modules/comment/migration_templates/d7_comment_field.yml b/core/modules/comment/migration_templates/d7_comment_field.yml
index 95a4602..cd7337c 100644
--- a/core/modules/comment/migration_templates/d7_comment_field.yml
+++ b/core/modules/comment/migration_templates/d7_comment_field.yml
@@ -3,7 +3,7 @@ label: Comment field configuration
migration_tags:
- Drupal 7
source:
- plugin: d7_comment_type
+ plugin: d7_node_type
constants:
entity_type: node
type: comment
@@ -12,7 +12,7 @@ process:
field_name:
-
plugin: migration_lookup
- source: bundle
+ source: type
migration: d7_comment_type
-
plugin: skip_on_empty
diff --git a/core/modules/comment/migration_templates/d7_comment_field_instance.yml b/core/modules/comment/migration_templates/d7_comment_field_instance.yml
index 147efcf..89b39b9 100644
--- a/core/modules/comment/migration_templates/d7_comment_field_instance.yml
+++ b/core/modules/comment/migration_templates/d7_comment_field_instance.yml
@@ -3,7 +3,7 @@ label: Comment field instance configuration
migration_tags:
- Drupal 7
source:
- plugin: d7_comment_type
+ plugin: d7_node_type
constants:
entity_type: node
label: Comments
@@ -15,20 +15,56 @@ process:
field_name:
-
plugin: migration_lookup
- source: bundle
+ source: type
migration: d7_comment_type
-
plugin: skip_on_empty
method: row
- bundle: node_type
- 'default_value/0/status': 'constants/required'
- 'settings/default_mode': default_mode
- 'settings/per_page': per_page
- 'settings/anonymous': anonymous
- 'settings/form_location': form_location
- 'settings/preview': preview
+ bundle: type
+ 'default_value/0/status':
+ # We're using static_map instead of default_value otherwise if the source
+ # is 0, the default value of 1 would be used.
+ plugin: static_map
+ source: comment
+ map:
+ 0: 0
+ 1: 1
+ 2: 2
+ default_value: 2
+ 'settings/default_mode':
+ # We're using static_map instead of default_value otherwise if the source
+ # is 0, the default value of 1 would be used.
+ plugin: static_map
+ source: comment_default_mode
+ map:
+ 0: 0
+ 1: 1
+ default_value: 1
+ 'settings/per_page':
+ plugin: default_value
+ source: comment_default_per_page
+ default_value: 50
+ 'settings/anonymous':
+ plugin: default_value
+ source: comment_anonymous
+ default_value: 0
+ 'settings/form_location':
+ plugin: default_value
+ source: comment_form_location
+ default_value: 0
+ 'settings/preview':
+ # We're using static_map instead of default_value otherwise if the source
+ # is 0, the default value of 1 would be used.
+ plugin: static_map
+ source: comment_preview
+ map:
+ 0: 0
+ 1: 1
+ 2: 2
+ default_value: 1
destination:
plugin: entity:field_config
migration_dependencies:
required:
+ - d7_node_type
- d7_comment_field
diff --git a/core/modules/comment/migration_templates/d7_comment_type.yml b/core/modules/comment/migration_templates/d7_comment_type.yml
index f94a59d..d54ca09 100644
--- a/core/modules/comment/migration_templates/d7_comment_type.yml
+++ b/core/modules/comment/migration_templates/d7_comment_type.yml
@@ -3,22 +3,31 @@ label: Comment type
migration_tags:
- Drupal 7
source:
- plugin: d7_comment_type
+ plugin: d7_node_type
constants:
entity_type: node
+ id_prefix: 'comment_node_'
+ label_suffix: 'comment'
process:
target_entity_type_id: 'constants/entity_type'
id:
- plugin: static_map
- source: bundle
- bypass: true
- # The Forum module provides its own comment type (comment_forum), which we
- # want to reuse if it exists.
- map:
- comment_node_forum: comment_forum
- label: label
+ -
+ plugin: concat
+ source:
+ - 'constants/id_prefix'
+ - type
+ -
+ plugin: static_map
+ bypass: true
+ # The Forum module provides its own comment type (comment_forum), which we
+ # want to reuse if it exists.
+ map:
+ comment_node_forum: comment_forum
+ label:
+ plugin: concat
+ source:
+ - name
+ - 'constants/label_suffix'
+ delimiter: ' '
destination:
plugin: entity:comment_type
-migration_dependencies:
- required:
- - d7_node_type
diff --git a/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php b/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php
index 50a14c1..b2511c5 100644
--- a/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php
+++ b/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php
@@ -34,6 +34,20 @@ public function query() {
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
+ return parent::prepareRow($this->prepareComment($row));
+ }
+
+ /**
+ * This is a backward compatibility layer for the deprecated migrate source
+ * plugins d6_comment_variable and d6_comment_variable_per_comment_type.
+ *
+ * @param \Drupal\migrate\Row $row
+ * The row from the source to process.
+ * @return \Drupal\migrate\Row
+ * The row object.
+ * @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x.
+ */
+ protected function prepareComment(Row $row) {
if ($this->variableGet('comment_subject_field_' . $row->getSourceProperty('type'), 1)) {
// Comment subject visible.
$row->setSourceProperty('field_name', 'comment');
@@ -43,10 +57,11 @@ public function prepareRow(Row $row) {
$row->setSourceProperty('field_name', 'comment_no_subject');
$row->setSourceProperty('comment_type', 'comment_no_subject');
}
+
// In D6, status=0 means published, while in D8 means the opposite.
// See https://www.drupal.org/node/237636.
$row->setSourceProperty('status', !$row->getSourceProperty('status'));
- return parent::prepareRow($row);
+ return $row;
}
/**
diff --git a/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php b/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php
index 398895b..4417e91 100644
--- a/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php
+++ b/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php
@@ -2,6 +2,8 @@
namespace Drupal\comment\Plugin\migrate\source\d6;
+@trigger_error('CommentVariable is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\node\Plugin\migrate\source\d6\NodeType instead.', E_USER_DEPRECATED);
+
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
use Drupal\migrate\Plugin\migrate\source\DummyQueryTrait;
@@ -10,6 +12,9 @@
* id = "d6_comment_variable",
* source_module = "comment"
* )
+ *
+ * @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x. Use
+ * \Drupal\node\Plugin\migrate\source\d6\NodeType instead.
*/
class CommentVariable extends DrupalSqlBase {
diff --git a/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariablePerCommentType.php b/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariablePerCommentType.php
index 0096ecd..03e9565 100644
--- a/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariablePerCommentType.php
+++ b/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariablePerCommentType.php
@@ -2,11 +2,16 @@
namespace Drupal\comment\Plugin\migrate\source\d6;
+@trigger_error('CommentVariablePerCommentType is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\node\Plugin\migrate\source\d6\NodeType instead.', E_USER_DEPRECATED);
+
/**
* @MigrateSource(
* id = "d6_comment_variable_per_comment_type",
* source_module = "comment"
* )
+ *
+ * @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x. Use
+ * \Drupal\node\Plugin\migrate\source\d6\NodeType instead.
*/
class CommentVariablePerCommentType extends CommentVariable {
diff --git a/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php b/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php
index a64fc8e..f022b42 100644
--- a/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php
+++ b/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php
@@ -2,6 +2,8 @@
namespace Drupal\comment\Plugin\migrate\source\d7;
+@trigger_error('CommentType is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\node\Plugin\migrate\source\d7\NodeType instead.', E_USER_DEPRECATED);
+
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
@@ -13,6 +15,9 @@
* id = "d7_comment_type",
* source_module = "comment"
* )
+ *
+ * @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x. Use
+ * \Drupal\node\Plugin\migrate\source\d7\NodeType instead.
*/
class CommentType extends DrupalSqlBase {
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentEntityDisplayTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentEntityDisplayTest.php
new file mode 100644
index 0000000..2c13371
--- /dev/null
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentEntityDisplayTest.php
@@ -0,0 +1,71 @@
+installConfig(['comment']);
+ $this->migrateContentTypes();
+ $this->executeMigrations([
+ 'd6_node_type',
+ 'd6_comment_type',
+ 'd6_comment_field',
+ 'd6_comment_field_instance',
+ 'd6_comment_entity_display',
+ ]);
+ }
+
+ /**
+ * Asserts various aspects of a comment component in an entity view display.
+ *
+ * @param string $id
+ * The entity ID.
+ * @param string $component_id
+ * The ID of the display component.
+ */
+ protected function assertDisplay($id, $component_id) {
+ $component = EntityViewDisplay::load($id)->getComponent($component_id);
+ $this->assertInternalType('array', $component);
+ $this->assertSame('hidden', $component['label']);
+ $this->assertSame('comment_default', $component['type']);
+ $this->assertSame(20, $component['weight']);
+ }
+
+ /**
+ * Tests the migrated display configuration.
+ */
+ public function testMigration() {
+ $this->assertDisplay('node.article.default', 'comment_node_article');
+ $this->assertDisplay('node.company.default', 'comment_node_company');
+ $this->assertDisplay('node.employee.default', 'comment_node_employee');
+ $this->assertDisplay('node.event.default', 'comment_node_event');
+ $this->assertDisplay('node.forum.default', 'comment_forum');
+ $this->assertDisplay('node.page.default', 'comment_node_page');
+ $this->assertDisplay('node.sponsor.default', 'comment_node_sponsor');
+ $this->assertDisplay('node.story.default', 'comment_node_story');
+ $this->assertDisplay('node.test_event.default', 'comment_node_test_event');
+ $this->assertDisplay('node.test_page.default', 'comment_node_test_page');
+ $this->assertDisplay('node.test_planet.default', 'comment_node_test_planet');
+ $this->assertDisplay('node.test_story.default', 'comment_node_test_story');
+ }
+
+}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentEntityFormDisplaySubjectTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentEntityFormDisplaySubjectTest.php
new file mode 100644
index 0000000..74a8715
--- /dev/null
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentEntityFormDisplaySubjectTest.php
@@ -0,0 +1,73 @@
+installConfig(['comment']);
+ $this->executeMigrations([
+ 'd6_comment_type',
+ 'd6_comment_entity_form_display_subject',
+ ]);
+ }
+
+ /**
+ * Asserts that the comment subject field is visible for a node type.
+ *
+ * @param string $id
+ * The entity form display ID.
+ */
+ protected function assertSubjectVisible($id) {
+ $component = EntityFormDisplay::load($id)->getComponent('subject');
+ $this->assertInternalType('array', $component);
+ $this->assertSame('string_textfield', $component['type']);
+ $this->assertSame(10, $component['weight']);
+ }
+
+ /**
+ * Asserts that the comment subject field is not visible for a node type.
+ *
+ * @param string $id
+ * The entity form display ID.
+ */
+ protected function assertSubjectNotVisible($id) {
+ $component = EntityFormDisplay::load($id)->getComponent('subject');
+ $this->assertNull($component);
+ }
+
+ /**
+ * Tests the migrated display configuration.
+ */
+ public function testMigration() {
+ $this->assertSubjectVisible('comment.comment_node_article.default');
+ $this->assertSubjectVisible('comment.comment_node_company.default');
+ $this->assertSubjectVisible('comment.comment_node_employee.default');
+ $this->assertSubjectVisible('comment.comment_node_page.default');
+ $this->assertSubjectVisible('comment.comment_node_sponsor.default');
+ $this->assertSubjectNotVisible('comment.comment_node_story.default');
+ $this->assertSubjectVisible('comment.comment_node_test_event.default');
+ $this->assertSubjectVisible('comment.comment_node_test_page.default');
+ $this->assertSubjectVisible('comment.comment_node_test_planet.default');
+ $this->assertSubjectVisible('comment.comment_node_test_story.default');
+ }
+
+}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentEntityFormDisplayTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentEntityFormDisplayTest.php
new file mode 100644
index 0000000..c9e0d6b
--- /dev/null
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentEntityFormDisplayTest.php
@@ -0,0 +1,69 @@
+installConfig(['comment']);
+ $this->migrateContentTypes();
+ $this->executeMigrations([
+ 'd6_comment_type',
+ 'd6_comment_field',
+ 'd6_comment_field_instance',
+ 'd6_comment_entity_form_display',
+ ]);
+ }
+
+ /**
+ * Asserts various aspects of a comment component in an entity form display.
+ *
+ * @param string $id
+ * The entity ID.
+ * @param string $component_id
+ * The ID of the form component.
+ */
+ protected function assertDisplay($id, $component_id) {
+ $component = EntityFormDisplay::load($id)->getComponent($component_id);
+ $this->assertInternalType('array', $component);
+ $this->assertSame('comment_default', $component['type']);
+ $this->assertSame(20, $component['weight']);
+ }
+
+ /**
+ * Tests the migrated display configuration.
+ */
+ public function testMigration() {
+ $this->assertDisplay('node.article.default', 'comment_node_article');
+ $this->assertDisplay('node.company.default', 'comment_node_company');
+ $this->assertDisplay('node.employee.default', 'comment_node_employee');
+ $this->assertDisplay('node.event.default', 'comment_node_event');
+ $this->assertDisplay('node.forum.default', 'comment_forum');
+ $this->assertDisplay('node.page.default', 'comment_node_page');
+ $this->assertDisplay('node.sponsor.default', 'comment_node_sponsor');
+ $this->assertDisplay('node.story.default', 'comment_node_story');
+ $this->assertDisplay('node.test_event.default', 'comment_node_test_event');
+ $this->assertDisplay('node.test_page.default', 'comment_node_test_page');
+ $this->assertDisplay('node.test_planet.default', 'comment_node_test_planet');
+ $this->assertDisplay('node.test_story.default', 'comment_node_test_story');
+ }
+
+}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentFieldInstanceTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentFieldInstanceTest.php
new file mode 100644
index 0000000..03469c4
--- /dev/null
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentFieldInstanceTest.php
@@ -0,0 +1,89 @@
+installConfig(['comment']);
+ $this->migrateContentTypes();
+ $this->executeMigrations([
+ 'd6_comment_type',
+ 'd6_comment_field',
+ 'd6_comment_field_instance',
+ ]);
+ }
+
+ /**
+ * Asserts a comment field instance entity.
+ *
+ * @param string $bundle
+ * The bundle ID.
+ * @param string $field_name
+ * The field name.
+ * @param int $default_value
+ * The field's default_value setting.
+ * @param int $default_mode
+ * The field's default_mode setting.
+ * @param int $per_page
+ * The field's per_page setting.
+ * @param bool $anonymous
+ * The field's anonymous setting.
+ * @param int $form_location
+ * The field's form_location setting.
+ * @param bool $preview
+ * The field's preview setting.
+ */
+ protected function assertEntity($bundle, $field_name, $default_value, $default_mode, $per_page, $anonymous, $form_location, $preview) {
+ $entity = FieldConfig::load("node.$bundle.$field_name");
+ $this->assertInstanceOf(FieldConfig::class, $entity);
+ $this->assertSame('node', $entity->getTargetEntityTypeId());
+ $this->assertSame('Comments', $entity->label());
+ $this->assertTrue($entity->isRequired());
+ $this->assertSame($bundle, $entity->getTargetBundle());
+ $this->assertSame($field_name, $entity->getFieldStorageDefinition()->getName());
+ $this->assertSame($default_value, $entity->get('default_value')[0]['status']);
+ $this->assertSame($default_mode, $entity->getSetting('default_mode'));
+ $this->assertSame($per_page, $entity->getSetting('per_page'));
+ $this->assertSame($anonymous, $entity->getSetting('anonymous'));
+ $this->assertSame($form_location, $entity->getSetting('form_location'));
+ $this->assertSame($preview, $entity->getSetting('preview'));
+ }
+
+ /**
+ * Test the migrated field instance values.
+ */
+ public function testMigration() {
+ $this->assertEntity('article', 'comment_node_article', 2, 1, 50, 0, FALSE, 1);
+ $this->assertEntity('company', 'comment_node_company', 2, 1, 50, 0, FALSE, 1);
+ $this->assertEntity('employee', 'comment_node_employee', 2, 1, 50, 0, FALSE, 1);
+ $this->assertEntity('event', 'comment_node_event', 2, 1, 50, 0, FALSE, 1);
+ $this->assertEntity('forum', 'comment_forum', 2, 1, 50, 0, FALSE, 1);
+ $this->assertEntity('page', 'comment_node_page', 0, 1, 50, 0, FALSE, 1);
+ $this->assertEntity('sponsor', 'comment_node_sponsor', 2, 1, 50, 0, FALSE, 1);
+ $this->assertEntity('story', 'comment_node_story', 2, 0, 70, 1, FALSE, 0);
+ $this->assertEntity('test_event', 'comment_node_test_event', 2, 1, 50, 0, FALSE, 1);
+ $this->assertEntity('test_page', 'comment_node_test_page', 2, 1, 50, 0, FALSE, 1);
+ $this->assertEntity('test_planet', 'comment_node_test_planet', 2, 1, 50, 0, FALSE, 1);
+ $this->assertEntity('test_story', 'comment_node_test_story', 2, 1, 50, 0, FALSE, 1);
+ }
+
+}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentFieldTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentFieldTest.php
new file mode 100644
index 0000000..e08e2d2
--- /dev/null
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentFieldTest.php
@@ -0,0 +1,65 @@
+installConfig(['comment']);
+ $this->executeMigrations([
+ 'd6_comment_type',
+ 'd6_comment_field',
+ ]);
+ }
+
+ /**
+ * Asserts a comment field entity.
+ *
+ * @param string $comment_type
+ * The comment type.
+ */
+ protected function assertEntity($comment_type) {
+ $entity = FieldStorageConfig::load('node.' . $comment_type);
+ $this->assertInstanceOf(FieldStorageConfig::class, $entity);
+ $this->assertSame('node', $entity->getTargetEntityTypeId());
+ $this->assertSame('comment', $entity->getType());
+ $this->assertSame($comment_type, $entity->getSetting('comment_type'));
+ }
+
+ /**
+ * Tests the migrated comment fields.
+ */
+ public function testMigration() {
+ $this->assertEntity('comment_node_article');
+ $this->assertEntity('comment_node_company');
+ $this->assertEntity('comment_node_employee');
+ $this->assertEntity('comment_node_event');
+ $this->assertEntity('comment_forum');
+ $this->assertEntity('comment_node_page');
+ $this->assertEntity('comment_node_sponsor');
+ $this->assertEntity('comment_node_story');
+ $this->assertEntity('comment_node_test_event');
+ $this->assertEntity('comment_node_test_page');
+ $this->assertEntity('comment_node_test_planet');
+ $this->assertEntity('comment_node_test_story');
+ }
+
+}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentTest.php
index 2a13178..06ca655 100644
--- a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentTest.php
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentTest.php
@@ -2,12 +2,15 @@
namespace Drupal\Tests\comment\Kernel\Migrate\d6;
+use Drupal\comment\Entity\Comment;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
+use Drupal\node\NodeInterface;
/**
- * Upgrade comments.
+ * Tests the migration of comments from Drupal 6.
*
+ * @group comment
* @group migrate_drupal_6
*/
class MigrateCommentTest extends MigrateDrupal6TestBase {
@@ -46,32 +49,41 @@ protected function setUp() {
}
/**
- * Tests the Drupal 6 to Drupal 8 comment migration.
+ * Tests the migrated comments.
*/
- public function testComments() {
- /** @var \Drupal\Core\Entity\EntityStorageInterface $comment_storage */
- $comment_storage = $this->container->get('entity.manager')->getStorage('comment');
- /** @var \Drupal\comment\CommentInterface $comment */
- $comment = $comment_storage->load(1);
- $this->assertIdentical('The first comment.', $comment->getSubject());
- $this->assertIdentical('The first comment body.', $comment->comment_body->value);
- $this->assertIdentical('filtered_html', $comment->comment_body->format);
- $this->assertIdentical(NULL, $comment->pid->target_id);
- $this->assertIdentical('1', $comment->getCommentedEntityId());
- $this->assertIdentical('node', $comment->getCommentedEntityTypeId());
- $this->assertIdentical('en', $comment->language()->getId());
- $this->assertIdentical('comment_no_subject', $comment->getTypeId());
- $this->assertEquals('203.0.113.1', $comment->getHostname());
-
- $comment = $comment_storage->load(2);
- $this->assertIdentical('The response to the second comment.', $comment->subject->value);
- $this->assertIdentical('3', $comment->pid->target_id);
- $this->assertEquals('203.0.113.2', $comment->getHostname());
-
- $comment = $comment_storage->load(3);
- $this->assertIdentical('The second comment.', $comment->subject->value);
- $this->assertIdentical(NULL, $comment->pid->target_id);
- $this->assertEquals('203.0.113.3', $comment->getHostname());
+ public function testMigration() {
+ $comment = Comment::load(1);
+ $this->assertSame('The first comment.', $comment->getSubject());
+ $this->assertSame('The first comment body.', $comment->comment_body->value);
+ $this->assertSame('filtered_html', $comment->comment_body->format);
+ $this->assertSame(NULL, $comment->pid->target_id);
+ $this->assertSame('1', $comment->getCommentedEntityId());
+ $this->assertSame('node', $comment->getCommentedEntityTypeId());
+ $this->assertSame('en', $comment->language()->getId());
+ $this->assertSame('comment_node_story', $comment->getTypeId());
+ $this->assertSame('203.0.113.1', $comment->getHostname());
+
+ $node = $comment->getCommentedEntity();
+ $this->assertInstanceOf(NodeInterface::class, $node);
+ $this->assertSame('1', $node->id());
+
+ $comment = Comment::load(2);
+ $this->assertSame('The response to the second comment.', $comment->subject->value);
+ $this->assertSame('3', $comment->pid->target_id);
+ $this->assertSame('203.0.113.2', $comment->getHostname());
+
+ $node = $comment->getCommentedEntity();
+ $this->assertInstanceOf(NodeInterface::class, $node);
+ $this->assertSame('1', $node->id());
+
+ $comment = Comment::load(3);
+ $this->assertSame('The second comment.', $comment->subject->value);
+ $this->assertSame(NULL, $comment->pid->target_id);
+ $this->assertSame('203.0.113.3', $comment->getHostname());
+
+ $node = $comment->getCommentedEntity();
+ $this->assertInstanceOf(NodeInterface::class, $node);
+ $this->assertSame('1', $node->id());
}
}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentTypeTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentTypeTest.php
index c28be63..2fa6082 100644
--- a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentTypeTest.php
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentTypeTest.php
@@ -6,8 +6,9 @@
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
- * Upgrade comment type.
+ * Tests the migration of comment types from Drupal 6.
*
+ * @group comment
* @group migrate_drupal_6
*/
class MigrateCommentTypeTest extends MigrateDrupal6TestBase {
@@ -22,20 +23,41 @@ class MigrateCommentTypeTest extends MigrateDrupal6TestBase {
*/
protected function setUp() {
parent::setUp();
- $this->installEntitySchema('node');
- $this->installEntitySchema('comment');
- $this->installConfig(['node', 'comment']);
+ $this->installConfig(['comment']);
$this->executeMigration('d6_comment_type');
}
/**
- * Tests the Drupal 6 to Drupal 8 comment type migration.
+ * Asserts a comment type entity.
+ *
+ * @param string $id
+ * The entity ID.
+ * @param string $label
+ * The entity label.
*/
- public function testCommentType() {
- $comment_type = CommentType::load('comment');
- $this->assertIdentical('node', $comment_type->getTargetEntityTypeId());
- $comment_type = CommentType::load('comment_no_subject');
- $this->assertIdentical('node', $comment_type->getTargetEntityTypeId());
+ protected function assertEntity($id, $label) {
+ $entity = CommentType::load($id);
+ $this->assertInstanceOf(CommentType::class, $entity);
+ $this->assertSame($label, $entity->label());
+ $this->assertSame('node', $entity->getTargetEntityTypeId());
+ }
+
+ /**
+ * Tests the migrated comment types.
+ */
+ public function testMigration() {
+ $this->assertEntity('comment_node_article', 'Article comment');
+ $this->assertEntity('comment_node_company', 'Company comment');
+ $this->assertEntity('comment_node_employee', 'Employee comment');
+ $this->assertEntity('comment_node_event', 'Event comment');
+ $this->assertEntity('comment_forum', 'Forum topic comment');
+ $this->assertEntity('comment_node_page', 'Page comment');
+ $this->assertEntity('comment_node_sponsor', 'Sponsor comment');
+ $this->assertEntity('comment_node_story', 'Story comment');
+ $this->assertEntity('comment_node_test_event', 'Migrate test event comment');
+ $this->assertEntity('comment_node_test_page', 'Migrate test page comment');
+ $this->assertEntity('comment_node_test_planet', 'Migrate test planet comment');
+ $this->assertEntity('comment_node_test_story', 'Migrate test story comment');
}
}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableDisplayBase.php b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableDisplayBase.php
deleted file mode 100644
index 964185b..0000000
--- a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableDisplayBase.php
+++ /dev/null
@@ -1,31 +0,0 @@
-installConfig(['comment']);
- $this->migrateContentTypes();
- $this->executeMigrations([
- 'd6_comment_type',
- 'd6_comment_field',
- 'd6_comment_field_instance',
- ]);
- }
-
-}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableEntityDisplayTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableEntityDisplayTest.php
deleted file mode 100644
index baa28bc..0000000
--- a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableEntityDisplayTest.php
+++ /dev/null
@@ -1,39 +0,0 @@
-executeMigration('d6_comment_entity_display');
- }
-
- /**
- * Tests comment variables migrated into an entity display.
- */
- public function testCommentEntityDisplay() {
- foreach (['page', 'story', 'article'] as $type) {
- $component = EntityViewDisplay::load('node.' . $type . '.default')->getComponent('comment');
- $this->assertIdentical('hidden', $component['label']);
- $this->assertIdentical('comment_default', $component['type']);
- $this->assertIdentical(20, $component['weight']);
- }
- }
-
-}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableEntityFormDisplaySubjectTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableEntityFormDisplaySubjectTest.php
deleted file mode 100644
index 31e61e0..0000000
--- a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableEntityFormDisplaySubjectTest.php
+++ /dev/null
@@ -1,45 +0,0 @@
-installConfig(['comment']);
- $this->executeMigrations([
- 'd6_comment_type',
- 'd6_comment_entity_form_display_subject',
- ]);
- }
-
- /**
- * Tests comment subject variable migrated into an entity display.
- */
- public function testCommentEntityFormDisplay() {
- $component = EntityFormDisplay::load('comment.comment.default')
- ->getComponent('subject');
- $this->assertIdentical('string_textfield', $component['type']);
- $this->assertIdentical(10, $component['weight']);
- $component = EntityFormDisplay::load('comment.comment_no_subject.default')
- ->getComponent('subject');
- $this->assertNull($component);
- }
-
-}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableEntityFormDisplayTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableEntityFormDisplayTest.php
deleted file mode 100644
index 818f9b8..0000000
--- a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableEntityFormDisplayTest.php
+++ /dev/null
@@ -1,39 +0,0 @@
-executeMigration('d6_comment_entity_form_display');
- }
-
- /**
- * Tests comment variables migrated into an entity display.
- */
- public function testCommentEntityFormDisplay() {
- foreach (['page', 'article', 'story'] as $type) {
- $component = EntityFormDisplay::load('node.' . $type . '.default')
- ->getComponent('comment');
- $this->assertIdentical('comment_default', $component['type']);
- $this->assertIdentical(20, $component['weight']);
- }
- }
-
-}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableFieldTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableFieldTest.php
deleted file mode 100644
index e2a2189..0000000
--- a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableFieldTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-installConfig(['comment']);
- $this->migrateContentTypes();
- $this->executeMigrations(['d6_comment_type', 'd6_comment_field']);
- }
-
- /**
- * Tests comment variables migrated into a field entity.
- */
- public function testCommentField() {
- $this->assertTrue(is_object(FieldStorageConfig::load('node.comment')));
- }
-
-}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableInstanceTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableInstanceTest.php
deleted file mode 100644
index 90b256f..0000000
--- a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableInstanceTest.php
+++ /dev/null
@@ -1,60 +0,0 @@
-installConfig(['comment']);
- $this->migrateContentTypes();
- $this->executeMigrations([
- 'd6_comment_type',
- 'd6_comment_field',
- 'd6_comment_field_instance',
- ]);
- }
-
- /**
- * Test the migrated field instance values.
- */
- public function testCommentFieldInstance() {
- $node = Node::create(['type' => 'page']);
- $this->assertIdentical(0, $node->comment->status);
- $this->assertIdentical('comment', $node->comment->getFieldDefinition()->getName());
- $settings = $node->comment->getFieldDefinition()->getSettings();
- $this->assertIdentical(CommentManagerInterface::COMMENT_MODE_THREADED, $settings['default_mode']);
- $this->assertIdentical(50, $settings['per_page']);
- $this->assertFalse($settings['anonymous']);
- $this->assertFalse($settings['form_location']);
- $this->assertTrue($settings['preview']);
-
- $node = Node::create(['type' => 'story']);
- $this->assertIdentical(2, $node->comment_no_subject->status);
- $this->assertIdentical('comment_no_subject', $node->comment_no_subject->getFieldDefinition()->getName());
- $settings = $node->comment_no_subject->getFieldDefinition()->getSettings();
- $this->assertIdentical(CommentManagerInterface::COMMENT_MODE_FLAT, $settings['default_mode']);
- $this->assertIdentical(70, $settings['per_page']);
- $this->assertTrue($settings['anonymous']);
- $this->assertFalse($settings['form_location']);
- $this->assertFalse($settings['preview']);
- }
-
-}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentEntityDisplayTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentEntityDisplayTest.php
index 8857f57..aeb1e92 100644
--- a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentEntityDisplayTest.php
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentEntityDisplayTest.php
@@ -6,12 +6,16 @@
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
- * Tests migration of comment display configuration.
+ * Tests the migration of comment entity displays from Drupal 7.
*
* @group comment
+ * @group migrate_drupal_7
*/
class MigrateCommentEntityDisplayTest extends MigrateDrupal7TestBase {
+ /**
+ * {@inheritdoc}
+ */
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
/**
@@ -19,7 +23,7 @@ class MigrateCommentEntityDisplayTest extends MigrateDrupal7TestBase {
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(static::$modules);
+ $this->installConfig(['comment', 'node']);
$this->executeMigrations([
'd7_node_type',
'd7_comment_type',
@@ -30,7 +34,7 @@ protected function setUp() {
}
/**
- * Asserts a display entity.
+ * Asserts various aspects of a comment component in an entity view display.
*
* @param string $id
* The entity ID.
@@ -39,10 +43,10 @@ protected function setUp() {
*/
protected function assertDisplay($id, $component_id) {
$component = EntityViewDisplay::load($id)->getComponent($component_id);
- $this->assertTrue(is_array($component));
- $this->assertIdentical('hidden', $component['label']);
- $this->assertIdentical('comment_default', $component['type']);
- $this->assertIdentical(20, $component['weight']);
+ $this->assertInternalType('array', $component);
+ $this->assertSame('hidden', $component['label']);
+ $this->assertSame('comment_default', $component['type']);
+ $this->assertSame(20, $component['weight']);
}
/**
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentEntityFormDisplaySubjectTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentEntityFormDisplaySubjectTest.php
index c713a45..2c3025a 100644
--- a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentEntityFormDisplaySubjectTest.php
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentEntityFormDisplaySubjectTest.php
@@ -6,12 +6,16 @@
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
- * Tests migration of comment form's subject display configuration.
+ * Tests the migration of comment form's subject display from Drupal 7.
*
* @group comment
+ * @group migrate_drupal_7
*/
class MigrateCommentEntityFormDisplaySubjectTest extends MigrateDrupal7TestBase {
+ /**
+ * {@inheritdoc}
+ */
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
/**
@@ -19,37 +23,47 @@ class MigrateCommentEntityFormDisplaySubjectTest extends MigrateDrupal7TestBase
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(static::$modules);
+ $this->installConfig(['comment']);
$this->executeMigrations([
- 'd7_node_type',
'd7_comment_type',
'd7_comment_entity_form_display_subject',
]);
}
/**
- * Asserts a display entity.
+ * Asserts that the comment subject field is visible for a node type.
+ *
+ * @param string $id
+ * The entity form display ID.
+ */
+ protected function assertSubjectVisible($id) {
+ $component = EntityFormDisplay::load($id)->getComponent('subject');
+ $this->assertInternalType('array', $component);
+ $this->assertSame('string_textfield', $component['type']);
+ $this->assertSame(10, $component['weight']);
+ }
+
+ /**
+ * Asserts that the comment subject field is not visible for a node type.
*
* @param string $id
- * The entity ID.
+ * The entity form display ID.
*/
- protected function assertDisplay($id) {
+ protected function assertSubjectNotVisible($id) {
$component = EntityFormDisplay::load($id)->getComponent('subject');
- $this->assertTrue(is_array($component));
- $this->assertIdentical('string_textfield', $component['type']);
- $this->assertIdentical(10, $component['weight']);
+ $this->assertNull($component);
}
/**
* Tests the migrated display configuration.
*/
public function testMigration() {
- $this->assertDisplay('comment.comment_node_page.default');
- $this->assertDisplay('comment.comment_node_article.default');
- $this->assertDisplay('comment.comment_node_book.default');
- $this->assertDisplay('comment.comment_node_blog.default');
- $this->assertDisplay('comment.comment_forum.default');
- $this->assertDisplay('comment.comment_node_test_content_type.default');
+ $this->assertSubjectVisible('comment.comment_node_page.default');
+ $this->assertSubjectVisible('comment.comment_node_article.default');
+ $this->assertSubjectVisible('comment.comment_node_book.default');
+ $this->assertSubjectVisible('comment.comment_node_blog.default');
+ $this->assertSubjectVisible('comment.comment_forum.default');
+ $this->assertSubjectNotVisible('comment.comment_node_test_content_type.default');
}
}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentEntityFormDisplayTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentEntityFormDisplayTest.php
index 8568913..2f0f6f3 100644
--- a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentEntityFormDisplayTest.php
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentEntityFormDisplayTest.php
@@ -6,12 +6,16 @@
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
- * Tests migration of comment form display configuration.
+ * Tests the migration of comment form display from Drupal 7.
*
* @group comment
+ * @group migrate_drupal_7
*/
class MigrateCommentEntityFormDisplayTest extends MigrateDrupal7TestBase {
+ /**
+ * {@inheritdoc}
+ */
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
/**
@@ -19,7 +23,7 @@ class MigrateCommentEntityFormDisplayTest extends MigrateDrupal7TestBase {
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(static::$modules);
+ $this->installConfig(['comment', 'node']);
$this->executeMigrations([
'd7_node_type',
'd7_comment_type',
@@ -30,7 +34,7 @@ protected function setUp() {
}
/**
- * Asserts a display entity.
+ * Asserts various aspects of a comment component in an entity form display.
*
* @param string $id
* The entity ID.
@@ -39,21 +43,21 @@ protected function setUp() {
*/
protected function assertDisplay($id, $component_id) {
$component = EntityFormDisplay::load($id)->getComponent($component_id);
- $this->assertTrue(is_array($component));
- $this->assertIdentical('comment_default', $component['type']);
- $this->assertIdentical(20, $component['weight']);
+ $this->assertInternalType('array', $component);
+ $this->assertSame('comment_default', $component['type']);
+ $this->assertSame(20, $component['weight']);
}
/**
* Tests the migrated display configuration.
*/
public function testMigration() {
- $this->assertDisplay('node.page.default', 'comment');
- $this->assertDisplay('node.article.default', 'comment');
- $this->assertDisplay('node.book.default', 'comment');
- $this->assertDisplay('node.blog.default', 'comment');
- $this->assertDisplay('node.forum.default', 'comment');
- $this->assertDisplay('node.test_content_type.default', 'comment');
+ $this->assertDisplay('node.page.default', 'comment_node_page');
+ $this->assertDisplay('node.article.default', 'comment_node_article');
+ $this->assertDisplay('node.book.default', 'comment_node_book');
+ $this->assertDisplay('node.blog.default', 'comment_node_blog');
+ $this->assertDisplay('node.forum.default', 'comment_forum');
+ $this->assertDisplay('node.test_content_type.default', 'comment_node_test_content_type');
}
}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentFieldInstanceTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentFieldInstanceTest.php
index f7e10d0..4b928f7 100644
--- a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentFieldInstanceTest.php
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentFieldInstanceTest.php
@@ -2,19 +2,20 @@
namespace Drupal\Tests\comment\Kernel\Migrate\d7;
-use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
-use Drupal\Core\Field\FieldConfigInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
- * Tests creation of comment reference fields for each comment type defined
- * in Drupal 7.
+ * Tests the migration of comment field instances from Drupal 7.
*
* @group comment
+ * @group migrate_drupal_7
*/
class MigrateCommentFieldInstanceTest extends MigrateDrupal7TestBase {
+ /**
+ * {@inheritdoc}
+ */
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
/**
@@ -22,7 +23,7 @@ class MigrateCommentFieldInstanceTest extends MigrateDrupal7TestBase {
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(static::$modules);
+ $this->installConfig(['comment', 'node']);
$this->executeMigrations([
'd7_node_type',
'd7_comment_type',
@@ -32,14 +33,14 @@ protected function setUp() {
}
/**
- * Asserts a comment field entity.
+ * Asserts a comment field instance entity.
*
- * @param string $id
- * The entity ID.
- * @param string $field_name
- * The field name.
* @param string $bundle
* The bundle ID.
+ * @param string $field_name
+ * The field name.
+ * @param int $default_value
+ * The field's default_value setting.
* @param int $default_mode
* The field's default_mode setting.
* @param int $per_page
@@ -51,36 +52,32 @@ protected function setUp() {
* @param bool $preview
* The field's preview setting.
*/
- protected function assertEntity($id, $field_name, $bundle, $default_mode, $per_page, $anonymous, $form_location, $preview) {
- $entity = FieldConfig::load($id);
- $this->assertTrue($entity instanceof FieldConfigInterface);
- /** @var \Drupal\field\FieldConfigInterface $entity */
- $this->assertIdentical('node', $entity->getTargetEntityTypeId());
- $this->assertIdentical('Comments', $entity->label());
+ protected function assertEntity($bundle, $field_name, $default_value, $default_mode, $per_page, $anonymous, $form_location, $preview) {
+ $entity = FieldConfig::load("node.$bundle.$field_name");
+ $this->assertInstanceOf(FieldConfig::class, $entity);
+ $this->assertSame('node', $entity->getTargetEntityTypeId());
+ $this->assertSame('Comments', $entity->label());
$this->assertTrue($entity->isRequired());
- $this->assertIdentical($field_name, $entity->getFieldStorageDefinition()->getName());
- $this->assertIdentical($bundle, $entity->getTargetBundle());
- $this->assertTrue($entity->get('default_value')[0]['status']);
- $this->assertEqual($default_mode, $entity->getSetting('default_mode'));
- $this->assertIdentical($per_page, $entity->getSetting('per_page'));
- $this->assertEqual($anonymous, $entity->getSetting('anonymous'));
- // This assertion fails because 1 !== TRUE. It's extremely strange that
- // the form_location setting is returning a boolean, but this appears to
- // be a problem with the entity, not with the migration.
- // $this->asserIdentical($form_location, $entity->getSetting('form_location'));
- $this->assertEqual($preview, $entity->getSetting('preview'));
+ $this->assertSame($bundle, $entity->getTargetBundle());
+ $this->assertSame($field_name, $entity->getFieldStorageDefinition()->getName());
+ $this->assertSame($default_value, $entity->get('default_value')[0]['status']);
+ $this->assertSame($default_mode, $entity->getSetting('default_mode'));
+ $this->assertSame($per_page, $entity->getSetting('per_page'));
+ $this->assertSame($anonymous, $entity->getSetting('anonymous'));
+ $this->assertSame($form_location, $entity->getSetting('form_location'));
+ $this->assertSame($preview, $entity->getSetting('preview'));
}
/**
* Tests the migrated fields.
*/
public function testMigration() {
- $this->assertEntity('node.page.comment_node_page', 'comment_node_page', 'page', TRUE, 50, FALSE, CommentItemInterface::FORM_BELOW, TRUE);
- $this->assertEntity('node.article.comment_node_article', 'comment_node_article', 'article', TRUE, 50, FALSE, CommentItemInterface::FORM_BELOW, TRUE);
- $this->assertEntity('node.blog.comment_node_blog', 'comment_node_blog', 'blog', TRUE, 50, FALSE, CommentItemInterface::FORM_BELOW, TRUE);
- $this->assertEntity('node.book.comment_node_book', 'comment_node_book', 'book', TRUE, 50, FALSE, CommentItemInterface::FORM_BELOW, TRUE);
- $this->assertEntity('node.forum.comment_forum', 'comment_forum', 'forum', TRUE, 50, FALSE, CommentItemInterface::FORM_BELOW, TRUE);
- $this->assertEntity('node.test_content_type.comment_node_test_content_type', 'comment_node_test_content_type', 'test_content_type', TRUE, 30, FALSE, CommentItemInterface::FORM_BELOW, TRUE);
+ $this->assertEntity('page', 'comment_node_page', 0, 1, 50, 0, TRUE, 1);
+ $this->assertEntity('article', 'comment_node_article', 2, 1, 50, 0, TRUE, 1);
+ $this->assertEntity('blog', 'comment_node_blog', 2, 1, 50, 0, TRUE, 1);
+ $this->assertEntity('book', 'comment_node_book', 2, 1, 50, 0, TRUE, 1);
+ $this->assertEntity('forum', 'comment_forum', 2, 1, 50, 0, TRUE, 1);
+ $this->assertEntity('test_content_type', 'comment_node_test_content_type', 2, 1, 30, 0, TRUE, 1);
}
}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentFieldTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentFieldTest.php
index 6f94df1..aa59f67 100644
--- a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentFieldTest.php
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentFieldTest.php
@@ -3,27 +3,28 @@
namespace Drupal\Tests\comment\Kernel\Migrate\d7;
use Drupal\field\Entity\FieldStorageConfig;
-use Drupal\field\FieldStorageConfigInterface;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
- * Tests creation of comment reference fields for each comment type defined
- * in Drupal 7.
+ * Tests the migration of comment fields from Drupal 7.
*
* @group comment
+ * @group migrate_drupal_7
*/
class MigrateCommentFieldTest extends MigrateDrupal7TestBase {
- public static $modules = ['node', 'comment', 'text', 'menu_ui'];
+ /**
+ * {@inheritdoc}
+ */
+ public static $modules = ['node', 'comment', 'text'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(static::$modules);
+ $this->installConfig(['comment']);
$this->executeMigrations([
- 'd7_node_type',
'd7_comment_type',
'd7_comment_field',
]);
@@ -32,30 +33,27 @@ protected function setUp() {
/**
* Asserts a comment field entity.
*
- * @param string $id
- * The entity ID.
* @param string $comment_type
- * The comment type (bundle ID) the field references.
+ * The comment type.
*/
- protected function assertEntity($id, $comment_type) {
- $entity = FieldStorageConfig::load($id);
- $this->assertTrue($entity instanceof FieldStorageConfigInterface);
- /** @var \Drupal\field\FieldStorageConfigInterface $entity */
- $this->assertIdentical('node', $entity->getTargetEntityTypeId());
- $this->assertIdentical('comment', $entity->getType());
- $this->assertIdentical($comment_type, $entity->getSetting('comment_type'));
+ protected function assertEntity($comment_type) {
+ $entity = FieldStorageConfig::load('node.' . $comment_type);
+ $this->assertInstanceOf(FieldStorageConfig::class, $entity);
+ $this->assertSame('node', $entity->getTargetEntityTypeId());
+ $this->assertSame('comment', $entity->getType());
+ $this->assertSame($comment_type, $entity->getSetting('comment_type'));
}
/**
- * Tests the migrated fields.
+ * Tests the migrated comment fields.
*/
public function testMigration() {
- $this->assertEntity('node.comment_node_page', 'comment_node_page');
- $this->assertEntity('node.comment_node_article', 'comment_node_article');
- $this->assertEntity('node.comment_node_blog', 'comment_node_blog');
- $this->assertEntity('node.comment_node_book', 'comment_node_book');
- $this->assertEntity('node.comment_forum', 'comment_forum');
- $this->assertEntity('node.comment_node_test_content_type', 'comment_node_test_content_type');
+ $this->assertEntity('comment_node_page');
+ $this->assertEntity('comment_node_article');
+ $this->assertEntity('comment_node_blog');
+ $this->assertEntity('comment_node_book');
+ $this->assertEntity('comment_forum');
+ $this->assertEntity('comment_node_test_content_type');
}
}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php
index 42c2a30..95717ed 100644
--- a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php
@@ -2,18 +2,21 @@
namespace Drupal\Tests\comment\Kernel\Migrate\d7;
-use Drupal\comment\CommentInterface;
use Drupal\comment\Entity\Comment;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\node\NodeInterface;
/**
- * Tests migration of comments from Drupal 7.
+ * Tests the migration of comments from Drupal 7.
*
* @group comment
+ * @group migrate_drupal_7
*/
class MigrateCommentTest extends MigrateDrupal7TestBase {
+ /**
+ * {@inheritdoc}
+ */
public static $modules = ['filter', 'node', 'comment', 'text', 'menu_ui'];
/**
@@ -22,50 +25,44 @@ class MigrateCommentTest extends MigrateDrupal7TestBase {
protected function setUp() {
parent::setUp();
- $this->installConfig(static::$modules);
$this->installEntitySchema('node');
$this->installEntitySchema('comment');
+ $this->installConfig(['comment', 'node']);
+ $this->installSchema('comment', ['comment_entity_statistics']);
$this->executeMigrations([
- 'd7_filter_format',
'd7_user_role',
'd7_user',
- ]);
- $this->executeMigration('d7_node_type');
- // We only need the test_content_type node migration to run for real, so
- // mock all the others.
- $this->prepareMigrations([
- 'd7_node' => [
- [[0], [0]],
- ],
- ]);
- $this->executeMigrations([
+ 'd7_node_type',
'd7_node',
'd7_comment_type',
+ 'd7_comment_field',
+ 'd7_comment_field_instance',
+ 'd7_comment_entity_display',
+ 'd7_comment_entity_form_display',
'd7_comment',
]);
}
/**
- * Tests migration of comments from Drupal 7.
+ * Tests the migrated comments.
*/
- public function testCommentMigration() {
+ public function testMigration() {
$comment = Comment::load(1);
- $this->assertTrue($comment instanceof CommentInterface);
- /** @var \Drupal\comment\CommentInterface $comment */
- $this->assertIdentical('A comment', $comment->getSubject());
- $this->assertIdentical('1421727536', $comment->getCreatedTime());
- $this->assertIdentical('1421727536', $comment->getChangedTime());
+ $this->assertInstanceOf(Comment::class, $comment);
+ $this->assertSame('A comment', $comment->getSubject());
+ $this->assertSame('1421727536', $comment->getCreatedTime());
+ $this->assertSame('1421727536', $comment->getChangedTime());
$this->assertTrue($comment->getStatus());
- $this->assertIdentical('admin', $comment->getAuthorName());
- $this->assertIdentical('admin@local.host', $comment->getAuthorEmail());
- $this->assertIdentical('This is a comment', $comment->comment_body->value);
- $this->assertIdentical('filtered_html', $comment->comment_body->format);
- $this->assertEquals('2001:db8:ffff:ffff:ffff:ffff:ffff:ffff', $comment->getHostname());
+ $this->assertSame('admin', $comment->getAuthorName());
+ $this->assertSame('admin@local.host', $comment->getAuthorEmail());
+ $this->assertSame('This is a comment', $comment->comment_body->value);
+ $this->assertSame('filtered_html', $comment->comment_body->format);
+ $this->assertSame('2001:db8:ffff:ffff:ffff:ffff:ffff:ffff', $comment->getHostname());
$node = $comment->getCommentedEntity();
- $this->assertTrue($node instanceof NodeInterface);
- $this->assertIdentical('1', $node->id());
+ $this->assertInstanceOf(NodeInterface::class, $node);
+ $this->assertSame('1', $node->id());
}
}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTypeTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTypeTest.php
index 8d2e576..b0c96da 100644
--- a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTypeTest.php
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTypeTest.php
@@ -2,29 +2,29 @@
namespace Drupal\Tests\comment\Kernel\Migrate\d7;
-use Drupal\comment\CommentTypeInterface;
use Drupal\comment\Entity\CommentType;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
- * Tests migration of comment types from Drupal 7.
+ * Tests the migration of comment types from Drupal 7.
*
* @group comment
+ * @group migrate_drupal_7
*/
class MigrateCommentTypeTest extends MigrateDrupal7TestBase {
- public static $modules = ['node', 'comment', 'text', 'menu_ui'];
+ /**
+ * {@inheritdoc}
+ */
+ public static $modules = ['node', 'comment', 'text'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(static::$modules);
- $this->executeMigrations([
- 'd7_node_type',
- 'd7_comment_type',
- ]);
+ $this->installConfig(['comment']);
+ $this->executeMigration('d7_comment_type');
}
/**
@@ -37,26 +37,21 @@ protected function setUp() {
*/
protected function assertEntity($id, $label) {
$entity = CommentType::load($id);
- $this->assertTrue($entity instanceof CommentTypeInterface);
- /** @var \Drupal\comment\CommentTypeInterface $entity */
- $this->assertIdentical($label, $entity->label());
- $this->assertIdentical('node', $entity->getTargetEntityTypeId());
+ $this->assertInstanceOf(CommentType::class, $entity);
+ $this->assertSame($label, $entity->label());
+ $this->assertSame('node', $entity->getTargetEntityTypeId());
}
/**
* Tests the migrated comment types.
*/
public function testMigration() {
- $this->assertEntity('comment_node_page', 'Basic page comment');
$this->assertEntity('comment_node_article', 'Article comment');
$this->assertEntity('comment_node_blog', 'Blog entry comment');
$this->assertEntity('comment_node_book', 'Book page comment');
$this->assertEntity('comment_forum', 'Forum topic comment');
+ $this->assertEntity('comment_node_page', 'Basic page comment');
$this->assertEntity('comment_node_test_content_type', 'Test content type comment');
-
- $migration = $this->getMigration('d7_comment_type');
- // Validate that the source count and processed count match up.
- $this->assertIdentical($migration->getSourcePlugin()->count(), $migration->getIdMap()->processedCount());
}
}
diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal7.php b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
index aa5d1a6..da9d467 100644
--- a/core/modules/migrate_drupal/tests/fixtures/drupal7.php
+++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
@@ -46146,7 +46146,7 @@
))
->values(array(
'name' => 'comment_subject_field_test_content_type',
- 'value' => 'i:1;',
+ 'value' => 'i:0;',
))
->values(array(
'name' => 'comment_test_content_type',
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php
index 993fdf4..d961faa 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php
@@ -40,18 +40,22 @@ protected function getEntityCounts() {
'block_content' => 2,
'block_content_type' => 1,
'comment' => 6,
- 'comment_type' => 3,
+ // The 'standard' profile provides the 'comment' comment type, and the
+ // migration creates 12 comment types, one per node type.
+ 'comment_type' => 13,
'contact_form' => 5,
'configurable_language' => 5,
'editor' => 2,
- 'field_config' => 72,
- 'field_storage_config' => 48,
+ 'field_config' => 84,
+ 'field_storage_config' => 58,
'file' => 7,
'filter_format' => 7,
'image_style' => 5,
'language_content_settings' => 2,
'migration' => 105,
'node' => 17,
+ // The 'book' module provides the 'book' node type, and the migration
+ // creates 12 node types.
'node_type' => 13,
'rdf_mapping' => 7,
'search_page' => 2,
@@ -67,9 +71,9 @@ protected function getEntityCounts() {
'menu_link_content' => 4,
'view' => 16,
'date_format' => 11,
- 'entity_form_display' => 19,
+ 'entity_form_display' => 29,
'entity_form_mode' => 1,
- 'entity_view_display' => 43,
+ 'entity_view_display' => 53,
'entity_view_mode' => 14,
'base_field_override' => 38,
];
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php
index a3ebb50..f22a9f7 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php
@@ -45,6 +45,8 @@ protected function getEntityCounts() {
'block_content' => 1,
'block_content_type' => 1,
'comment' => 1,
+ // The 'standard' profile provides the 'comment' comment type, and the
+ // migration creates 6 comment types, one per node type.
'comment_type' => 7,
// Module 'language' comes with 'en', 'und', 'zxx'. Migration adds 'is'.
'configurable_language' => 4,
diff --git a/core/modules/node/src/Plugin/migrate/source/d6/NodeType.php b/core/modules/node/src/Plugin/migrate/source/d6/NodeType.php
index 5ec0aae..c5caa12 100644
--- a/core/modules/node/src/Plugin/migrate/source/d6/NodeType.php
+++ b/core/modules/node/src/Plugin/migrate/source/d6/NodeType.php
@@ -63,7 +63,7 @@ public function query() {
* {@inheritdoc}
*/
public function fields() {
- return [
+ $fields = [
'type' => $this->t('Machine name of the node type.'),
'name' => $this->t('Human name of the node type.'),
'module' => $this->t('The module providing the node type.'),
@@ -79,6 +79,28 @@ public function fields() {
'orig_type' => $this->t('The original type.'),
'teaser_length' => $this->t('Teaser length'),
];
+ if ($this->moduleExists('comment')) {
+ $fields += $this->getCommentFields();
+ }
+ return $fields;
+ }
+
+ /**
+ * Returns the fields containing comment settings for each node type.
+ *
+ * @return string[]
+ * An associative array of field descriptions, keyed by field.
+ */
+ protected function getCommentFields() {
+ return [
+ 'comment' => $this->t('Default comment setting'),
+ 'comment_default_mode' => $this->t('Default display mode'),
+ 'comment_default_per_page' => $this->t('Default comments per page'),
+ 'comment_anonymous' => $this->t('Anonymous commenting'),
+ 'comment_subject_field' => $this->t('Comment subject field'),
+ 'comment_preview' => $this->t('Preview comment'),
+ 'comment_form_location' => $this->t('Location of comment submission form'),
+ ];
}
/**
@@ -112,6 +134,13 @@ public function prepareRow(Row $row) {
$row->setSourceProperty('available_menus', [$default_node_menu]);
$row->setSourceProperty('parent', $default_node_menu . ':');
}
+
+ if ($this->moduleExists('comment')) {
+ foreach (array_keys($this->getCommentFields()) as $field) {
+ $row->setSourceProperty($field, $this->variableGet($field . '_' . $type, NULL));
+ }
+ }
+
return parent::prepareRow($row);
}
diff --git a/core/modules/node/src/Plugin/migrate/source/d7/NodeType.php b/core/modules/node/src/Plugin/migrate/source/d7/NodeType.php
index 7f8290f..44f0b5e 100644
--- a/core/modules/node/src/Plugin/migrate/source/d7/NodeType.php
+++ b/core/modules/node/src/Plugin/migrate/source/d7/NodeType.php
@@ -54,6 +54,28 @@ public function fields() {
'orig_type' => $this->t('The original type.'),
'teaser_length' => $this->t('Teaser length'),
];
+ if ($this->moduleExists('comment')) {
+ $fields += $this->getCommentFields();
+ }
+ return $fields;
+ }
+
+ /**
+ * Returns the fields containing comment settings for each node type.
+ *
+ * @return string[]
+ * An associative array of field descriptions, keyed by field.
+ */
+ protected function getCommentFields() {
+ return [
+ 'comment' => $this->t('Default comment setting'),
+ 'comment_default_mode' => $this->t('Default display mode'),
+ 'comment_default_per_page' => $this->t('Default comments per page'),
+ 'comment_anonymous' => $this->t('Anonymous commenting'),
+ 'comment_subject_field' => $this->t('Comment subject field'),
+ 'comment_preview' => $this->t('Preview comment'),
+ 'comment_form_location' => $this->t('Location of comment submission form'),
+ ];
}
/**
@@ -107,6 +129,13 @@ public function prepareRow(Row $row) {
if ($parent = $this->variableGet('menu_parent_' . $type, NULL)) {
$row->setSourceProperty('parent', $parent . ':');
}
+
+ if ($this->moduleExists('comment')) {
+ foreach (array_keys($this->getCommentFields()) as $field) {
+ $row->setSourceProperty($field, $this->variableGet($field . '_' . $type, NULL));
+ }
+ }
+
return parent::prepareRow($row);
}
diff --git a/core/modules/node/tests/src/Kernel/Plugin/migrate/source/d6/NodeTypeTest.php b/core/modules/node/tests/src/Kernel/Plugin/migrate/source/d6/NodeTypeTest.php
index 38af680..9d59f43 100644
--- a/core/modules/node/tests/src/Kernel/Plugin/migrate/source/d6/NodeTypeTest.php
+++ b/core/modules/node/tests/src/Kernel/Plugin/migrate/source/d6/NodeTypeTest.php
@@ -57,9 +57,139 @@ public function providerSource() {
'orig_type' => 'story',
],
];
+ $tests[0]['source_data']['variable'] = [
+ [
+ 'name' => 'comment_anonymous_page',
+ 'value' => 'i:0;',
+ ],
+ [
+ 'name' => 'comment_anonymous_story',
+ 'value' => 'i:1;',
+ ],
+ [
+ 'name' => 'comment_default_mode_page',
+ 'value' => 'i:0;',
+ ],
+ [
+ 'name' => 'comment_default_mode_story',
+ 'value' => 'i:1;',
+ ],
+ [
+ 'name' => 'comment_default_per_page_page',
+ 'value' => 's:2:"10";',
+ ],
+ [
+ 'name' => 'comment_default_per_page_story',
+ 'value' => 's:2:"20";',
+ ],
+ [
+ 'name' => 'comment_form_location_page',
+ 'value' => 'i:0;',
+ ],
+ [
+ 'name' => 'comment_form_location_story',
+ 'value' => 'i:1;',
+ ],
+ [
+ 'name' => 'comment_page',
+ 'value' => 's:1:"0";',
+ ],
+ [
+ 'name' => 'comment_preview_page',
+ 'value' => 's:1:"0";',
+ ],
+ [
+ 'name' => 'comment_preview_story',
+ 'value' => 's:1:"1";',
+ ],
+ [
+ 'name' => 'comment_story',
+ 'value' => 's:1:"1";',
+ ],
+ [
+ 'name' => 'comment_subject_field_page',
+ 'value' => 'i:0;',
+ ],
+ [
+ 'name' => 'comment_subject_field_story',
+ 'value' => 'i:1;',
+ ],
+ [
+ 'name' => 'node_options_page',
+ 'value' => 'a:1:{i:0;s:6:"status";}',
+ ],
+ [
+ 'name' => 'node_options_story',
+ 'value' => 'a:1:{i:0;s:6:"status";}',
+ ],
+ ];
+ $tests[0]['source_data']['system'] = [
+ [
+ 'type' => 'module',
+ 'name' => 'comment',
+ 'status' => '1',
+ ],
+ ];
// The expected results.
- $tests[0]['expected_data'] = $tests[0]['source_data']['node_type'];
+ $tests[0]['expected_data'] = [
+ [
+ 'type' => 'page',
+ 'name' => 'Page',
+ 'module' => 'node',
+ 'description' => 'A page, similar in form to a story, is a simple method for creating and displaying information that rarely changes, such as an "About us" section of a website. By default, a page entry does not allow visitor comments and is not featured on the site\'s initial home page.',
+ 'help' => '',
+ 'title_label' => 'Title',
+ 'has_body' => 1,
+ 'body_label' => 'Body',
+ 'min_word_count' => 0,
+ 'custom' => 1,
+ 'modified' => 0,
+ 'locked' => 0,
+ 'orig_type' => 'page',
+ 'options' => [
+ 'promote' => FALSE,
+ 'sticky' => FALSE,
+ 'status' => TRUE,
+ 'revision' => FALSE,
+ ],
+ 'comment' => 0,
+ 'comment_default_mode' => 0,
+ 'comment_default_per_page' => '10',
+ 'comment_anonymous' => 0,
+ 'comment_subject_field' => 0,
+ 'comment_preview' => 0,
+ 'comment_form_location' => 0,
+ ],
+ [
+ 'type' => 'story',
+ 'name' => 'Story',
+ 'module' => 'node',
+ 'description' => 'A story, similar in form to a page, is ideal for creating and displaying content that informs or engages website visitors. Press releases, site announcements, and informal blog-like entries may all be created with a story entry. By default, a story entry is automatically featured on the site\'s initial home page, and provides the ability to post comments.',
+ 'help' => '',
+ 'title_label' => 'Title',
+ 'has_body' => 1,
+ 'body_label' => 'Body',
+ 'min_word_count' => 0,
+ 'custom' => 1,
+ 'modified' => 0,
+ 'locked' => 0,
+ 'orig_type' => 'story',
+ 'options' => [
+ 'promote' => FALSE,
+ 'sticky' => FALSE,
+ 'status' => TRUE,
+ 'revision' => FALSE,
+ ],
+ 'comment' => 1,
+ 'comment_default_mode' => 1,
+ 'comment_default_per_page' => '20',
+ 'comment_anonymous' => 1,
+ 'comment_subject_field' => 1,
+ 'comment_preview' => 1,
+ 'comment_form_location' => 1,
+ ],
+ ];
return $tests;
}
diff --git a/core/modules/node/tests/src/Kernel/Plugin/migrate/source/d7/NodeTypeTest.php b/core/modules/node/tests/src/Kernel/Plugin/migrate/source/d7/NodeTypeTest.php
index 1c738d1..5e876b7 100644
--- a/core/modules/node/tests/src/Kernel/Plugin/migrate/source/d7/NodeTypeTest.php
+++ b/core/modules/node/tests/src/Kernel/Plugin/migrate/source/d7/NodeTypeTest.php
@@ -55,6 +55,62 @@ public function providerSource() {
];
$tests[0]['source_data']['variable'] = [
[
+ 'name' => 'comment_anonymous_page',
+ 'value' => 'i:0;',
+ ],
+ [
+ 'name' => 'comment_anonymous_story',
+ 'value' => 'i:1;',
+ ],
+ [
+ 'name' => 'comment_default_mode_page',
+ 'value' => 'i:0;',
+ ],
+ [
+ 'name' => 'comment_default_mode_story',
+ 'value' => 'i:1;',
+ ],
+ [
+ 'name' => 'comment_default_per_page_page',
+ 'value' => 's:2:"10";',
+ ],
+ [
+ 'name' => 'comment_default_per_page_story',
+ 'value' => 's:2:"20";',
+ ],
+ [
+ 'name' => 'comment_form_location_page',
+ 'value' => 'i:0;',
+ ],
+ [
+ 'name' => 'comment_form_location_story',
+ 'value' => 'i:1;',
+ ],
+ [
+ 'name' => 'comment_page',
+ 'value' => 's:1:"0";',
+ ],
+ [
+ 'name' => 'comment_preview_page',
+ 'value' => 's:1:"0";',
+ ],
+ [
+ 'name' => 'comment_preview_story',
+ 'value' => 's:1:"1";',
+ ],
+ [
+ 'name' => 'comment_story',
+ 'value' => 's:1:"1";',
+ ],
+ [
+ 'name' => 'comment_subject_field_page',
+ 'value' => 'i:0;',
+ ],
+ [
+ 'name' => 'comment_subject_field_story',
+ 'value' => 'i:1;',
+ ],
+ [
'name' => 'node_options_page',
'value' => 'a:1:{i:0;s:6:"status";}',
],
@@ -77,9 +133,78 @@ public function providerSource() {
'data' => 'a:1:{s:5:"label";s:4:"Body";}',
],
];
+ $tests[0]['source_data']['system'] = [
+ [
+ 'type' => 'module',
+ 'name' => 'comment',
+ 'status' => '1',
+ ],
+ [
+ 'type' => 'module',
+ 'name' => 'field',
+ 'status' => '1',
+ ],
+ ];
// The expected results.
- $tests[0]['expected_data'] = $tests[0]['source_data']['node_type'];
+ $tests[0]['expected_data'] = [
+ [
+ 'type' => 'page',
+ 'name' => 'Page',
+ 'base' => 'node',
+ 'description' => 'A page, similar in form to a story, is a simple method for creating and displaying information that rarely changes, such as an "About us" section of a website. By default, a page entry does not allow visitor comments and is not featured on the site\'s initial home page.',
+ 'help' => '',
+ 'title_label' => 'Title',
+ 'custom' => 1,
+ 'modified' => 0,
+ 'locked' => 0,
+ 'disabled' => 0,
+ 'orig_type' => 'page',
+ 'options' => [
+ 'promote' => FALSE,
+ 'sticky' => FALSE,
+ 'status' => TRUE,
+ 'revision' => FALSE,
+ ],
+ 'create_body' => TRUE,
+ 'body_label' => 'Body',
+ 'comment' => 0,
+ 'comment_default_mode' => 0,
+ 'comment_default_per_page' => '10',
+ 'comment_anonymous' => 0,
+ 'comment_subject_field' => 0,
+ 'comment_preview' => 0,
+ 'comment_form_location' => 0,
+ ],
+ [
+ 'type' => 'story',
+ 'name' => 'Story',
+ 'base' => 'node',
+ 'description' => 'A story, similar in form to a page, is ideal for creating and displaying content that informs or engages website visitors. Press releases, site announcements, and informal blog-like entries may all be created with a story entry. By default, a story entry is automatically featured on the site\'s initial home page, and provides the ability to post comments.',
+ 'help' => '',
+ 'title_label' => 'Title',
+ 'custom' => 1,
+ 'modified' => 0,
+ 'locked' => 0,
+ 'disabled' => 0,
+ 'orig_type' => 'story',
+ 'options' => [
+ 'promote' => FALSE,
+ 'sticky' => FALSE,
+ 'status' => TRUE,
+ 'revision' => FALSE,
+ ],
+ 'create_body' => TRUE,
+ 'body_label' => 'Body',
+ 'comment' => 1,
+ 'comment_default_mode' => 1,
+ 'comment_default_per_page' => '20',
+ 'comment_anonymous' => 1,
+ 'comment_subject_field' => 1,
+ 'comment_preview' => 1,
+ 'comment_form_location' => 1,
+ ],
+ ];
return $tests;
}