function FieldDropbuttonTest::setUp

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

Overrides ViewsKernelTestBase::setUp

File

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

Class

FieldDropbuttonTest
Tests the core <a href="/api/drupal/core%21modules%21views%21src%21Plugin%21views%21field%21Dropbutton.php/class/Dropbutton/11.x" title="Provides a handler that renders links as dropbutton." class="local">Drupal\views\Plugin\views\field\Dropbutton</a> 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.
    $requestTime = \Drupal::time()->getRequestTime();
    $this->node1 = $this->createNode([
        'type' => 'bar',
        'title' => 'foo',
        'status' => 1,
        'uid' => $admin->id(),
        'created' => $requestTime - 10,
    ]);
    $this->node2 = $this->createNode([
        'type' => 'foo',
        'title' => 'foo',
        'status' => 1,
        'uid' => $admin->id(),
        'created' => $requestTime - 5,
    ]);
    $this->node3 = $this->createNode([
        'type' => 'bar',
        'title' => 'bars',
        'status' => 1,
        'uid' => $admin->id(),
        'created' => $requestTime,
    ]);
    // 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);
}

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