function ArgumentSummaryTest::setUp

Same name and namespace in other branches
  1. 11.x core/modules/views/tests/src/Kernel/Handler/ArgumentSummaryTest.php \Drupal\Tests\views\Kernel\Handler\ArgumentSummaryTest::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

File

core/modules/views/tests/src/Kernel/Handler/ArgumentSummaryTest.php, line 62

Class

ArgumentSummaryTest
Tests the summary of results when an argument is not provided.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

protected function setUp($import_test_views = TRUE) : void {
    parent::setUp($import_test_views);
    $this->installEntitySchema('node');
    $this->installEntitySchema('taxonomy_term');
    $this->installEntitySchema('user');
    // Create the content type with an autocomplete tagging field.
    $this->nodeType = NodeType::create([
        'type' => 'article',
        'name' => 'Article',
    ]);
    $this->nodeType
        ->save();
    // Create the vocabulary for the tag field.
    $this->tagVocabulary = Vocabulary::create([
        'name' => 'Views testing tags',
        'vid' => 'views_testing_tags',
    ]);
    $this->tagVocabulary
        ->save();
    // Create the tag field itself.
    $handler_settings = [
        'target_bundles' => [
            $this->tagVocabulary
                ->id() => $this->tagVocabulary
                ->id(),
        ],
        'auto_create' => TRUE,
    ];
    $this->createEntityReferenceField('node', $this->nodeType
        ->id(), 'field_tags', NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
}

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