Same name and namespace in other branches
  1. 8.9.x core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldWidgetSettingsTest.php \Drupal\Tests\field\Kernel\Migrate\d6\MigrateFieldWidgetSettingsTest
  2. 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

Expanded class hierarchy of MigrateFieldWidgetSettingsTest

File

core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldWidgetSettingsTest.php, line 15

Namespace

Drupal\Tests\field\Kernel\Migrate\d6
View 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

Namesort descending Modifiers Type Description Overrides
MigrateDrupal6TestBase::getFixtureFilePath protected function Gets the path to the fixture file. 13
MigrateDrupal6TestBase::migrateContent protected function Executes all content migrations.
MigrateDrupal6TestBase::migrateContentTypes protected function Migrates node types.
MigrateDrupal6TestBase::migrateFields protected function Executes all field migrations.
MigrateDrupal6TestBase::migrateTaxonomy protected function Executes all taxonomy migrations.
MigrateDrupal6TestBase::migrateUsers protected function Executes all user migrations.
MigrateDrupalTestBase::loadFixture protected function Loads a database fixture into the source database connection.
MigrateFieldWidgetSettingsTest::$modules protected static property Modules to enable. Overrides MigrateDrupal6TestBase::$modules
MigrateFieldWidgetSettingsTest::setUp protected function Overrides MigrateDrupal6TestBase::setUp
MigrateFieldWidgetSettingsTest::testWidgetSettings public function Tests that migrated view modes can be loaded using D8 API's.
MigrateTestBase::$collectMessages protected property TRUE to collect messages instead of displaying them.
MigrateTestBase::$logger protected property A logger prophecy object. 2
MigrateTestBase::$migrateMessages protected property A two dimensional array of messages.
MigrateTestBase::$migration protected property The primary migration being tested. 1
MigrateTestBase::$sourceDatabase protected property The source database connection.
MigrateTestBase::cleanupMigrateConnection private function Cleans up the test migrate connection.
MigrateTestBase::createMigrationConnection private function Changes the database connection to the prefixed one.
MigrateTestBase::display public function Displays a migrate message. Overrides MigrateMessageInterface::display
MigrateTestBase::executeMigration protected function Executes a single migration.
MigrateTestBase::executeMigrations protected function Executes a set of migrations in dependency order.
MigrateTestBase::getMigration protected function Gets the migration plugin.
MigrateTestBase::mockFailure protected function Records a failure in the map table of a specific migration.
MigrateTestBase::prepareMigration protected function Modify a migration's configuration before executing it.
MigrateTestBase::prepareMigrations protected function Prepare any dependent migrations.
MigrateTestBase::setTestLogger protected function Injects the test logger into the container.
MigrateTestBase::startCollectingMessages public function Start collecting messages and erase previous messages.
MigrateTestBase::stopCollectingMessages public function Stop collecting messages.
MigrateTestBase::tearDown protected function
NodeMigrateTypeTestTrait::$tableName public property The migrate_map table name.
NodeMigrateTypeTestTrait::getTableName protected function Gets the migrate_map table name.
NodeMigrateTypeTestTrait::makeNodeMigrateMapTable protected function Create a node migrate_map table.
NodeMigrateTypeTestTrait::nodeMigrateMapTableCount protected function Gets the numbers of complete and classic node migrate_map tables.
NodeMigrateTypeTestTrait::removeNodeMigrateMapTable protected function Remove the node migrate map table.