Version 1
[yaffs-website] / web / core / modules / comment / tests / src / Kernel / Migrate / d7 / MigrateCommentEntityFormDisplayTest.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 migration of comment form display configuration.
10  *
11  * @group comment
12  */
13 class MigrateCommentEntityFormDisplayTest 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_form_display',
29     ]);
30   }
31
32   /**
33    * Asserts a display entity.
34    *
35    * @param string $id
36    *   The entity ID.
37    * @param string $component
38    *   The ID of the form component.
39    */
40   protected function assertDisplay($id, $component_id) {
41     $component = EntityFormDisplay::load($id)->getComponent($component_id);
42     $this->assertTrue(is_array($component));
43     $this->assertIdentical('comment_default', $component['type']);
44     $this->assertIdentical(20, $component['weight']);
45   }
46
47   /**
48    * Tests the migrated display configuration.
49    */
50   public function testMigration() {
51     $this->assertDisplay('node.page.default', 'comment');
52     $this->assertDisplay('node.article.default', 'comment');
53     $this->assertDisplay('node.book.default', 'comment');
54     $this->assertDisplay('node.blog.default', 'comment');
55     $this->assertDisplay('node.forum.default', 'comment');
56     $this->assertDisplay('node.test_content_type.default', 'comment');
57   }
58
59 }