function ViewsEntitySchemaSubscriberIntegrationTest::testDataTableAddition

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

Tests that adding data tables adapts the views.

File

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

Class

ViewsEntitySchemaSubscriberIntegrationTest
Tests <a href="/api/drupal/core%21modules%21views%21src%21EventSubscriber%21ViewsEntitySchemaSubscriber.php/class/ViewsEntitySchemaSubscriber/8.9.x" title="Reacts to changes on entity types to update all views entities." class="local">\Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber</a>

Namespace

Drupal\Tests\views\Kernel\EventSubscriber

Code

public function testDataTableAddition() {
    $this->updateEntityTypeToTranslatable(TRUE);
    
    /** @var \Drupal\views\Entity\View $view */
    $entity_storage = $this->entityTypeManager
        ->getStorage('view');
    $view = $entity_storage->load('test_view_entity_test');
    // 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', $display['display_options']['fields']['name']['table']);
    // Check that only the impacted views have been updated.
    $this->assertUpdatedViews([
        'test_view_entity_test',
    ]);
}

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