You are here

protected function ExposedFormCheckboxesTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Functional/Plugin/ExposedFormCheckboxesTest.php \Drupal\Tests\views\Functional\Plugin\ExposedFormCheckboxesTest::setUp()

Overrides ViewTestBase::setUp

File

core/modules/views/tests/src/Functional/Plugin/ExposedFormCheckboxesTest.php, line 54

Class

ExposedFormCheckboxesTest
Tests exposed forms functionality.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

protected function setUp($import_test_views = TRUE) : void {
  parent::setUp(FALSE);

  // Create a vocabulary and entity reference field so we can test the "is all
  // of" filter operator. Must be done ahead of the view import so the
  // vocabulary is in place to meet the view dependencies.
  $vocabulary = Vocabulary::create([
    'name' => 'test_exposed_checkboxes',
    'vid' => 'test_exposed_checkboxes',
    'nodes' => [
      'article' => 'article',
    ],
  ]);
  $vocabulary
    ->save();
  $this->vocabulary = $vocabulary;
  ViewTestData::createTestViews(self::class, [
    'views_test_config',
  ]);
  $this
    ->enableViewsTestModule();

  // Create two content types.
  $this
    ->drupalCreateContentType([
    'type' => 'article',
  ]);
  $this
    ->drupalCreateContentType([
    'type' => 'page',
  ]);

  // Create some random nodes: 5 articles, one page.
  for ($i = 0; $i < 5; $i++) {
    $this
      ->drupalCreateNode([
      'type' => 'article',
    ]);
  }
  $this
    ->drupalCreateNode([
    'type' => 'page',
  ]);
}