You are here

protected function TestSocialSimpleTestBase::setComponentFormDisplay in Social simple 2.0.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/TestSocialSimpleTestBase.php \Drupal\Tests\social_simple\Functional\TestSocialSimpleTestBase::setComponentFormDisplay()

Set the widget for a component in a form display.

Parameters

string $form_display_id: The form display id.

string $entity_type: The entity type name.

string $bundle: The bundle name.

string $field_name: The field name to set.

string $widget_id: The widget id to set.

array $settings: The settings of widget.

string $mode: The mode name.

1 call to TestSocialSimpleTestBase::setComponentFormDisplay()
TestSocialSimpleTestBase::setUp in tests/src/Functional/TestSocialSimpleTestBase.php

File

tests/src/Functional/TestSocialSimpleTestBase.php, line 220

Class

TestSocialSimpleTestBase
Provides common helper methods for Social simple module tests.

Namespace

Drupal\Tests\social_simple\Functional

Code

protected function setComponentFormDisplay($form_display_id, $entity_type, $bundle, $field_name, $widget_id, $settings, $mode = 'default') {

  // Set article's form display.
  $this->formDisplay = EntityFormDisplay::load($form_display_id);
  if (!$this->formDisplay) {
    EntityFormDisplay::create([
      'targetEntityType' => $entity_type,
      'bundle' => $bundle,
      'mode' => $mode,
      'status' => TRUE,
    ])
      ->save();
    $this->formDisplay = EntityFormDisplay::load($form_display_id);
  }
  if ($this->formDisplay instanceof EntityFormDisplayInterface) {
    $this->formDisplay
      ->setComponent($field_name, [
      'type' => $widget_id,
      'settings' => $settings,
    ])
      ->save();
  }
}