function EntityDisplayRepositoryTest::setUp

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

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