function ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest::setUp

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php \Drupal\FunctionalTests\Entity\ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest::setUp()
  2. 8.9.x core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php \Drupal\FunctionalTests\Entity\ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest::setUp()
  3. 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 46

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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.