3 namespace Drupal\Tests\field\Kernel\Migrate\d6;
5 use Drupal\Core\Entity\Entity\EntityFormDisplay;
6 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
9 * Migrate field widget settings.
11 * @group migrate_drupal_6
13 class MigrateFieldWidgetSettingsTest extends MigrateDrupal6TestBase {
18 public static $modules = ['menu_ui'];
23 protected function setUp() {
25 $this->migrateFields();
29 * Test that migrated view modes can be loaded using D8 API's.
31 public function testWidgetSettings() {
32 // Test the config can be loaded.
33 $form_display = EntityFormDisplay::load('node.story.default');
34 $this->assertIdentical(FALSE, is_null($form_display), "Form display node.story.default loaded with config.");
37 $component = $form_display->getComponent('field_test');
38 $expected = ['weight' => 1, 'type' => 'text_textfield'];
39 $expected['settings'] = ['size' => 60, 'placeholder' => ''];
40 $expected['third_party_settings'] = [];
41 $expected['region'] = 'content';
42 $this->assertIdentical($expected, $component, 'Text field settings are correct.');
45 $component = $form_display->getComponent('field_test_two');
46 $expected['type'] = 'number';
47 $expected['weight'] = 1;
48 $expected['settings'] = ['placeholder' => ''];
49 $this->assertIdentical($expected, $component);
52 $component = $form_display->getComponent('field_test_three');
53 $expected['weight'] = 2;
54 $this->assertIdentical($expected, $component);
57 $component = $form_display->getComponent('field_test_email');
58 $expected['type'] = 'email_default';
59 $expected['weight'] = 6;
60 $expected['settings'] = ['placeholder' => '', 'size' => 60];
61 $this->assertIdentical($expected, $component);
64 $component = $form_display->getComponent('field_test_link');
65 $this->assertIdentical('link_default', $component['type']);
66 $this->assertIdentical(7, $component['weight']);
67 $this->assertFalse(array_filter($component['settings']));
70 $component = $form_display->getComponent('field_test_filefield');
71 $expected['type'] = 'file_generic';
72 $expected['weight'] = 8;
73 $expected['settings'] = ['progress_indicator' => 'bar'];
74 $this->assertIdentical($expected, $component);
77 $component = $form_display->getComponent('field_test_imagefield');
78 $expected['type'] = 'image_image';
79 $expected['weight'] = 9;
80 $expected['settings'] = ['progress_indicator' => 'bar', 'preview_image_style' => 'thumbnail'];
81 $this->assertIdentical($expected, $component);
84 $component = $form_display->getComponent('field_test_phone');
85 $expected['type'] = 'telephone_default';
86 $expected['weight'] = 13;
87 $expected['settings'] = ['placeholder' => ''];
88 $this->assertIdentical($expected, $component);
91 $component = $form_display->getComponent('field_test_date');
92 $expected['type'] = 'datetime_default';
93 $expected['weight'] = 10;
94 $expected['settings'] = [];
95 $this->assertIdentical($expected, $component);
97 $component = $form_display->getComponent('field_test_datestamp');
98 $expected['weight'] = 11;
99 $this->assertIdentical($expected, $component);
101 $component = $form_display->getComponent('field_test_datetime');
102 $expected['weight'] = 12;
103 $this->assertIdentical($expected, $component);
105 $component = entity_get_form_display('node', 'employee', 'default')
106 ->getComponent('field_company');
107 $this->assertInternalType('array', $component);
108 $this->assertSame('options_select', $component['type']);
110 $component = entity_get_form_display('node', 'employee', 'default')
111 ->getComponent('field_company_2');
112 $this->assertInternalType('array', $component);
113 $this->assertSame('options_buttons', $component['type']);
115 $component = entity_get_form_display('node', 'employee', 'default')
116 ->getComponent('field_company_3');
117 $this->assertInternalType('array', $component);
118 $this->assertSame('entity_reference_autocomplete_tags', $component['type']);
120 $component = entity_get_form_display('node', 'employee', 'default')
121 ->getComponent('field_commander');
122 $this->assertInternalType('array', $component);
123 $this->assertSame('options_select', $component['type']);