You are here

public function ViewsEntitySchemaSubscriberIntegrationTest::testVariousTableUpdatesForRevisionView in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php \Drupal\Tests\views\Kernel\EventSubscriber\ViewsEntitySchemaSubscriberIntegrationTest::testVariousTableUpdatesForRevisionView()
  2. 9 core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php \Drupal\Tests\views\Kernel\EventSubscriber\ViewsEntitySchemaSubscriberIntegrationTest::testVariousTableUpdatesForRevisionView()

Tests some possible entity table updates for a revision view.

File

core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php, line 436

Class

ViewsEntitySchemaSubscriberIntegrationTest
Tests \Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber.

Namespace

Drupal\Tests\views\Kernel\EventSubscriber

Code

public function testVariousTableUpdatesForRevisionView() {

  // base + revision <-> base + translation + revision
  $this
    ->updateEntityTypeToRevisionable(TRUE);
  [
    $view,
    $display,
  ] = $this
    ->getUpdatedViewAndDisplay(TRUE);
  $this
    ->assertEquals('entity_test_update_revision', $view
    ->get('base_table'));
  $this
    ->assertEquals('entity_test_update_revision', $display['display_options']['fields']['id']['table']);
  $this
    ->assertEquals('entity_test_update_revision', $display['display_options']['fields']['name']['table']);
  $this
    ->updateEntityTypeToTranslatable(TRUE);
  [
    $view,
    $display,
  ] = $this
    ->getUpdatedViewAndDisplay(TRUE);
  $this
    ->assertEquals('entity_test_update_revision', $view
    ->get('base_table'));
  $this
    ->assertEquals('entity_test_update_revision', $display['display_options']['fields']['id']['table']);
  $this
    ->assertEquals('entity_test_update_revision_data', $display['display_options']['fields']['name']['table']);
  $this
    ->updateEntityTypeToNotTranslatable(TRUE);
  [
    $view,
    $display,
  ] = $this
    ->getUpdatedViewAndDisplay(TRUE);
  $this
    ->assertEquals('entity_test_update_revision', $view
    ->get('base_table'));
  $this
    ->assertEquals('entity_test_update_revision', $display['display_options']['fields']['id']['table']);
  $this
    ->assertEquals('entity_test_update_revision', $display['display_options']['fields']['name']['table']);

  // Check that only the impacted views have been updated.
  $this
    ->assertUpdatedViews([
    'test_view_entity_test',
    'test_view_entity_test_data',
    'test_view_entity_test_revision',
  ]);
}