function FieldDropbuttonTest::setUp

Same name in this branch
  1. 9 core/modules/views/tests/src/Functional/Handler/FieldDropButtonTest.php \Drupal\Tests\views\Functional\Handler\FieldDropButtonTest::setUp()
Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Kernel/Handler/FieldDropbuttonTest.php \Drupal\Tests\views\Kernel\Handler\FieldDropbuttonTest::setUp()
  2. 8.9.x core/modules/views/tests/src/Functional/Handler/FieldDropButtonTest.php \Drupal\Tests\views\Functional\Handler\FieldDropButtonTest::setUp()
  3. 10 core/modules/views/tests/src/Kernel/Handler/FieldDropbuttonTest.php \Drupal\Tests\views\Kernel\Handler\FieldDropbuttonTest::setUp()
  4. 10 core/modules/views/tests/src/Functional/Handler/FieldDropButtonTest.php \Drupal\Tests\views\Functional\Handler\FieldDropButtonTest::setUp()
  5. 11.x core/modules/views/tests/src/Kernel/Handler/FieldDropbuttonTest.php \Drupal\Tests\views\Kernel\Handler\FieldDropbuttonTest::setUp()
  6. 11.x 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 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);
}

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