Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / comment / tests / src / Kernel / Migrate / d7 / MigrateCommentFieldTest.php
1 <?php
2
3 namespace Drupal\Tests\comment\Kernel\Migrate\d7;
4
5 use Drupal\field\Entity\FieldStorageConfig;
6 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
7
8 /**
9  * Tests the migration of comment fields from Drupal 7.
10  *
11  * @group comment
12  * @group migrate_drupal_7
13  */
14 class MigrateCommentFieldTest 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->executeMigrations([
28       'd7_comment_type',
29       'd7_comment_field',
30     ]);
31   }
32
33   /**
34    * Asserts a comment field entity.
35    *
36    * @param string $comment_type
37    *   The comment type.
38    */
39   protected function assertEntity($comment_type) {
40     $entity = FieldStorageConfig::load('node.' . $comment_type);
41     $this->assertInstanceOf(FieldStorageConfig::class, $entity);
42     $this->assertSame('node', $entity->getTargetEntityTypeId());
43     $this->assertSame('comment', $entity->getType());
44     $this->assertSame($comment_type, $entity->getSetting('comment_type'));
45   }
46
47   /**
48    * Tests the migrated comment fields.
49    */
50   public function testMigration() {
51     $this->assertEntity('comment_node_page');
52     $this->assertEntity('comment_node_article');
53     $this->assertEntity('comment_node_blog');
54     $this->assertEntity('comment_node_book');
55     $this->assertEntity('comment_forum');
56     $this->assertEntity('comment_node_test_content_type');
57   }
58
59 }