Pull merge.
[yaffs-website] / web / core / modules / comment / tests / src / Kernel / Migrate / d7 / MigrateCommentTypeTest.php
1 <?php
2
3 namespace Drupal\Tests\comment\Kernel\Migrate\d7;
4
5 use Drupal\comment\Entity\CommentType;
6 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
7
8 /**
9  * Tests the migration of comment types from Drupal 7.
10  *
11  * @group comment
12  * @group migrate_drupal_7
13  */
14 class MigrateCommentTypeTest extends MigrateDrupal7TestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = ['node', 'comment', 'text'];
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function setUp() {
25     parent::setUp();
26     $this->installConfig(['comment']);
27     $this->executeMigration('d7_comment_type');
28   }
29
30   /**
31    * Asserts a comment type entity.
32    *
33    * @param string $id
34    *   The entity ID.
35    * @param string $label
36    *   The entity label.
37    */
38   protected function assertEntity($id, $label) {
39     $entity = CommentType::load($id);
40     $this->assertInstanceOf(CommentType::class, $entity);
41     $this->assertSame($label, $entity->label());
42     $this->assertSame('node', $entity->getTargetEntityTypeId());
43   }
44
45   /**
46    * Tests the migrated comment types.
47    */
48   public function testMigration() {
49     $comment_fields = [
50       'comment' => 'Default comment setting',
51       'comment_default_mode' => 'Default display mode',
52       'comment_default_per_page' => 'Default comments per page',
53       'comment_anonymous' => 'Anonymous commenting',
54       'comment_subject_field' => 'Comment subject field',
55       'comment_preview' => 'Preview comment',
56       'comment_form_location' => 'Location of comment submission form',
57     ];
58     $this->assertArraySubset($comment_fields, $this->migration->getSourcePlugin()->fields());
59
60     $this->assertEntity('comment_node_article', 'Article comment');
61     $this->assertEntity('comment_node_blog', 'Blog entry comment');
62     $this->assertEntity('comment_node_book', 'Book page comment');
63     $this->assertEntity('comment_forum', 'Forum topic comment');
64     $this->assertEntity('comment_node_page', 'Basic page comment');
65     $this->assertEntity('comment_node_test_content_type', 'Test content type comment');
66   }
67
68 }