You are here

public function EntityViewsDataTest::testBaseTables in Drupal 10

Tests base tables.

File

core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php, line 171

Class

EntityViewsDataTest
Tests entity views data.

Namespace

Drupal\Tests\views\Kernel\Entity

Code

public function testBaseTables() {
  $data = $this->entityTypeManager
    ->getHandler('entity_test', 'views_data')
    ->getViewsData();
  $this
    ->assertEquals('entity_test', $data['entity_test']['table']['entity type']);
  $this
    ->assertEquals(FALSE, $data['entity_test']['table']['entity revision']);
  $this
    ->assertEquals('Entity test', $data['entity_test']['table']['group']);
  $this
    ->assertEquals('entity_test', $data['entity_test']['table']['provider']);
  $this
    ->assertEquals('id', $data['entity_test']['table']['base']['field']);
  $this
    ->assertEquals([
    'entity_test_list_cache_context',
  ], $data['entity_test']['table']['base']['cache_contexts']);
  $this
    ->assertEquals('Entity test', $data['entity_test']['table']['base']['title']);

  // TODO: change these to assertArrayNotHasKey().
  $this
    ->assertFalse(isset($data['entity_test']['table']['defaults']));
  $this
    ->assertFalse(isset($data['entity_test_mul_property_data']));
  $this
    ->assertFalse(isset($data['revision_table']));
  $this
    ->assertFalse(isset($data['revision_data_table']));
}