diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableDisplayBase.php b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableDisplayBase.php new file mode 100644 index 0000000000..964185b589 --- /dev/null +++ b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableDisplayBase.php @@ -0,0 +1,31 @@ +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 new file mode 100644 index 0000000000..a98c374bed --- /dev/null +++ b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableEntityDisplayTest.php @@ -0,0 +1,41 @@ +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 new file mode 100644 index 0000000000..6e74bb9949 --- /dev/null +++ b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableEntityFormDisplaySubjectTest.php @@ -0,0 +1,47 @@ +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 new file mode 100644 index 0000000000..e7432ca107 --- /dev/null +++ b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableEntityFormDisplayTest.php @@ -0,0 +1,41 @@ +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 new file mode 100644 index 0000000000..74169b084b --- /dev/null +++ b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableFieldTest.php @@ -0,0 +1,39 @@ +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 new file mode 100644 index 0000000000..5822a86594 --- /dev/null +++ b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentVariableInstanceTest.php @@ -0,0 +1,62 @@ +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']); + } + +}