Version 1
[yaffs-website] / web / core / modules / comment / tests / src / Kernel / Migrate / d7 / MigrateCommentEntityDisplayTest.php
1 <?php
2
3 namespace Drupal\Tests\comment\Kernel\Migrate\d7;
4
5 use Drupal\Core\Entity\Entity\EntityViewDisplay;
6 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
7
8 /**
9  * Tests migration of comment display configuration.
10  *
11  * @group comment
12  */
13 class MigrateCommentEntityDisplayTest extends MigrateDrupal7TestBase {
14
15   public static $modules = ['node', 'comment', 'text', 'menu_ui'];
16
17   /**
18    * {@inheritdoc}
19    */
20   protected function setUp() {
21     parent::setUp();
22     $this->installConfig(static::$modules);
23     $this->executeMigrations([
24       'd7_node_type',
25       'd7_comment_type',
26       'd7_comment_field',
27       'd7_comment_field_instance',
28       'd7_comment_entity_display',
29     ]);
30   }
31
32   /**
33    * Asserts a display entity.
34    *
35    * @param string $id
36    *   The entity ID.
37    * @param string $component_id
38    *   The ID of the display component.
39    */
40   protected function assertDisplay($id, $component_id) {
41     $component = EntityViewDisplay::load($id)->getComponent($component_id);
42     $this->assertTrue(is_array($component));
43     $this->assertIdentical('hidden', $component['label']);
44     $this->assertIdentical('comment_default', $component['type']);
45     $this->assertIdentical(20, $component['weight']);
46   }
47
48   /**
49    * Tests the migrated display configuration.
50    */
51   public function testMigration() {
52     $this->assertDisplay('node.page.default', 'comment_node_page');
53     $this->assertDisplay('node.article.default', 'comment_node_article');
54     $this->assertDisplay('node.book.default', 'comment_node_book');
55     $this->assertDisplay('node.blog.default', 'comment_node_blog');
56     $this->assertDisplay('node.forum.default', 'comment_node_forum');
57     $this->assertDisplay('node.test_content_type.default', 'comment_node_test_content_type');
58   }
59
60 }