3 namespace Drupal\Tests\views\Functional\Update;
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6 use Drupal\views\Views;
9 * Tests the upgrade path for views multi-value base field data.
11 * @see views_update_8500()
15 class EntityViewsMultiValueBaseFieldDataUpdateTest extends UpdatePathTestBase {
20 protected function setDatabaseDumpFiles() {
21 $this->databaseDumpFiles = [
22 __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
23 __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.views-entity-views-data-2846614.php',
28 * Tests multi-value base field views data is updated correctly.
30 public function testUpdateMultiValueBaseFields() {
33 $view = Views::getView('test_user_multi_value');
34 $display = $view->storage->get('display');
36 // Check each handler type present in the configuration to make sure the
37 // field got updated correctly.
38 foreach (['fields', 'filters', 'arguments'] as $type) {
39 $handler_config = $display['default']['display_options'][$type]['roles'];
41 // The ID should remain unchanged. Otherwise the update handler could
42 // overwrite a separate handler config.
43 $this->assertEqual('roles', $handler_config['id']);
44 // The field should be updated from 'roles' to the correct column name.
45 $this->assertEqual('roles_target_id', $handler_config['field']);
46 // Check the table is still correct.
47 $this->assertEqual('user__roles', $handler_config['table']);
49 // The plugin ID should be updated as well.
50 $this->assertEqual($type === 'arguments' ? 'user__roles_rid' : 'user_roles', $handler_config['plugin_id']);