Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / comment / tests / src / Kernel / Migrate / d7 / MigrateCommentEntityFormDisplaySubjectTest.php
1 <?php
2
3 namespace Drupal\Tests\comment\Kernel\Migrate\d7;
4
5 use Drupal\Core\Entity\Entity\EntityFormDisplay;
6 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
7
8 /**
9  * Tests the migration of comment form's subject display from Drupal 7.
10  *
11  * @group comment
12  * @group migrate_drupal_7
13  */
14 class MigrateCommentEntityFormDisplaySubjectTest extends MigrateDrupal7TestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = ['node', 'comment', 'text', 'menu_ui'];
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_entity_form_display_subject',
30     ]);
31   }
32
33   /**
34    * Asserts that the comment subject field is visible for a node type.
35    *
36    * @param string $id
37    *   The entity form display ID.
38    */
39   protected function assertSubjectVisible($id) {
40     $component = EntityFormDisplay::load($id)->getComponent('subject');
41     $this->assertInternalType('array', $component);
42     $this->assertSame('string_textfield', $component['type']);
43     $this->assertSame(10, $component['weight']);
44   }
45
46   /**
47    * Asserts that the comment subject field is not visible for a node type.
48    *
49    * @param string $id
50    *   The entity form display ID.
51    */
52   protected function assertSubjectNotVisible($id) {
53     $component = EntityFormDisplay::load($id)->getComponent('subject');
54     $this->assertNull($component);
55   }
56
57   /**
58    * Tests the migrated display configuration.
59    */
60   public function testMigration() {
61     $this->assertSubjectVisible('comment.comment_node_page.default');
62     $this->assertSubjectVisible('comment.comment_node_article.default');
63     $this->assertSubjectVisible('comment.comment_node_book.default');
64     $this->assertSubjectVisible('comment.comment_node_blog.default');
65     $this->assertSubjectVisible('comment.comment_forum.default');
66     $this->assertSubjectNotVisible('comment.comment_node_test_content_type.default');
67   }
68
69 }