diff --git a/core/modules/rest/tests/modules/rest_test_views/rest_test_views.install b/core/modules/rest/tests/modules/rest_test_views/rest_test_views.install deleted file mode 100644 index edc5a585f84d90980be2d04936dc690aa932184b..0000000000000000000000000000000000000000 --- a/core/modules/rest/tests/modules/rest_test_views/rest_test_views.install +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -/** - * @file - * Install function for the Rest Test Views module. - */ - -declare(strict_types=1); - -use Drupal\views\Tests\ViewTestData; - -/** - * Implements hook_install(). - */ -function rest_test_views_install(): void { - - // Install the state and schema by for views test data. - \Drupal::state()->set('views_test_data_schema', ViewTestData::schemaDefinition()); - \Drupal::state()->set('views_test_data_views_data', ViewTestData::viewsData()); - drupal_flush_all_caches(); -} diff --git a/core/modules/rest/tests/modules/rest_test_views/test_views/views.view.test_serializer_display_entity.yml b/core/modules/rest/tests/modules/rest_test_views/test_views/views.view.test_serializer_display_entity.yml index 8612f65df475c01036c9b669b1eedcc126bd1785..9444338650fa0d9d3f02ca7962d40a0c0af6e0a7 100644 --- a/core/modules/rest/tests/modules/rest_test_views/test_views/views.view.test_serializer_display_entity.yml +++ b/core/modules/rest/tests/modules/rest_test_views/test_views/views.view.test_serializer_display_entity.yml @@ -2,9 +2,7 @@ langcode: en status: true dependencies: module: - - entity_test - rest - - serialization - user id: test_serializer_display_entity label: 'Test serialize display entity rows' @@ -15,60 +13,42 @@ base_table: entity_test base_field: id display: default: + display_plugin: default id: default display_title: Default - display_plugin: default position: null display_options: - title: 'Test serialize' - exposed_form: - type: basic access: type: perm options: perm: 'access content' cache: type: tag + query: + type: views_query + exposed_form: + type: basic + style: + type: serializer + row: + type: data_entity sorts: id: id: standard table: entity_test field: id + order: DESC + plugin_id: date entity_type: entity_test entity_field: id - plugin_id: date - order: DESC + title: 'Test serialize' arguments: { } - style: - type: serializer - row: - type: data_entity - query: - type: views_query - display_extenders: { } - cache_metadata: - max-age: -1 - contexts: - - entity_test_view_grants - - 'languages:language_interface' - - request_format - - url.query_args - - user.permissions - tags: { } rest_export_1: + display_plugin: rest_export id: rest_export_1 display_title: serializer - display_plugin: rest_export position: null display_options: defaults: access: false - display_extenders: { } path: test/serialize/entity - cache_metadata: - max-age: -1 - contexts: - - entity_test_view_grants - - 'languages:language_interface' - - request_format - tags: { } diff --git a/core/modules/rest/tests/modules/rest_test_views/test_views/views.view.test_serializer_display_field.yml b/core/modules/rest/tests/modules/rest_test_views/test_views/views.view.test_serializer_display_field.yml index cac819a387279aee2395db8ab14ad0daa84bb511..414de42d6b19f87634eb0153bfdf71daa9b5386a 100644 --- a/core/modules/rest/tests/modules/rest_test_views/test_views/views.view.test_serializer_display_field.yml +++ b/core/modules/rest/tests/modules/rest_test_views/test_views/views.view.test_serializer_display_field.yml @@ -3,9 +3,7 @@ status: true dependencies: module: - rest - - serialization - user - - views_test_data id: test_serializer_display_field label: 'Test serializer display field rows' module: rest @@ -15,19 +13,32 @@ base_table: views_test_data base_field: id display: default: + display_plugin: default id: default display_title: Default - display_plugin: default position: null display_options: - title: 'Test serialize' + access: + type: perm + options: + perm: 'access content' + cache: + type: tag + query: + type: views_query + exposed_form: + type: basic + style: + type: serializer + row: + type: data_field fields: name: id: name table: views_test_data field: name - plugin_id: string label: '' + plugin_id: string nothing: id: nothing table: views @@ -45,71 +56,49 @@ display: id: created table: views_test_data field: created - plugin_id: date - date_format: timestamp - custom_date_format: '' - timezone: '' - exposed_form: - type: basic - access: - type: perm - options: - perm: 'access content' - cache: - type: tag + type: timestamp + settings: + date_format: medium + custom_date_format: '' + timezone: '' + plugin_id: field sorts: created: id: created table: views_test_data field: created - plugin_id: date order: DESC + plugin_id: date + title: 'Test serialize' arguments: { } - style: - type: serializer - row: - type: data_field - query: - type: views_query - display_extenders: { } - cache_metadata: - max-age: -1 - contexts: - - 'languages:language_interface' - - request_format - - url.query_args - - user.permissions - tags: { } rest_export_1: + display_plugin: rest_export id: rest_export_1 display_title: serializer - display_plugin: rest_export position: null display_options: + defaults: + access: false + style: false + row: false + path: test/serialize/field access: type: none style: type: serializer row: type: data_field - defaults: - access: false - style: false - row: false - display_extenders: { } - path: test/serialize/field - cache_metadata: - max-age: -1 - contexts: - - 'languages:language_interface' - - request_format - tags: { } rest_export_2: + display_plugin: rest_export id: rest_export_2 display_title: 'serialize - access denied' - display_plugin: rest_export position: null display_options: + defaults: + access: false + style: false + row: false + path: test/serialize/denied access: type: perm options: @@ -118,16 +107,3 @@ display: type: serializer row: type: data_field - defaults: - access: false - style: false - row: false - display_extenders: { } - path: test/serialize/denied - cache_metadata: - max-age: -1 - contexts: - - 'languages:language_interface' - - request_format - - user.permissions - tags: { } diff --git a/core/modules/views/src/Plugin/ViewsHandlerManager.php b/core/modules/views/src/Plugin/ViewsHandlerManager.php index 99502754f49b31e13beade8c030a866492d5dc6b..e1182507bf86f62499efecd2de356e527cdcb4dc 100644 --- a/core/modules/views/src/Plugin/ViewsHandlerManager.php +++ b/core/modules/views/src/Plugin/ViewsHandlerManager.php @@ -107,7 +107,6 @@ public function getHandler(array $item, ?string $override_plugin_id = NULL): Vie } } - // First priority is to use the override. // When aggregation is enabled, particular plugins need to be // replaced in order to override the query with a query that // can run the aggregate counts, sums, or averages for example. @@ -115,24 +114,13 @@ public function getHandler(array $item, ?string $override_plugin_id = NULL): Vie // for example which aggressively overrides any filter used // by a number of mathematical-type queries regardless of the // original filter. - if ($override_plugin_id) { - $handler = $this->createInstance($override_plugin_id, $definition); - if (!method_exists($handler, 'broken') || !$handler->broken()) { - return $handler; - } + $plugin_id = $override_plugin_id ?: $definition['id']; + // Try to use the overridden handler. + $handler = $this->createInstance($plugin_id, $definition); + if ($override_plugin_id && method_exists($handler, 'broken') && $handler->broken()) { + $handler = $this->createInstance($definition['id'], $definition); } - - // Then try the configuration provided for the handler. - if (isset($item['plugin_id'])) { - $handler = $this->createInstance($item['plugin_id'], $definition); - if (!method_exists($handler, 'broken') || !$handler->broken()) { - return $handler; - } - } - - // Finally, fall back to the default configuration suggested - // by the view data. - return $this->createInstance($definition['id'], $definition); + return $handler; } // Finally, use the 'broken' handler. diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_block_exposed_ajax.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_block_exposed_ajax.yml index 69e49097ad171be7d6e9d341430df496964be44e..649b5fe8abdef6223e4f45f8bf4745cfe8d0090e 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_block_exposed_ajax.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_block_exposed_ajax.yml @@ -35,7 +35,7 @@ display: field: type id: type table: node_field_data - plugin_id: bundle + plugin_id: in_operator entity_type: node entity_field: type pager: diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_block_exposed_ajax_with_page.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_block_exposed_ajax_with_page.yml index ab6321d8b6f2c5dfa07e993d743f21d6c2b6469b..c484c6b1389e7f4225c698245e928d4b7d191a15 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_block_exposed_ajax_with_page.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_block_exposed_ajax_with_page.yml @@ -35,7 +35,7 @@ display: field: type id: type table: node_field_data - plugin_id: bundle + plugin_id: in_operator entity_type: node entity_field: type pager: diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_click_sort.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_click_sort.yml index 5aaa351c1ae212d8597bc53d2555e2456fa27522..3ab5ecb6689400b5276c6c0e3ad40cf78bb0c62f 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_click_sort.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_click_sort.yml @@ -1,44 +1,40 @@ langcode: en status: true -dependencies: - module: - - user - - views_test_data +dependencies: { } id: test_click_sort label: test_click_sort module: views description: '' tag: '' base_table: views_test_data -base_field: id +base_field: nid display: default: - id: default - display_title: Default - display_plugin: default - position: null display_options: fields: id: id: id table: views_test_data field: id - plugin_id: numeric label: ID + plugin_id: numeric name: id: name table: views_test_data field: name + label: Name plugin_id: string - label: '' created: id: created table: views_test_data field: created - plugin_id: date - date_format: timestamp - custom_date_format: '' - timezone: '' + label: created + plugin_id: field + type: timestamp + settings: + date_format: medium + custom_date_format: '' + timezone: '' access: type: none cache: @@ -55,17 +51,14 @@ display: default_sort_order: desc created: sortable: false - cache_metadata: - max-age: -1 - contexts: - - 'languages:language_interface' - - url.query_args - - user.permissions - tags: { } - page_1: - id: page_1 - display_title: Page - display_plugin: page + display_plugin: default + display_title: Default + id: default position: 0 + page_1: display_options: path: test_click_sort + display_plugin: page + display_title: Page + id: page_1 + position: 0 diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_click_sort_ajax.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_click_sort_ajax.yml index 534e3eaecbac31566b6ae2b69289be3b0a1cb5d5..bf65e0eaf3792bbbee1adb48e84b8b9eb682dcc8 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_click_sort_ajax.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_click_sort_ajax.yml @@ -1,105 +1,41 @@ langcode: en status: true -dependencies: - module: - - views_test_data +dependencies: { } id: test_click_sort_ajax label: test_click_sort_ajax module: views description: '' tag: '' base_table: views_test_data -base_field: id +base_field: nid display: default: - id: default - display_title: Default - display_plugin: default - position: null display_options: + use_ajax: true fields: id: id: id table: views_test_data field: id - plugin_id: numeric label: ID + plugin_id: numeric name: id: name table: views_test_data field: name - relationship: none - group_type: group - admin_label: '' - plugin_id: string label: Name - 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: true - element_wrapper_type: '' - element_wrapper_class: '' - element_default_classes: true - empty: '' - hide_empty: false - empty_zero: false - hide_alter_empty: true + plugin_id: string created: id: created table: views_test_data field: created - plugin_id: date - date_format: timestamp - custom_date_format: '' - timezone: '' - pager: - type: mini - options: - offset: 0 - pagination_heading_level: h4 - items_per_page: 1 - total_pages: null - id: 0 - tags: - next: 'Next ›' - previous: '‹ Previous' - 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 + label: created + plugin_id: field + type: timestamp + settings: + date_format: medium + custom_date_format: '' + timezone: '' access: type: none cache: @@ -107,61 +43,23 @@ display: style: type: table options: - grouping: { } - row_class: '' - default_row_class: true - columns: - id: id - name: name - created: created - default: id info: id: - sortable: false + sortable: true default_sort_order: asc - align: '' - separator: '' - empty_column: false - responsive: '' name: sortable: true default_sort_order: desc - align: '' - separator: '' - empty_column: false - responsive: '' created: sortable: false - default_sort_order: asc - align: '' - separator: '' - empty_column: false - responsive: '' - override: true - sticky: false - summary: '' - empty_table: false - caption: '' - description: '' - use_ajax: true - display_extenders: { } - cache_metadata: - max-age: -1 - contexts: - - 'languages:language_interface' - - url.query_args - tags: { } - page_1: - id: page_1 - display_title: Page - display_plugin: page + display_plugin: default + display_title: Default + id: default position: 0 + page_1: display_options: - display_extenders: { } path: test_click_sort - cache_metadata: - max-age: -1 - contexts: - - 'languages:language_interface' - - url.query_args - tags: { } + display_plugin: page + display_title: Page + id: page_1 + position: 0 diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_entity_test_protected_access.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_entity_test_protected_access.yml index 1a3bf61bc6880f14eee9aaed5122bb2dc02d7029..a41124d71e84c327c5fa4388fb944ffb746c6831 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_entity_test_protected_access.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_entity_test_protected_access.yml @@ -86,7 +86,7 @@ display: exclude: false entity_type: entity_test entity_field: test_text_access - plugin_id: field + plugin_id: standard empty: '' hide_empty: false empty_zero: false diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_block.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_block.yml index ebcf5c9f704d4f81eda759d7869344259a96df3c..2df02b0b6633756e16b957d4fffc8cbefef3d1c1 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_block.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_block.yml @@ -1,8 +1,6 @@ langcode: en status: true dependencies: - config: - - core.entity_view_mode.node.teaser module: - node id: test_exposed_block @@ -14,83 +12,66 @@ base_table: node_field_data base_field: nid display: default: - id: default - display_title: Default - display_plugin: default - position: 0 display_options: title: 'Test Exposed Block' - pager: - type: full - exposed_form: - type: basic - options: - reset_button: true access: type: none cache: type: tag + exposed_form: + options: + reset_button: true + type: basic filters: type: + expose: + identifier: type + label: 'Content: Type' + operator_id: type_op + reduce: false + exposed: true + field: type id: type table: node_field_data - field: type + plugin_id: in_operator entity_type: node entity_field: type - plugin_id: bundle - exposed: true - expose: - operator_id: type_op - label: 'Content: Type' - identifier: type - reduce: false + pager: + type: full + query: + options: + query_comment: '' + type: views_query style: type: default row: type: 'entity:node' - query: - type: views_query - options: - query_comment: '' - display_extenders: { } - cache_metadata: - max-age: -1 - contexts: - - 'languages:language_interface' - - url - - url.query_args - - 'user.node_grants:view' - tags: { } + display_plugin: default + display_title: Default + id: default + position: 0 + page_1: + display_options: + path: test_exposed_block + exposed_block: true + display_plugin: page + display_title: Page + id: page_1 + position: 0 block_1: + display_plugin: block id: block_1 display_title: Block - display_plugin: block position: 2 display_options: - exposed_block: true display_extenders: { } - cache_metadata: - max-age: -1 - contexts: - - 'languages:language_interface' - - url - - url.query_args - - 'user.node_grants:view' - tags: { } - page_1: - id: page_1 - display_title: Page - display_plugin: page - position: 0 - display_options: exposed_block: true - display_extenders: { } - path: test_exposed_block cache_metadata: max-age: -1 contexts: + - 'languages:language_content' - 'languages:language_interface' - - url - url.query_args - 'user.node_grants:view' + - user.permissions tags: { } diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form_buttons.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form_buttons.yml index 89b658d11dc30deecb6fcc92ac212ff7ba932d4a..9a3605845e80e46b34f856d3184f085471616c51 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form_buttons.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form_buttons.yml @@ -1,8 +1,6 @@ langcode: en status: true dependencies: - config: - - core.entity_view_mode.node.teaser module: - node id: test_exposed_form_buttons @@ -14,66 +12,48 @@ base_table: node_field_data base_field: nid display: default: - id: default - display_title: Default - display_plugin: default - position: 0 display_options: - pager: - type: full - exposed_form: - type: basic - options: - reset_button: true access: type: none cache: type: tag + exposed_form: + options: + reset_button: true + type: basic filters: type: + expose: + identifier: type + label: 'Content: Type' + operator_id: type_op + reduce: false + description: 'Exposed description' + exposed: true + field: type id: type table: node_field_data - field: type + plugin_id: in_operator entity_type: node entity_field: type - plugin_id: bundle - exposed: true - expose: - operator_id: type_op - label: 'Content: Type' - description: 'Exposed description' - identifier: type - reduce: false + pager: + type: full + query: + options: + query_comment: '' + type: views_query style: type: default row: type: 'entity:node' - query: - type: views_query - options: - query_comment: '' - display_extenders: { } - cache_metadata: - max-age: -1 - contexts: - - 'languages:language_interface' - - url - - url.query_args - - 'user.node_grants:view' - tags: { } - page_1: - id: page_1 - display_title: Page - display_plugin: page + display_plugin: default + display_title: Default + id: default position: 0 + page_1: display_options: - display_extenders: { } path: test_exposed_form_buttons - cache_metadata: - max-age: -1 - contexts: - - 'languages:language_interface' - - url - - url.query_args - - 'user.node_grants:view' - tags: { } + display_plugin: page + display_title: Page + id: page_1 + position: 0 diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form_checkboxes.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form_checkboxes.yml index 3707472faa9c56637ac08b10dd89ee9259cd71b4..f3caf6512a69d45784923c972cf4e8ca4f965e09 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form_checkboxes.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form_checkboxes.yml @@ -2,8 +2,7 @@ langcode: en status: true dependencies: config: - - core.entity_view_mode.node.teaser - - taxonomy.vocabulary.tags + - taxonomy.vocabulary.test_exposed_checkboxes module: - node - taxonomy @@ -16,44 +15,33 @@ base_table: node_field_data base_field: nid display: default: - id: default - display_title: Default - display_plugin: default - position: 0 display_options: - pager: - type: full - exposed_form: - type: basic - options: - reset_button: true access: type: none cache: type: tag + exposed_form: + options: + reset_button: true + type: basic filters: - type_1: - id: type_1 + type: + id: type table: node_field_data field: type relationship: none group_type: group admin_label: '' - entity_type: node - entity_field: type - plugin_id: bundle operator: in value: { } group: 1 exposed: true expose: - operator_id: type_1_op - label: 'Content type' - description: '' + operator_id: type_op + label: 'Content: Type' + description: 'Exposed description' use_operator: false - operator: type_1_op - operator_limit_selection: false - operator_list: { } + operator: '' identifier: type required: false remember: false @@ -73,6 +61,9 @@ display: default_group: All default_group_multiple: { } group_items: { } + plugin_id: in_operator + entity_type: node + entity_field: type tid: id: tid table: taxonomy_index @@ -80,7 +71,6 @@ display: relationship: none group_type: group admin_label: '' - plugin_id: taxonomy_index_tid operator: and value: { } group: 1 @@ -91,8 +81,6 @@ display: description: '' use_operator: false operator: tid_op - operator_limit_selection: false - operator_list: { } identifier: tid required: false remember: false @@ -113,45 +101,50 @@ display: default_group_multiple: { } group_items: { } reduce_duplicates: false - vid: tags type: select - hierarchy: false limit: true + vid: test_exposed_checkboxes + hierarchy: false error_message: true - filter_groups: - operator: AND - groups: - 1: AND + plugin_id: taxonomy_index_tid + pager: + type: full + query: + options: + query_comment: '' + type: views_query style: type: default row: type: 'entity:node' - query: - type: views_query - options: - query_comment: '' display_extenders: { } + display_plugin: default + display_title: Default + id: default + position: 0 cache_metadata: max-age: -1 contexts: - 'languages:language_interface' - url - url.query_args + - user - 'user.node_grants:view' tags: { } page_1: - id: page_1 - display_title: Page - display_plugin: page - position: 0 display_options: - display_extenders: { } path: test_exposed_form_checkboxes + display_extenders: { } + display_plugin: page + display_title: Page + id: page_1 + position: 0 cache_metadata: max-age: -1 contexts: - 'languages:language_interface' - url - url.query_args + - user - 'user.node_grants:view' tags: { } diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form_pager.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form_pager.yml index bbddc9f8d34c81c29f92064f7a0758e011d1ee54..49555262930794980bfc6c59d9b8ff4c5aab44da 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form_pager.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form_pager.yml @@ -60,7 +60,7 @@ display: default_group: All default_group_multiple: { } group_items: { } - plugin_id: bundle + plugin_id: in_operator entity_type: node entity_field: type created: diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_filter_in_operator_ui.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_filter_in_operator_ui.yml index 8b072fb19193f6325c167b28e199a0378fcde3e0..46b4412664a3226ed2b406a01d493969148ee41f 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_filter_in_operator_ui.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_filter_in_operator_ui.yml @@ -63,7 +63,7 @@ display: field: type id: type table: node_field_data - plugin_id: bundle + plugin_id: in_operator entity_type: node entity_field: type nid: diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_history.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_history.yml index d67f17051828080cee04ea9f20aef348bb4cf008..c2b25fff96970d27d332d644672b835ea28b1697 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_history.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_history.yml @@ -188,7 +188,8 @@ display: group_type: group admin_label: '' operator: '=' - value: '' + value: + value: '' group: 1 exposed: false expose: @@ -215,7 +216,7 @@ display: default_group: All default_group_multiple: { } group_items: { } - plugin_id: history_user_timestamp + plugin_id: date defaults: filters: false filter_groups: false diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_remember_selected.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_remember_selected.yml index 0d842e4c05a39dec61d0cc9aa5aa3221f1d0662d..6d3b049afceac156fce67866b7e90bdfb17165d4 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_remember_selected.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_remember_selected.yml @@ -40,7 +40,7 @@ display: admin_label: '' entity_type: node entity_field: type - plugin_id: bundle + plugin_id: in_operator operator: in value: { } group: 1 diff --git a/core/modules/views/tests/modules/views_test_data_alter/src/Hook/ViewsTestDataAlterHooks.php b/core/modules/views/tests/modules/views_test_data_alter/src/Hook/ViewsTestDataAlterHooks.php deleted file mode 100644 index 3b6cc1f35a3dfe1425b9a6fe2d309e25bd41315e..0000000000000000000000000000000000000000 --- a/core/modules/views/tests/modules/views_test_data_alter/src/Hook/ViewsTestDataAlterHooks.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\views_test_data_alter\Hook; - -use Drupal\Core\Hook\Attribute\Hook; - -/** - * Hook implementations for views_test_data_alter. - */ -class ViewsTestDataAlterHooks { - - /** - * Implements hook_views_data_alter(). - */ - #[Hook('views_data_alter')] - public function viewsDataAlter(array &$data): void { - // Modify a filter to use a different filter handler plugin - // by default so that we can test that the handler used - // respects the handler plugin ID specified in the - // configuration. - $data['node_field_data']['status']['filter']['id'] = 'numeric'; - } - -} diff --git a/core/modules/views/tests/modules/views_test_data_alter/views_test_data_alter.info.yml b/core/modules/views/tests/modules/views_test_data_alter/views_test_data_alter.info.yml deleted file mode 100644 index ac3d0bbb1217bf419672cb139d4d6064583ac357..0000000000000000000000000000000000000000 --- a/core/modules/views/tests/modules/views_test_data_alter/views_test_data_alter.info.yml +++ /dev/null @@ -1,7 +0,0 @@ -name: 'Views Test Data Alter' -type: module -description: 'Test module for Views to alter data.' -package: Testing -version: VERSION -dependencies: - - drupal:views diff --git a/core/modules/views/tests/src/Functional/Entity/BaseFieldAccessTest.php b/core/modules/views/tests/src/Functional/Entity/BaseFieldAccessTest.php index 14b713d8cd587390aa04d74a82bc08ee0f07b619..8ee795e5b60e344900ff3a029f3c3e59fc0e6fa8 100644 --- a/core/modules/views/tests/src/Functional/Entity/BaseFieldAccessTest.php +++ b/core/modules/views/tests/src/Functional/Entity/BaseFieldAccessTest.php @@ -39,6 +39,15 @@ class BaseFieldAccessTest extends ViewTestBase { protected function setUp($import_test_views = TRUE, $modules = ['views_test_config', 'comment_test_views']): void { parent::setUp($import_test_views, $modules); + \Drupal::state()->set('entity_test.views_data', [ + 'entity_test' => [ + 'test_text_access' => [ + 'field' => [ + 'id' => 'standard', + ], + ], + ], + ]); $entity_1 = EntityTest::create([ 'test_text_access' => 'no access value', ]); diff --git a/core/modules/views/tests/src/Functional/Handler/HandlerTest.php b/core/modules/views/tests/src/Functional/Handler/HandlerTest.php index c6523c40c10042689b64830361db2f2c84220579..fa9af239ca3eb248913402ec437994ea2d3b507e 100644 --- a/core/modules/views/tests/src/Functional/Handler/HandlerTest.php +++ b/core/modules/views/tests/src/Functional/Handler/HandlerTest.php @@ -333,12 +333,6 @@ public function testSetRelationship(): void { * @see \Drupal\views\Plugin\views\HandlerBase::placeholder() */ public function testPlaceholder(): void { - // Change the test view to use the test field plugin which has the - // additional get placeholder method. - $config = $this->config('views.view.test_view'); - $config->set('display.default.display_options.fields.name.plugin_id', 'test_field'); - $config->save(); - $view = Views::getView('test_view'); $view->initHandlers(); $view->initQuery(); @@ -348,7 +342,7 @@ public function testPlaceholder(): void { $field = $handler->field; $string = ':' . $table . '_' . $field; - // Make sure the placeholder variables contain the expected values. + // Make sure the placeholder variables are like expected. $this->assertEquals($string, $handler->getPlaceholder()); $this->assertEquals($string . 1, $handler->getPlaceholder()); $this->assertEquals($string . 2, $handler->getPlaceholder()); @@ -375,7 +369,7 @@ public function testAccess(): void { $views_data = $this->viewsData(); $views_data = $views_data['views_test_data']; - // Enable access only to the callback field and deny access for the callback and the arguments. + // Enable access to callback only field and deny for callback + arguments. $this->config('views_test_data.tests')->set('handler_access_callback', TRUE)->save(); $this->config('views_test_data.tests')->set('handler_access_callback_argument', FALSE)->save(); $view->initDisplay(); @@ -388,7 +382,7 @@ public function testAccess(): void { } } - // Enable access to the callback and the argument handlers and deny access for the callback. + // Enable access to the callback + argument handlers and deny for callback. $this->config('views_test_data.tests')->set('handler_access_callback', FALSE)->save(); $this->config('views_test_data.tests')->set('handler_access_callback_argument', TRUE)->save(); $view->destroy(); diff --git a/core/modules/views/tests/src/Functional/Plugin/ExposedFormCheckboxesTest.php b/core/modules/views/tests/src/Functional/Plugin/ExposedFormCheckboxesTest.php index a5b1b27db056bd57f6565b51aee4fc4eecda788c..a6e39524c245ced4ac1967b3ba8384f1c127f227 100644 --- a/core/modules/views/tests/src/Functional/Plugin/ExposedFormCheckboxesTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormCheckboxesTest.php @@ -61,7 +61,7 @@ protected function setUp($import_test_views = TRUE, $modules = []): void { // vocabulary is in place to meet the view dependencies. $vocabulary = Vocabulary::create([ 'name' => 'test_exposed_checkboxes', - 'vid' => 'tags', + 'vid' => 'test_exposed_checkboxes', 'nodes' => ['article' => 'article'], ]); $vocabulary->save(); diff --git a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php index 933554003ff0c5dcf19b78561ff42e5516240c03..fa9995eea82ee2e04fe4756b14cbeaaf8df4372a 100644 --- a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php @@ -116,7 +116,7 @@ public function testExposedIdentifier(): void { 'field' => 'type', 'id' => 'type', 'table' => 'node_field_data', - 'plugin_id' => 'bundle', + 'plugin_id' => 'in_operator', 'entity_type' => 'node', 'entity_field' => 'type', 'expose' => [ diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldTimeIntervalTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldTimeIntervalTest.php index 25f1db02ecc16eab11b3134e4ce11e5c313349a3..9f4d930c6f780d8896860b84d6abb6b01e15baae 100644 --- a/core/modules/views/tests/src/Kernel/Handler/FieldTimeIntervalTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/FieldTimeIntervalTest.php @@ -44,16 +44,13 @@ class FieldTimeIntervalTest extends ViewsKernelTestBase { * Tests the TimeInterval handler. */ public function testFieldTimeInterval(): void { - $view_config = $this->config('views.view.test_view'); - $view_config->set('display.default.display_options.fields.age.plugin_id', 'time_interval'); - foreach (array_keys($this->ages) as $delta) { + $view = Views::getView('test_view'); + $view->setDisplay(); + $this->executeView($view); + foreach ($view->result as $delta => $row) { [, $formatted_value, $granularity] = $this->ages[$delta]; - $view_config->set('display.default.display_options.fields.age.granularity', $granularity); - $view_config->save(); - $view = Views::getView('test_view'); - $view->setDisplay(); - $this->executeView($view); - $this->assertEquals($formatted_value, $view->field['age']->advancedRender($view->result[$delta])); + $view->field['age']->options['granularity'] = $granularity; + $this->assertEquals($formatted_value, $view->field['age']->advancedRender($row)); } } diff --git a/core/modules/views/tests/src/Kernel/ModuleTest.php b/core/modules/views/tests/src/Kernel/ModuleTest.php index ff2d42e327e8b7f6670831a7011223f7d8d601ec..b3cdf6446d9deebeabf4f64ecd2d932bbdbdef7d 100644 --- a/core/modules/views/tests/src/Kernel/ModuleTest.php +++ b/core/modules/views/tests/src/Kernel/ModuleTest.php @@ -8,7 +8,6 @@ use Drupal\Core\Form\FormState; use Drupal\views\Plugin\views\area\Broken as BrokenArea; use Drupal\views\Plugin\views\field\Broken as BrokenField; -use Drupal\views\Plugin\views\filter\BooleanOperator; use Drupal\views\Plugin\views\filter\Broken as BrokenFilter; use Drupal\views\Plugin\views\filter\Standard; use Drupal\views\Plugin\views\ViewsHandlerInterface; @@ -26,12 +25,12 @@ class ModuleTest extends ViewsKernelTestBase { * * @var array */ - public static $testViews = ['test_view_status', 'test_view', 'test_argument', 'test_redirect_view']; + public static $testViews = ['test_view_status', 'test_view', 'test_argument']; /** * {@inheritdoc} */ - protected static $modules = ['field', 'user', 'block', 'node', 'views_test_data_alter']; + protected static $modules = ['field', 'user', 'block']; /** * Stores the last triggered error. @@ -110,14 +109,6 @@ public function testViewsGetHandler(): void { ]; $handler = $this->container->get('plugin.manager.views.filter')->getHandler($item, 'standard'); $this->assertInstanceOf(Standard::class, $handler); - - // Test that the configuration is respected rather than overridden - // by views data. Using assertSame() here to make the error more clearly - // show what the result is when an error is caused. - $test_view_config = $this->config('views.view.test_redirect_view'); - $item = $test_view_config->get('display.default.display_options.filters.status'); - $handler = $this->container->get('plugin.manager.views.filter')->getHandler($item); - $this->assertSame(BooleanOperator::class, get_class($handler)); } /** diff --git a/core/modules/views/tests/src/Kernel/Plugin/ExposedFormRenderTest.php b/core/modules/views/tests/src/Kernel/Plugin/ExposedFormRenderTest.php index fa4969d1e9b6d6a43cd80a42e91f496eda86208d..97d670634b3f6f7e9986f94ea283a1120f288181 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/ExposedFormRenderTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/ExposedFormRenderTest.php @@ -5,12 +5,8 @@ namespace Drupal\Tests\views\Kernel\Plugin; use Drupal\Component\Utility\Html; -use Drupal\Core\Form\FormState; -use Drupal\Core\Path\CurrentPathStack; use Drupal\node\Entity\NodeType; use Drupal\Tests\views\Kernel\ViewsKernelTestBase; -use Drupal\views\ExposedFormCache; -use Drupal\views\Form\ViewsExposedForm; use Drupal\views\Views; /** @@ -24,7 +20,7 @@ class ExposedFormRenderTest extends ViewsKernelTestBase { /** * {@inheritdoc} */ - public static $testViews = ['test_exposed_form_buttons', 'test_exposed_admin_ui']; + public static $testViews = ['test_exposed_form_buttons']; /** * {@inheritdoc} @@ -68,38 +64,85 @@ public function testExposedFormRawInput(): void { 'name' => 'Article', ])->save(); - // Build the form state. - $form = []; - $view = Views::getView('test_exposed_admin_ui'); + $view = Views::getView('test_exposed_form_buttons'); $view->setDisplay(); + $view->displayHandlers->get('default')->overrideOption('filters', [ + 'type' => [ + 'exposed' => TRUE, + 'field' => 'type', + 'id' => 'type', + 'table' => 'node_field_data', + 'plugin_id' => 'in_operator', + 'entity_type' => 'node', + 'entity_field' => 'type', + 'expose' => [ + 'identifier' => 'type', + 'label' => 'Content: Type', + 'operator_id' => 'type_op', + 'reduce' => FALSE, + 'multiple' => FALSE, + ], + ], + 'type_with_default_value' => [ + 'exposed' => TRUE, + 'field' => 'type', + 'id' => 'type_with_default_value', + 'table' => 'node_field_data', + 'plugin_id' => 'in_operator', + 'entity_type' => 'node', + 'entity_field' => 'type', + 'value' => ['article', 'article'], + 'expose' => [ + 'identifier' => 'type_with_default_value', + 'label' => 'Content: Type with value', + 'operator_id' => 'type_op', + 'reduce' => FALSE, + 'multiple' => FALSE, + ], + ], + 'multiple_types' => [ + 'exposed' => TRUE, + 'field' => 'type', + 'id' => 'multiple_types', + 'table' => 'node_field_data', + 'plugin_id' => 'in_operator', + 'entity_type' => 'node', + 'entity_field' => 'type', + 'expose' => [ + 'identifier' => 'multiple_types', + 'label' => 'Content: Type (multiple)', + 'operator_id' => 'type_op', + 'reduce' => FALSE, + 'multiple' => TRUE, + ], + ], + 'multiple_types_with_default_value' => [ + 'exposed' => TRUE, + 'field' => 'type', + 'id' => 'multiple_types_with_default_value', + 'table' => 'node_field_data', + 'plugin_id' => 'in_operator', + 'entity_type' => 'node', + 'entity_field' => 'type', + 'value' => ['article', 'article'], + 'expose' => [ + 'identifier' => 'multiple_types_with_default_value', + 'label' => 'Content: Type with default value (multiple)', + 'operator_id' => 'type_op', + 'reduce' => FALSE, + 'multiple' => TRUE, + ], + ], + ]); + $view->save(); $this->executeView($view); - $form_state = new FormState(); - $form_state->set('view', $view); - $form_state->setValue('type', 'article'); - - // Mock the exposed form. - $exposed_form_cache = $this->createMock(ExposedFormCache::class); - $current_path_stack = $this->createMock(CurrentPathStack::class); - $exposed_form = new ViewsExposedForm($exposed_form_cache, $current_path_stack); - $exposed_form->submitForm($form, $form_state); - $updated_view = $form_state->get('view'); - $expected = [ - 'type' => 'article', - ]; - $this->assertSame($updated_view->exposed_raw_input, $expected); - - $form_state->setValue('type', ['article', 'page']); - $exposed_form->submitForm($form, $form_state); - $updated_view = $form_state->get('view'); - $expected = [ - 'type' => [ - 'article', - 'page', - ], + 'type' => 'All', + 'type_with_default_value' => 'article', + 'multiple_types_with_default_value' => ['article' => 'article'], ]; - $this->assertSame($updated_view->exposed_raw_input, $expected); + $this->assertSame($view->exposed_raw_input, $expected); } }