You are here

public function EntityReferenceRelationshipTest::testEntityReferenceConfigEntity in Drupal 10

Same name and namespace in other branches
  1. 9 core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php \Drupal\Tests\field\Kernel\EntityReference\Views\EntityReferenceRelationshipTest::testEntityReferenceConfigEntity()

Test that config entities don't get relationships added.

File

core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php, line 355

Class

EntityReferenceRelationshipTest
Tests entity reference relationship data.

Namespace

Drupal\Tests\field\Kernel\EntityReference\Views

Code

public function testEntityReferenceConfigEntity() {

  // Create reference from entity_test to a config entity.
  $this
    ->createEntityReferenceField('entity_test', 'entity_test', 'field_test_config_entity', 'field_test_config_entity', 'user_role');
  Views::viewsData()
    ->clear();
  $views_data = Views::viewsData()
    ->getAll();

  // Test that a relationship got added for content entities but not config
  // entities.
  $this
    ->assertTrue(isset($views_data['entity_test__field_test_data']['field_test_data']['relationship']));
  $this
    ->assertFalse(isset($views_data['entity_test__field_test_config_entity']['field_test_config_entity']['relationship']));
}