diff --git a/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2846614.php b/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2846614.php new file mode 100644 index 0000000000..2bb0b3ca65 --- /dev/null +++ b/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2846614.php @@ -0,0 +1,32 @@ +insert('config') + ->fields(array( + 'collection', + 'name', + 'data', + )) + ->values(array( + 'collection' => '', + 'name' => 'views.view.' . $views_config['id'], + 'data' => serialize($views_config), + )) + ->execute(); +} diff --git a/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2846614.yml b/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2846614.yml new file mode 100644 index 0000000000..2d68cbe4c4 --- /dev/null +++ b/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2846614.yml @@ -0,0 +1,240 @@ +uuid: 001475a0-daec-4e8a-8ca7-97b0d24100a6 +langcode: en +status: true +dependencies: + module: + - user +id: test_user_multi_value +label: test_user_multi_value +module: views +description: '' +tag: '' +base_table: users_field_data +base_field: uid +core: 8.x +display: + default: + display_plugin: default + id: default + display_title: Master + position: 0 + display_options: + access: + type: perm + options: + perm: 'access user profiles' + cache: + type: tag + options: { } + query: + type: views_query + options: + disable_sql_rewrite: false + distinct: false + replica: false + query_comment: '' + query_tags: { } + exposed_form: + type: basic + options: + submit_button: Filter + reset_button: false + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: true + sort_asc_label: Asc + sort_desc_label: Desc + pager: + type: mini + options: + items_per_page: 10 + offset: 0 + id: 0 + total_pages: null + expose: + items_per_page: false + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 25, 50' + items_per_page_options_all: false + items_per_page_options_all_label: '- All -' + offset: false + offset_label: Offset + tags: + previous: ‹‹ + next: ›› + style: + type: default + options: + grouping: { } + row_class: '' + default_row_class: true + uses_fields: false + row: + type: fields + options: + inline: { } + separator: '' + hide_empty: false + default_field_elements: true + fields: + roles: + id: roles + table: user__roles + field: roles + relationship: none + group_type: group + admin_label: '' + label: '' + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: target_id + type: entity_reference_label + settings: + link: true + group_column: target_id + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + entity_type: user + entity_field: roles + plugin_id: field + filters: + roles: + id: roles + table: user__roles + field: roles + relationship: none + group_type: group + admin_label: '' + operator: '=' + value: '' + group: 1 + exposed: false + expose: + operator_id: '' + label: '' + description: '' + use_operator: false + operator: '' + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + entity_type: user + entity_field: roles + plugin_id: string + sorts: { } + header: { } + footer: { } + empty: { } + relationships: { } + arguments: + roles: + id: roles + table: user__roles + field: roles + relationship: none + group_type: group + admin_label: '' + default_action: ignore + exception: + value: all + title_enable: false + title: All + title_enable: false + title: '' + default_argument_type: fixed + default_argument_options: + argument: '' + default_argument_skip_url: false + summary_options: + base_path: '' + count: true + items_per_page: 25 + override: false + summary: + sort_order: asc + number_of_records: 0 + format: default_summary + specify_validation: false + validate: + type: none + fail: 'not found' + validate_options: { } + glossary: false + limit: 0 + case: none + path_case: none + transform_dash: false + break_phrase: false + entity_type: user + entity_field: roles + plugin_id: string + display_extenders: { } + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url + - url.query_args + - user.permissions + tags: { } diff --git a/core/modules/views/src/Tests/Update/EntityViewsMultiValueBaseFieldDataUpdateTest.php b/core/modules/views/src/Tests/Update/EntityViewsMultiValueBaseFieldDataUpdateTest.php index 2631bb00fa..a4e17fc669 100644 --- a/core/modules/views/src/Tests/Update/EntityViewsMultiValueBaseFieldDataUpdateTest.php +++ b/core/modules/views/src/Tests/Update/EntityViewsMultiValueBaseFieldDataUpdateTest.php @@ -9,23 +9,19 @@ /** * Tests the upgrade path for views multi-value base field data. * + * @see views_update_8300() + * * @group Update */ class EntityViewsMultiValueBaseFieldDataUpdateTest extends UpdatePathTestBase { - /** - * Views to be enabled. - * - * @var array - */ - public static $testViews = ['test_entity_multivalue_basefield_update']; - /** * {@inheritdoc} */ protected function setDatabaseDumpFiles() { $this->databaseDumpFiles = [ __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz', + __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.views-entity-views-data-2846614.php', ]; } @@ -33,18 +29,24 @@ protected function setDatabaseDumpFiles() { * Tests multi-value base field views data is updated correctly. */ public function testUpdateMultiValueBaseFields() { - \Drupal::service('module_installer')->install(['entity_test', 'views_test_config']); - - ViewTestData::createTestViews(get_class($this), ['views_test_config']); - $this->runUpdates(); - $view = Views::getView('test_entity_multivalue_basefield_update'); - - // The field for this handler should get updated to use the correct field - // storage column name. + $view = Views::getView('test_user_multi_value'); $display = $view->storage->get('display'); - $this->assertEqual('basefield_name', $view->storage->get($display['default']['display_options']['fields']['name']['field'])); + + // Check each handler type present in the configuration to make sure the + // field got updated correctly. + foreach (['fields', 'filters', 'arguments'] as $type) { + $handler_config = $display['default']['display_options'][$type]['roles']; + + // The ID should remain unchanged. Otherwise the update handler could + // overwrite a separate handler config. + $this->assertEqual('roles', $handler_config['id']); + // The field should be updated from 'roles' to the correct column name. + $this->assertEqual('roles_target_id', $handler_config['field']); + // Check the table is still correct. + $this->assertEqual('user__roles', $handler_config['table']); + } } } diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_entity_multivalue_basefield_update.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_entity_multivalue_basefield_update.yml deleted file mode 100644 index 803d32a15f..0000000000 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_entity_multivalue_basefield_update.yml +++ /dev/null @@ -1,45 +0,0 @@ -langcode: en -status: true -dependencies: - module: - - entity_test -id: test_entity_multivalue_basefield_update -label: '' -module: views -description: '' -tag: '' -base_table: entity_test_multivalue_basefield -base_field: id -core: '8' -display: - default: - display_plugin: default - id: default - display_title: Master - position: 0 - display_options: - fields: - id: - id: id - table: entity_test_multivalue_basefield - field: nid - relationship: none - plugin_id: field - entity_type: entity_test_multivalue_basefield - entity_field: id - name: - id: name - table: entity_test_multivalue_basefield__name - field: name - plugin_id: field - entity_type: entity_test_multivalue_basefield - entity_field: name - defaults: - fields: false - filters: false - sorts: - id: - id: id - table: entity_test_multivalue_basefield - field: id - order: asc