public function EntityFormDisplayTest::testEntityGetFromDisplay in Drupal 9
Same name and namespace in other branches
- 8 core/modules/field_ui/tests/src/Kernel/EntityFormDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityFormDisplayTest::testEntityGetFromDisplay()
@covers \Drupal\Core\Entity\EntityDisplayRepository::getFormDisplay
File
- core/
modules/ field_ui/ tests/ src/ Kernel/ EntityFormDisplayTest.php, line 40
Class
- EntityFormDisplayTest
- Tests the entity display configuration entities.
Namespace
Drupal\Tests\field_ui\KernelCode
public function testEntityGetFromDisplay() {
/** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
$display_repository = \Drupal::service('entity_display.repository');
// Check that EntityDisplayRepositoryInterface::getFormDisplay() returns a
// fresh object when no configuration entry exists.
$form_display = $display_repository
->getFormDisplay('entity_test', 'entity_test');
$this
->assertTrue($form_display
->isNew());
// Add some components and save the display.
$form_display
->setComponent('component_1', [
'weight' => 10,
])
->save();
// Check that EntityDisplayRepositoryInterface::getFormDisplay() returns the
// correct object.
$form_display = $display_repository
->getFormDisplay('entity_test', 'entity_test');
$this
->assertFalse($form_display
->isNew());
$this
->assertEquals('entity_test.entity_test.default', $form_display
->id());
$this
->assertEquals([
'weight' => 10,
'settings' => [],
'third_party_settings' => [],
'region' => 'content',
], $form_display
->getComponent('component_1'));
}