You are here

protected function FieldDropbuttonTest::setUp in Drupal 10

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

File

core/modules/views/tests/src/Kernel/Handler/FieldDropbuttonTest.php, line 73

Class

FieldDropbuttonTest
Tests the core Drupal\views\Plugin\views\field\Dropbutton handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

protected function setUp($import_test_views = TRUE) : void {
  parent::setUp(FALSE);
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('user');
  $this
    ->installSchema('node', 'node_access');
  $this
    ->installConfig('node');
  $this
    ->installConfig('filter');
  ViewTestData::createTestViews(static::class, [
    'views_test_config',
  ]);

  // Create two node types.
  $this
    ->createContentType([
    'type' => 'foo',
  ]);
  $this
    ->createContentType([
    'type' => 'bar',
  ]);

  // Create user 1.
  $admin = $this
    ->createUser();

  // And three nodes.
  $this->node1 = $this
    ->createNode([
    'type' => 'bar',
    'title' => 'bazs',
    'status' => 1,
    'uid' => $admin
      ->id(),
    'created' => REQUEST_TIME - 10,
  ]);
  $this->node2 = $this
    ->createNode([
    'type' => 'foo',
    'title' => 'foos',
    'status' => 1,
    'uid' => $admin
      ->id(),
    'created' => REQUEST_TIME - 5,
  ]);
  $this->node3 = $this
    ->createNode([
    'type' => 'bar',
    'title' => 'bars',
    'status' => 1,
    'uid' => $admin
      ->id(),
    'created' => REQUEST_TIME,
  ]);

  // Now create a user with the ability to edit bar but not foo.
  $this->testUser = $this
    ->createUser([
    'access content overview',
    'access content',
    'edit any bar content',
    'delete any bar content',
  ]);

  // And switch to that user.
  $this->container
    ->get('account_switcher')
    ->switchTo($this->testUser);
}