function ViewsEntitySchemaSubscriberIntegrationTest::testDataTableRename
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php \Drupal\Tests\views\Kernel\EventSubscriber\ViewsEntitySchemaSubscriberIntegrationTest::testDataTableRename()
- 8.9.x core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php \Drupal\Tests\views\Kernel\EventSubscriber\ViewsEntitySchemaSubscriberIntegrationTest::testDataTableRename()
- 11.x core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php \Drupal\Tests\views\Kernel\EventSubscriber\ViewsEntitySchemaSubscriberIntegrationTest::testDataTableRename()
Tests that renaming data tables adapts the views.
File
-
core/
modules/ views/ tests/ src/ Kernel/ EventSubscriber/ ViewsEntitySchemaSubscriberIntegrationTest.php, line 162
Class
- ViewsEntitySchemaSubscriberIntegrationTest
- Tests \Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber.
Namespace
Drupal\Tests\views\Kernel\EventSubscriberCode
public function testDataTableRename() : void {
$this->updateEntityTypeToTranslatable(TRUE);
$entity_storage = $this->entityTypeManager
->getStorage('view');
$view = $entity_storage->load('test_view_entity_test_data');
$this->assertEquals('entity_test_update', $view->get('base_table'));
$display = $view->getDisplay('default');
$this->assertEquals('entity_test_update', $display['display_options']['fields']['id']['table']);
// Ensure that the data table is used.
$this->assertEquals('entity_test_update_data', $display['display_options']['fields']['name']['table']);
$this->renameDataTable();
$this->applyEntityUpdates('entity_test_update');
/** @var \Drupal\views\Entity\View $view */
$entity_storage = $this->entityTypeManager
->getStorage('view');
$view = $entity_storage->load('test_view_entity_test_data');
// Ensure the data table got renamed, so also the views fields.
$this->assertEquals('entity_test_update', $view->get('base_table'));
$display = $view->getDisplay('default');
$this->assertEquals('entity_test_update', $display['display_options']['fields']['id']['table']);
$this->assertEquals('entity_test_update_data_new', $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',
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.