2c13371fb8a54186f244e0cbf3716f123925659a
[yaffs-website] / web / core / modules / comment / tests / src / Kernel / Migrate / d6 / MigrateCommentEntityDisplayTest.php
1 <?php
2
3 namespace Drupal\Tests\comment\Kernel\Migrate\d6;
4
5 use Drupal\Core\Entity\Entity\EntityViewDisplay;
6 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
7
8 /**
9  * Tests the migration of comment entity displays from Drupal 6.
10  *
11  * @group comment
12  * @group migrate_drupal_6
13  */
14 class MigrateCommentEntityDisplayTest extends MigrateDrupal6TestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = ['comment', 'menu_ui'];
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function setUp() {
25     parent::setUp();
26     $this->installConfig(['comment']);
27     $this->migrateContentTypes();
28     $this->executeMigrations([
29       'd6_node_type',
30       'd6_comment_type',
31       'd6_comment_field',
32       'd6_comment_field_instance',
33       'd6_comment_entity_display',
34     ]);
35   }
36
37   /**
38    * Asserts various aspects of a comment component in an entity view display.
39    *
40    * @param string $id
41    *   The entity ID.
42    * @param string $component_id
43    *   The ID of the display component.
44    */
45   protected function assertDisplay($id, $component_id) {
46     $component = EntityViewDisplay::load($id)->getComponent($component_id);
47     $this->assertInternalType('array', $component);
48     $this->assertSame('hidden', $component['label']);
49     $this->assertSame('comment_default', $component['type']);
50     $this->assertSame(20, $component['weight']);
51   }
52
53   /**
54    * Tests the migrated display configuration.
55    */
56   public function testMigration() {
57     $this->assertDisplay('node.article.default', 'comment_node_article');
58     $this->assertDisplay('node.company.default', 'comment_node_company');
59     $this->assertDisplay('node.employee.default', 'comment_node_employee');
60     $this->assertDisplay('node.event.default', 'comment_node_event');
61     $this->assertDisplay('node.forum.default', 'comment_forum');
62     $this->assertDisplay('node.page.default', 'comment_node_page');
63     $this->assertDisplay('node.sponsor.default', 'comment_node_sponsor');
64     $this->assertDisplay('node.story.default', 'comment_node_story');
65     $this->assertDisplay('node.test_event.default', 'comment_node_test_event');
66     $this->assertDisplay('node.test_page.default', 'comment_node_test_page');
67     $this->assertDisplay('node.test_planet.default', 'comment_node_test_planet');
68     $this->assertDisplay('node.test_story.default', 'comment_node_test_story');
69   }
70
71 }