function ViewsEntitySchemaSubscriberIntegrationTest::testVariousTableUpdates

Same name in other branches
  1. 9 core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php \Drupal\Tests\views\Kernel\EventSubscriber\ViewsEntitySchemaSubscriberIntegrationTest::testVariousTableUpdates()
  2. 10 core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php \Drupal\Tests\views\Kernel\EventSubscriber\ViewsEntitySchemaSubscriberIntegrationTest::testVariousTableUpdates()
  3. 11.x core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php \Drupal\Tests\views\Kernel\EventSubscriber\ViewsEntitySchemaSubscriberIntegrationTest::testVariousTableUpdates()

Tests a bunch possible entity definition table updates.

File

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

Class

ViewsEntitySchemaSubscriberIntegrationTest
Tests \Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber

Namespace

Drupal\Tests\views\Kernel\EventSubscriber

Code

public function testVariousTableUpdates() {
    // We want to test the following permutations of entity definition updates:
    // base <-> base + translation
    // base + translation <-> base + translation + revision
    // base + revision <-> base + translation + revision
    // base <-> base + revision
    // base <-> base + translation + revision
    // base <-> base + translation
    $this->updateEntityTypeToTranslatable(TRUE);
    list($view, $display) = $this->getUpdatedViewAndDisplay();
    $this->assertEqual('entity_test_update', $view->get('base_table'));
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['id']['table']);
    $this->assertEqual('entity_test_update_data', $display['display_options']['fields']['name']['table']);
    $this->updateEntityTypeToNotTranslatable(TRUE);
    list($view, $display) = $this->getUpdatedViewAndDisplay();
    $this->assertEqual('entity_test_update', $view->get('base_table'));
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['id']['table']);
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['name']['table']);
    $this->resetEntityType();
    // base + translation <-> base + translation + revision
    $this->updateEntityTypeToTranslatable(TRUE);
    list($view, $display) = $this->getUpdatedViewAndDisplay();
    $this->assertEqual('entity_test_update', $view->get('base_table'));
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['id']['table']);
    $this->assertEqual('entity_test_update_data', $display['display_options']['fields']['name']['table']);
    $this->updateEntityTypeToRevisionable(TRUE);
    list($view, $display) = $this->getUpdatedViewAndDisplay();
    $this->assertEqual('entity_test_update', $view->get('base_table'));
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['id']['table']);
    $this->assertEqual('entity_test_update_data', $display['display_options']['fields']['name']['table']);
    $this->updateEntityTypeToNotRevisionable(TRUE);
    list($view, $display) = $this->getUpdatedViewAndDisplay();
    $this->assertEqual('entity_test_update', $view->get('base_table'));
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['id']['table']);
    $this->assertEqual('entity_test_update_data', $display['display_options']['fields']['name']['table']);
    $this->resetEntityType();
    // base + revision <-> base + translation + revision
    $this->updateEntityTypeToRevisionable();
    list($view, $display) = $this->getUpdatedViewAndDisplay();
    $this->assertEqual('entity_test_update', $view->get('base_table'));
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['id']['table']);
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['name']['table']);
    $this->updateEntityTypeToTranslatable(TRUE);
    list($view, $display) = $this->getUpdatedViewAndDisplay();
    $this->assertEqual('entity_test_update', $view->get('base_table'));
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['id']['table']);
    $this->assertEqual('entity_test_update_data', $display['display_options']['fields']['name']['table']);
    $this->updateEntityTypeToNotTranslatable(TRUE);
    list($view, $display) = $this->getUpdatedViewAndDisplay();
    $this->assertEqual('entity_test_update', $view->get('base_table'));
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['id']['table']);
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['name']['table']);
    $this->resetEntityType();
    // base <-> base + revision
    $this->updateEntityTypeToRevisionable(TRUE);
    list($view, $display) = $this->getUpdatedViewAndDisplay();
    $this->assertEqual('entity_test_update', $view->get('base_table'));
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['id']['table']);
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['name']['table']);
    $this->updateEntityTypeToNotRevisionable(TRUE);
    list($view, $display) = $this->getUpdatedViewAndDisplay();
    $this->assertEqual('entity_test_update', $view->get('base_table'));
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['id']['table']);
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['name']['table']);
    $this->resetEntityType();
    // base <-> base + translation + revision
    $this->updateEntityTypeToRevisionable(TRUE);
    $this->updateEntityTypeToTranslatable(TRUE);
    list($view, $display) = $this->getUpdatedViewAndDisplay();
    $this->assertEqual('entity_test_update', $view->get('base_table'));
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['id']['table']);
    $this->assertEqual('entity_test_update_data', $display['display_options']['fields']['name']['table']);
    $this->updateEntityTypeToNotRevisionable(TRUE);
    $this->updateEntityTypeToNotTranslatable(TRUE);
    list($view, $display) = $this->getUpdatedViewAndDisplay();
    $this->assertEqual('entity_test_update', $view->get('base_table'));
    $this->assertEqual('entity_test_update', $display['display_options']['fields']['id']['table']);
    $this->assertEqual('entity_test_update', $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',
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.