You are here

public function EntityDisplayTest::testEntityGetDisplay in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testEntityGetDisplay()
  2. 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\Kernel

Code

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
    ->assertEqual($display
    ->id(), 'entity_test.entity_test.default');
  $this
    ->assertEqual($display
    ->getComponent('component_1'), [
    'weight' => 10,
    'settings' => [],
    'third_party_settings' => [],
    'region' => 'content',
  ]);
}