function EntityDisplayRepositoryTest::setUp

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityDisplayRepositoryTest.php \Drupal\KernelTests\Core\Entity\EntityDisplayRepositoryTest::setUp()
  2. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityDisplayRepositoryTest.php \Drupal\KernelTests\Core\Entity\EntityDisplayRepositoryTest::setUp()
  3. 11.x 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 <a href="/api/drupal/core%21lib%21Drupal%21Core%21Entity%21EntityDisplayRepository.php/class/EntityDisplayRepository/8.9.x" title="Provides a repository for entity display objects (view modes and form modes)." class="local">\Drupal\Core\Entity\EntityDisplayRepository</a>

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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.