You are here

protected function FieldFieldAccessTestBase::setUp in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Kernel/Handler/FieldFieldAccessTestBase.php \Drupal\Tests\views\Kernel\Handler\FieldFieldAccessTestBase::setUp()
  2. 9 core/modules/views/tests/src/Kernel/Handler/FieldFieldAccessTestBase.php \Drupal\Tests\views\Kernel\Handler\FieldFieldAccessTestBase::setUp()

Parameters

bool $import_test_views: Should the views specified on the test class be imported. If you need to setup some additional stuff, like fields, you need to call false and then call createTestViews for your own.

Overrides ViewsKernelTestBase::setUp

5 calls to FieldFieldAccessTestBase::setUp()
CommentViewsFieldAccessTest::setUp in core/modules/comment/tests/src/Kernel/Views/CommentViewsFieldAccessTest.php
EntityTestViewsFieldAccessTest::setUp in core/modules/views/tests/src/Kernel/Handler/EntityTestViewsFieldAccessTest.php
NodeViewsFieldAccessTest::setUp in core/modules/node/tests/src/Kernel/Views/NodeViewsFieldAccessTest.php
TaxonomyViewsFieldAccessTest::setUp in core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyViewsFieldAccessTest.php
UserViewsFieldAccessTest::setUp in core/modules/user/tests/src/Kernel/Views/UserViewsFieldAccessTest.php
6 methods override FieldFieldAccessTestBase::setUp()
CommentViewsFieldAccessTest::setUp in core/modules/comment/tests/src/Kernel/Views/CommentViewsFieldAccessTest.php
EntityTestViewsFieldAccessTest::setUp in core/modules/views/tests/src/Kernel/Handler/EntityTestViewsFieldAccessTest.php
FileViewsFieldAccessTest::setUp in core/modules/file/tests/src/Kernel/Views/FileViewsFieldAccessTest.php
NodeViewsFieldAccessTest::setUp in core/modules/node/tests/src/Kernel/Views/NodeViewsFieldAccessTest.php
TaxonomyViewsFieldAccessTest::setUp in core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyViewsFieldAccessTest.php

... See full list

File

core/modules/views/tests/src/Kernel/Handler/FieldFieldAccessTestBase.php, line 38

Class

FieldFieldAccessTestBase
Provides a base class for base field access in views.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

protected function setUp($import_test_views = TRUE) : void {
  parent::setUp($import_test_views);
  $this
    ->installEntitySchema('user');
  $role_with_access = Role::create([
    'id' => 'with_access',
    'permissions' => [
      'view test entity field',
    ],
    'label' => 'With access',
  ]);
  $role_with_access
    ->save();
  $role_without_access = Role::create([
    'id' => 'without_access',
    'permissions' => [],
    'label' => 'Without access',
  ]);
  $role_without_access
    ->save();
  $this->userWithAccess = User::create([
    'name' => $this
      ->randomMachineName(),
    'roles' => [
      $role_with_access
        ->id(),
    ],
  ]);
  $this->userWithAccess
    ->save();
  $this->userWithoutAccess = User::create([
    'name' => $this
      ->randomMachineName(),
    'roles' => [
      $role_without_access
        ->id(),
    ],
  ]);
  $this->userWithoutAccess
    ->save();
}