diff --git a/core/modules/field_ui/src/Tests/EntityFormDisplayWebTest.php b/core/modules/field_ui/src/Tests/EntityFormDisplayWebTest.php new file mode 100644 index 0000000..5ed153b --- /dev/null +++ b/core/modules/field_ui/src/Tests/EntityFormDisplayWebTest.php @@ -0,0 +1,52 @@ +drupalCreateUser(['administer entity_test content']); + $this->drupalLogin($user); + + $entity = EntityTestBaseFieldDisplay::create(['name' => $this->randomString()]); + $entity->save(); + + $this->drupalGet('entity_test_base_field_display/manage/' . $entity->id()); + $this->assertRaw($entity->label()); + $this->assertText('A field with multiple values'); + $this->drupalPostForm(NULL, [], t('Add another item')); + + $edit['test_display_multiple[0][value]'] = $this->randomString(); + $edit['test_display_multiple[1][value]'] = $this->randomString(); + $this->drupalPostForm(NULL, $edit, t('Save')); + $this->assertText('entity_test_base_field_display ' . $entity->id() . ' has been updated.'); + + + + } + +} diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php index 210eb53..88547af 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\BaseFieldDefinition; +use Drupal\entity_test\FieldStorageDefinition; /** * Defines a test entity class for base fields display. @@ -23,9 +24,10 @@ * }, * "translation" = "Drupal\content_translation\ContentTranslationHandler" * }, - * base_table = "entity_test", + * base_table = "entity_test_base_field_display", * entity_keys = { * "id" = "id", + * "label" = "name", * "uuid" = "uuid", * "bundle" = "type" * }, @@ -70,6 +72,18 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { 'weight' => 11, )); + $fields['test_display_multiple'] = BaseFieldDefinition::create('text') + ->setLabel(t('A field with multiple values')) + ->setCardinality(FieldStorageDefinition::CARDINALITY_UNLIMITED) + ->setDisplayOptions('view', array( + 'type' => 'text_default', + 'weight' => 11, + )) + ->setDisplayOptions('form', array( + 'type' => 'text_textfield', + 'weight' => 11, + )); + return $fields; }