Same name and namespace in other branches
- 8.9.x core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldWidgetSettingsTest.php \Drupal\Tests\field\Kernel\Migrate\d6\MigrateFieldWidgetSettingsTest
- 9 core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldWidgetSettingsTest.php \Drupal\Tests\field\Kernel\Migrate\d6\MigrateFieldWidgetSettingsTest
Migrate field widget settings.
@group migrate_drupal_6
Hierarchy
- class \Drupal\Tests\migrate\Kernel\MigrateTestBase extends \Drupal\KernelTests\KernelTestBase implements MigrateMessageInterface
- class \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase
- class \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase uses NodeMigrateTypeTestTrait
- class \Drupal\Tests\field\Kernel\Migrate\d6\MigrateFieldWidgetSettingsTest
- class \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase uses NodeMigrateTypeTestTrait
- class \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase
Expanded class hierarchy of MigrateFieldWidgetSettingsTest
File
- core/
modules/ field/ tests/ src/ Kernel/ Migrate/ d6/ MigrateFieldWidgetSettingsTest.php, line 15
Namespace
Drupal\Tests\field\Kernel\Migrate\d6View source
class MigrateFieldWidgetSettingsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'comment',
'menu_ui',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this
->installConfig([
'comment',
]);
$this
->executeMigration('d6_comment_type');
$this
->migrateFields();
}
/**
* Tests that migrated view modes can be loaded using D8 API's.
*/
public function testWidgetSettings() {
// Test the config can be loaded.
$form_display = EntityFormDisplay::load('node.story.default');
$this
->assertNotNull($form_display);
// Text field.
$component = $form_display
->getComponent('field_test');
$expected = [
'type' => 'text_textfield',
'weight' => 1,
'region' => 'content',
'settings' => [
'size' => 60,
'placeholder' => '',
],
'third_party_settings' => [],
];
$this
->assertSame($expected, $component, 'Text field settings are correct.');
// Integer field.
$component = $form_display
->getComponent('field_test_two');
$expected['type'] = 'number';
$expected['weight'] = 1;
$expected['settings'] = [
'placeholder' => '',
];
$this
->assertSame($expected, $component);
// Float field.
$component = $form_display
->getComponent('field_test_three');
$expected['weight'] = 2;
$this
->assertSame($expected, $component);
// Email field.
$component = $form_display
->getComponent('field_test_email');
$expected['type'] = 'email_default';
$expected['weight'] = 6;
$expected['settings'] = [
'placeholder' => '',
'size' => 60,
];
$this
->assertSame($expected, $component);
// Link field.
$component = $form_display
->getComponent('field_test_link');
$this
->assertSame('link_default', $component['type']);
$this
->assertSame(7, $component['weight']);
$this
->assertEmpty(array_filter($component['settings']));
// File field.
$component = $form_display
->getComponent('field_test_filefield');
$expected['type'] = 'file_generic';
$expected['weight'] = 8;
$expected['settings'] = [
'progress_indicator' => 'bar',
];
$this
->assertSame($expected, $component);
// Image field.
$component = $form_display
->getComponent('field_test_imagefield');
$expected['type'] = 'image_image';
$expected['weight'] = 9;
$expected['settings'] = [
'progress_indicator' => 'bar',
'preview_image_style' => 'thumbnail',
];
$this
->assertSame($expected, $component);
// Phone field.
$component = $form_display
->getComponent('field_test_phone');
$expected['type'] = 'telephone_default';
$expected['weight'] = 13;
$expected['settings'] = [
'placeholder' => '',
];
$this
->assertSame($expected, $component);
// Date fields.
$component = $form_display
->getComponent('field_test_date');
$expected['type'] = 'datetime_default';
$expected['weight'] = 10;
$expected['settings'] = [];
$this
->assertSame($expected, $component);
$component = $form_display
->getComponent('field_test_datestamp');
$expected['weight'] = 11;
$this
->assertSame($expected, $component);
$component = $form_display
->getComponent('field_test_datetime');
$expected['weight'] = 12;
$this
->assertSame($expected, $component);
/** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
$display_repository = \Drupal::service('entity_display.repository');
$component = $display_repository
->getFormDisplay('node', 'employee', 'default')
->getComponent('field_company');
$this
->assertIsArray($component);
$this
->assertSame('options_select', $component['type']);
$component = $display_repository
->getFormDisplay('node', 'employee', 'default')
->getComponent('field_company_2');
$this
->assertIsArray($component);
$this
->assertSame('options_buttons', $component['type']);
$component = $display_repository
->getFormDisplay('node', 'employee', 'default')
->getComponent('field_company_3');
$this
->assertIsArray($component);
$this
->assertSame('entity_reference_autocomplete_tags', $component['type']);
$component = $display_repository
->getFormDisplay('node', 'employee', 'default')
->getComponent('field_company_4');
$this
->assertIsArray($component);
$this
->assertSame('entity_reference_autocomplete', $component['type']);
$component = $display_repository
->getFormDisplay('node', 'employee', 'default')
->getComponent('field_commander');
$this
->assertIsArray($component);
$this
->assertSame('options_select', $component['type']);
$component = $display_repository
->getFormDisplay('comment', 'comment_node_a_thirty_two_char', 'default')
->getComponent('comment_body');
$this
->assertIsArray($component);
$this
->assertSame('text_textarea', $component['type']);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MigrateDrupal6TestBase:: |
protected | function | Gets the path to the fixture file. | 13 |
MigrateDrupal6TestBase:: |
protected | function | Executes all content migrations. | |
MigrateDrupal6TestBase:: |
protected | function | Migrates node types. | |
MigrateDrupal6TestBase:: |
protected | function | Executes all field migrations. | |
MigrateDrupal6TestBase:: |
protected | function | Executes all taxonomy migrations. | |
MigrateDrupal6TestBase:: |
protected | function | Executes all user migrations. | |
MigrateDrupalTestBase:: |
protected | function | Loads a database fixture into the source database connection. | |
MigrateFieldWidgetSettingsTest:: |
protected static | property |
Modules to enable. Overrides MigrateDrupal6TestBase:: |
|
MigrateFieldWidgetSettingsTest:: |
protected | function |
Overrides MigrateDrupal6TestBase:: |
|
MigrateFieldWidgetSettingsTest:: |
public | function | Tests that migrated view modes can be loaded using D8 API's. | |
MigrateTestBase:: |
protected | property | TRUE to collect messages instead of displaying them. | |
MigrateTestBase:: |
protected | property | A logger prophecy object. | 2 |
MigrateTestBase:: |
protected | property | A two dimensional array of messages. | |
MigrateTestBase:: |
protected | property | The primary migration being tested. | 1 |
MigrateTestBase:: |
protected | property | The source database connection. | |
MigrateTestBase:: |
private | function | Cleans up the test migrate connection. | |
MigrateTestBase:: |
private | function | Changes the database connection to the prefixed one. | |
MigrateTestBase:: |
public | function |
Displays a migrate message. Overrides MigrateMessageInterface:: |
|
MigrateTestBase:: |
protected | function | Executes a single migration. | |
MigrateTestBase:: |
protected | function | Executes a set of migrations in dependency order. | |
MigrateTestBase:: |
protected | function | Gets the migration plugin. | |
MigrateTestBase:: |
protected | function | Records a failure in the map table of a specific migration. | |
MigrateTestBase:: |
protected | function | Modify a migration's configuration before executing it. | |
MigrateTestBase:: |
protected | function | Prepare any dependent migrations. | |
MigrateTestBase:: |
protected | function | Injects the test logger into the container. | |
MigrateTestBase:: |
public | function | Start collecting messages and erase previous messages. | |
MigrateTestBase:: |
public | function | Stop collecting messages. | |
MigrateTestBase:: |
protected | function | ||
NodeMigrateTypeTestTrait:: |
public | property | The migrate_map table name. | |
NodeMigrateTypeTestTrait:: |
protected | function | Gets the migrate_map table name. | |
NodeMigrateTypeTestTrait:: |
protected | function | Create a node migrate_map table. | |
NodeMigrateTypeTestTrait:: |
protected | function | Gets the numbers of complete and classic node migrate_map tables. | |
NodeMigrateTypeTestTrait:: |
protected | function | Remove the node migrate map table. |