You are here

public function DisplayFormModeTestTrait::drupalCreateFormMode in Form mode manager 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/DisplayFormModeTestTrait.php \Drupal\Tests\form_mode_manager\Functional\DisplayFormModeTestTrait::drupalCreateFormMode()

Creates a Form Mode based on default settings.

$this
  ->drupalCreateFormMode([
  'id' => node . my_form_mode,
  'label' => t('Hello, world!'),
]);

The following defaults are provided:

  • id: Random string.
  • label: Random string.
  • targetEntityType: 'page'.

Parameters

string $entity_type_id: The entity type id.

array $settings: (optional) An associative array of settings for the form mode. Override the defaults by specifying the key and value in the array, for example:.

Return value

\Drupal\Core\Entity\EntityDisplayModeInterface The created form mode entity.

3 calls to DisplayFormModeTestTrait::drupalCreateFormMode()
FormModeManagerBase::setUp in tests/src/Functional/FormModeManagerBase.php
FormModeManagerUiTest::testFormModeManagerTaxonomyTermOverview in tests/src/Functional/FormModeManagerUiTest.php
Tests Form Mode links provide by module for Term entity.
FormModeManagerUiTest::testFormModeManagerUserOverview in tests/src/Functional/FormModeManagerUiTest.php
Tests Form Mode links provide by module for User entity.

File

tests/src/Functional/DisplayFormModeTestTrait.php, line 36

Class

DisplayFormModeTestTrait
Provides common helper methods for form_mode_manager module tests.

Namespace

Drupal\Tests\form_mode_manager\Functional

Code

public function drupalCreateFormMode($entity_type_id, array $settings = []) {
  $form_mode = EntityFormMode::create($settings + [
    'id' => "{$entity_type_id}.{$this->randomMachineName()}",
    'label' => $this
      ->randomMachineName(),
    'targetEntityType' => $entity_type_id,
  ]);
  $form_mode
    ->save();
  return $form_mode;
}