You are here

protected function FieldFieldAccessTestBase::setUp in Drupal 9

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

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

8 calls to FieldFieldAccessTestBase::setUp()
AggregatorFeedViewsFieldAccessTest::setUp in core/modules/aggregator/tests/src/Kernel/Views/AggregatorFeedViewsFieldAccessTest.php
AggregatorItemViewsFieldAccessTest::setUp in core/modules/aggregator/tests/src/Kernel/Views/AggregatorItemViewsFieldAccessTest.php
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

... See full list

8 methods override FieldFieldAccessTestBase::setUp()
AggregatorFeedViewsFieldAccessTest::setUp in core/modules/aggregator/tests/src/Kernel/Views/AggregatorFeedViewsFieldAccessTest.php
AggregatorItemViewsFieldAccessTest::setUp in core/modules/aggregator/tests/src/Kernel/Views/AggregatorItemViewsFieldAccessTest.php
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

... 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) {
  parent::setUp($import_test_views);
  $this
    ->installEntitySchema('user');
  $role_with_access = Role::create([
    'id' => 'with_access',
    'permissions' => [
      'view test entity field',
    ],
  ]);
  $role_with_access
    ->save();
  $role_without_access = Role::create([
    'id' => 'without_access',
    'permissions' => [],
  ]);
  $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();
}