You are here

protected function ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php \Drupal\FunctionalTests\Entity\ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest::setUp()
  2. 10 core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php \Drupal\FunctionalTests\Entity\ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest::setUp()

Overrides BrowserTestBase::setUp

File

core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php, line 44

Class

ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest
Tests the correct mapping of user input on the correct field delta elements.

Namespace

Drupal\FunctionalTests\Entity

Code

protected function setUp() : void {
  parent::setUp();
  $web_user = $this
    ->drupalCreateUser([
    'administer entity_test content',
  ]);
  $this
    ->drupalLogin($web_user);

  // Create a field of field type "shape" with unlimited cardinality on the
  // entity type "entity_test".
  $this->entityTypeId = 'entity_test';
  $this->fieldName = 'shape';
  FieldStorageConfig::create([
    'field_name' => $this->fieldName,
    'entity_type' => $this->entityTypeId,
    'type' => 'shape',
    'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
  ])
    ->save();
  FieldConfig::create([
    'entity_type' => $this->entityTypeId,
    'field_name' => $this->fieldName,
    'bundle' => $this->entityTypeId,
    'label' => 'Shape',
    'translatable' => FALSE,
  ])
    ->save();
  \Drupal::service('entity_display.repository')
    ->getFormDisplay($this->entityTypeId, $this->entityTypeId)
    ->setComponent($this->fieldName, [
    'type' => 'shape_only_color_editable_widget',
  ])
    ->save();
}