function RouteProviderTest::setUp

Same name in this branch
  1. 11.x core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php \Drupal\KernelTests\Core\Routing\RouteProviderTest::setUp()
Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php \Drupal\KernelTests\Core\Routing\RouteProviderTest::setUp()
  2. 9 core/tests/Drupal/KernelTests/Core/Entity/RouteProviderTest.php \Drupal\KernelTests\Core\Entity\RouteProviderTest::setUp()
  3. 8.9.x core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php \Drupal\KernelTests\Core\Routing\RouteProviderTest::setUp()
  4. 8.9.x core/tests/Drupal/KernelTests/Core/Entity/RouteProviderTest.php \Drupal\KernelTests\Core\Entity\RouteProviderTest::setUp()
  5. 10 core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php \Drupal\KernelTests\Core\Routing\RouteProviderTest::setUp()
  6. 10 core/tests/Drupal/KernelTests/Core/Entity/RouteProviderTest.php \Drupal\KernelTests\Core\Entity\RouteProviderTest::setUp()

Overrides KernelTestBase::setUp

File

core/tests/Drupal/KernelTests/Core/Entity/RouteProviderTest.php, line 33

Class

RouteProviderTest
Tests route providers for entity types.

Namespace

Drupal\KernelTests\Core\Entity

Code

protected function setUp() : void {
    parent::setUp();
    $permissions = [
        'administer entity_test content',
        'view test entity',
    ];
    $this->setUpCurrentUser([
        'uid' => 2,
    ], $permissions);
    $this->installEntitySchema('entity_test_mul');
    $this->installEntitySchema('entity_test_admin_routes');
    
    /** @var \Drupal\user\RoleInterface $role */
    $role = Role::create([
        'id' => RoleInterface::ANONYMOUS_ID,
        'label' => 'Anonymous',
    ]);
    $role->grantPermission('administer entity_test content')
        ->grantPermission('view test entity');
    $role->save();
}

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