function NodeAccessBaseTableTest::setUp

Same name in other branches
  1. 9 core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php \Drupal\Tests\node\Functional\NodeAccessBaseTableTest::setUp()
  2. 8.9.x core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php \Drupal\Tests\node\Functional\NodeAccessBaseTableTest::setUp()
  3. 11.x core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php \Drupal\Tests\node\Functional\NodeAccessBaseTableTest::setUp()

Overrides NodeTestBase::setUp

File

core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php, line 73

Class

NodeAccessBaseTableTest
Tests behavior of the node access subsystem if the base table is not node.

Namespace

Drupal\Tests\node\Functional

Code

protected function setUp() : void {
    parent::setUp();
    // Create the vocabulary for the tag field.
    $vocabulary = Vocabulary::create([
        'name' => 'Tags',
        'vid' => 'tags',
        'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
    ]);
    $vocabulary->save();
    $field_name = 'field_' . $vocabulary->id();
    $handler_settings = [
        'target_bundles' => [
            $vocabulary->id() => $vocabulary->id(),
        ],
        'auto_create' => TRUE,
    ];
    $this->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
    $entity_type_manager = $this->container
        ->get('entity_type.manager');
    $entity_type_manager->getStorage('entity_form_display')
        ->load('node.article.default')
        ->setComponent($field_name, [
        'type' => 'entity_reference_autocomplete_tags',
        'weight' => -4,
    ])
        ->save();
    node_access_test_add_field(NodeType::load('article'));
    node_access_rebuild();
    \Drupal::state()->set('node_access_test.private', TRUE);
}

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