You are here

public function ViewsEntitySchemaSubscriberIntegrationTest::testDataTableRename in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php \Drupal\views\Tests\EventSubscriber\ViewsEntitySchemaSubscriberIntegrationTest::testDataTableRename()

Tests that renaming data tables adapts the views.

File

core/modules/views/src/Tests/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php, line 150
Contains \Drupal\views\Tests\EventSubscriber\ViewsEntitySchemaSubscriberIntegrationTest.

Class

ViewsEntitySchemaSubscriberIntegrationTest
Tests \Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber

Namespace

Drupal\views\Tests\EventSubscriber

Code

public function testDataTableRename() {
  $this
    ->updateEntityTypeToTranslatable();
  $this->entityDefinitionUpdateManager
    ->applyUpdates();
  $entity_storage = $this->entityManager
    ->getStorage('view');
  $view = $entity_storage
    ->load('test_view_entity_test_data');
  $this
    ->assertEqual('entity_test_update', $view
    ->get('base_table'));
  $display = $view
    ->getDisplay('default');
  $this
    ->assertEqual('entity_test_update', $display['display_options']['fields']['id']['table']);

  // Ensure that the data table is used.
  $this
    ->assertEqual('entity_test_update_data', $display['display_options']['fields']['name']['table']);
  $this
    ->renameDataTable();
  $this->entityDefinitionUpdateManager
    ->applyUpdates();

  /** @var \Drupal\views\Entity\View $view */
  $entity_storage = $this->entityManager
    ->getStorage('view');
  $view = $entity_storage
    ->load('test_view_entity_test_data');

  // Ensure the data table got renamed, so also the views fields.
  $this
    ->assertEqual('entity_test_update', $view
    ->get('base_table'));
  $display = $view
    ->getDisplay('default');
  $this
    ->assertEqual('entity_test_update', $display['display_options']['fields']['id']['table']);
  $this
    ->assertEqual('entity_test_update_data_new', $display['display_options']['fields']['name']['table']);
}