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