function ImageItemTest::testDisplayDefaultValue
Tests display_default.
File
-
core/
modules/ image/ tests/ src/ Kernel/ ImageItemTest.php, line 213
Class
- ImageItemTest
- Tests using entity fields of the image field type.
Namespace
Drupal\Tests\image\KernelCode
public function testDisplayDefaultValue() : void {
$entity = EntityTest::create([
'name' => $this->randomMachineName(),
]);
$form_object = $this->container
->get(EntityTypeManagerInterface::class)
->getFormObject('entity_test', 'default');
\assert($form_object instanceof ContentEntityForm);
$form_object->setEntity($entity);
$form_display = EntityFormDisplay::collectRenderDisplay($entity, 'default');
\assert($form_display instanceof EntityFormDisplay);
$form_state = new FormState();
$form_object->setFormDisplay($form_display, $form_state);
$this->container
->get(FormBuilderInterface::class)
->buildForm($form_object, $form_state);
self::assertEquals(1, $form_state->getValue([
'image_test',
0,
'display',
]));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.