You are here

protected function EntityDisplayRepositoryTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityDisplayRepositoryTest.php \Drupal\KernelTests\Core\Entity\EntityDisplayRepositoryTest::setUp()

Overrides KernelTestBase::setUp

File

core/tests/Drupal/KernelTests/Core/Entity/EntityDisplayRepositoryTest.php, line 32

Class

EntityDisplayRepositoryTest
@coversDefaultClass \Drupal\Core\Entity\EntityDisplayRepository

Namespace

Drupal\KernelTests\Core\Entity

Code

protected function setUp() {
  parent::setUp();
  $this->displayRepository = \Drupal::service('entity_display.repository');

  // Create a new view mode for users.
  $this->container
    ->get('entity_type.manager')
    ->getStorage('entity_view_mode')
    ->create([
    'id' => 'user.pastafazoul',
    'label' => $this
      ->randomMachineName(),
    'targetEntityType' => 'user',
  ])
    ->save();

  // Create a new form mode for users.
  $this->container
    ->get('entity_type.manager')
    ->getStorage('entity_form_mode')
    ->create([
    'id' => 'user.register',
    'label' => $this
      ->randomMachineName(),
    'targetEntityType' => 'user',
  ])
    ->save();
}