public function MigrateFieldWidgetSettingsTest::testWidgetSettings in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/field/src/Tests/Migrate/d6/MigrateFieldWidgetSettingsTest.php \Drupal\field\Tests\Migrate\d6\MigrateFieldWidgetSettingsTest::testWidgetSettings()
Test that migrated view modes can be loaded using D8 API's.
File
- core/
modules/ field/ src/ Tests/ Migrate/ d6/ MigrateFieldWidgetSettingsTest.php, line 31 - Contains \Drupal\field\Tests\Migrate\d6\MigrateFieldWidgetSettingsTest.
Class
- MigrateFieldWidgetSettingsTest
- Migrate field widget settings.
Namespace
Drupal\field\Tests\Migrate\d6Code
public function testWidgetSettings() {
// Test the config can be loaded.
$form_display = EntityFormDisplay::load('node.story.default');
$this
->assertIdentical(FALSE, is_null($form_display), "Form display node.story.default loaded with config.");
// Text field.
$component = $form_display
->getComponent('field_test');
$expected = array(
'weight' => 1,
'type' => 'text_textfield',
);
$expected['settings'] = array(
'size' => 60,
'placeholder' => '',
);
$expected['third_party_settings'] = array();
$this
->assertIdentical($expected, $component, 'Text field settings are correct.');
// Integer field.
$component = $form_display
->getComponent('field_test_two');
$expected['type'] = 'number';
$expected['weight'] = 1;
$expected['settings'] = array(
'placeholder' => '',
);
$this
->assertIdentical($expected, $component);
// Float field.
$component = $form_display
->getComponent('field_test_three');
$expected['weight'] = 2;
$this
->assertIdentical($expected, $component);
// Email field.
$component = $form_display
->getComponent('field_test_email');
$expected['type'] = 'email_default';
$expected['weight'] = 6;
$this
->assertIdentical($expected, $component);
// Link field.
$component = $form_display
->getComponent('field_test_link');
$this
->assertIdentical('link_default', $component['type']);
$this
->assertIdentical(7, $component['weight']);
$this
->assertFalse(array_filter($component['settings']));
// File field.
$component = $form_display
->getComponent('field_test_filefield');
$expected['type'] = 'file_generic';
$expected['weight'] = 8;
$expected['settings'] = array(
'progress_indicator' => 'bar',
);
$this
->assertIdentical($expected, $component);
// Image field.
$component = $form_display
->getComponent('field_test_imagefield');
$expected['type'] = 'image_image';
$expected['weight'] = 9;
$expected['settings'] = array(
'progress_indicator' => 'bar',
'preview_image_style' => 'thumbnail',
);
$this
->assertIdentical($expected, $component);
// Phone field.
$component = $form_display
->getComponent('field_test_phone');
$expected['type'] = 'telephone_default';
$expected['weight'] = 13;
$expected['settings'] = array(
'placeholder' => '',
);
$this
->assertIdentical($expected, $component);
// Date fields.
$component = $form_display
->getComponent('field_test_date');
$expected['type'] = 'datetime_default';
$expected['weight'] = 10;
$expected['settings'] = array();
$this
->assertIdentical($expected, $component);
$component = $form_display
->getComponent('field_test_datestamp');
$expected['weight'] = 11;
$this
->assertIdentical($expected, $component);
$component = $form_display
->getComponent('field_test_datetime');
$expected['weight'] = 12;
$this
->assertIdentical($expected, $component);
}