diff -u b/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php b/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php --- b/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php +++ b/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php @@ -2,7 +2,11 @@ namespace Drupal\Tests\node\Functional; +use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Language\LanguageInterface; use Drupal\node\Entity\NodeType; +use Drupal\taxonomy\Entity\Vocabulary; +use Drupal\Tests\field\Traits\EntityReferenceTestTrait; /** * Tests behavior of the node access subsystem if the base table is not node. @@ -11,12 +15,19 @@ */ class NodeAccessBaseTableTest extends NodeTestBase { + use EntityReferenceTestTrait; + /** * Modules to enable. * * @var array */ - protected static $modules = ['node_access_test', 'views']; + protected static $modules = [ + 'node_access_test', + 'views', + 'taxonomy', + 'search', + ]; /** * {@inheritdoc} @@ -25,13 +36,4 @@ /** - * The installation profile to use with this test. - * - * This test class requires the "tags" taxonomy field. - * - * @var string - */ - protected $profile = 'testing'; - - /** * Nodes by user. * @@ -68,6 +70,33 @@ 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();