1<?php
2
3namespace Drupal\Tests\user\Kernel\Migrate\d6;
4
5use Drupal\Core\Entity\Entity\EntityFormDisplay;
6use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
7
8/**
9 * Tests the user profile entity form display migration.
10 *
11 * @group migrate_drupal_6
12 */
13class MigrateUserProfileEntityFormDisplayTest extends MigrateDrupal6TestBase {
14
15  /**
16   * {@inheritdoc}
17   */
18  protected function setUp(): void {
19    parent::setUp();
20    $this->executeMigrations([
21      'user_profile_field',
22      'user_profile_field_instance',
23      'user_profile_entity_form_display',
24    ]);
25  }
26
27  /**
28   * Tests migration of user profile fields.
29   */
30  public function testUserProfileEntityFormDisplay() {
31    $display = EntityFormDisplay::load('user.user.default');
32
33    // Test a text field.
34    $component = $display->getComponent('profile_color');
35    $this->assertSame('text_textfield', $component['type']);
36
37    // Test a list field.
38    $component = $display->getComponent('profile_bands');
39    $this->assertSame('text_textfield', $component['type']);
40
41    // Test a date field.
42    $component = $display->getComponent('profile_birthdate');
43    $this->assertSame('datetime_default', $component['type']);
44
45    // Test PROFILE_PRIVATE field is hidden.
46    $this->assertNull($display->getComponent('profile_sell_address'));
47
48    // Test PROFILE_HIDDEN field is hidden.
49    $this->assertNull($display->getComponent('profile_sold_to'));
50
51    // Test that a checkbox field has the proper display label setting.
52    $component = $display->getComponent('profile_really_really_love_mig');
53    $this->assertSame('boolean_checkbox', $component['type']);
54    $this->assertTrue($component['settings']['display_label']);
55  }
56
57}
58