From 1e95bd705efbdc699ba5d2327c4c404a8edbaf7e Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Thu, 5 Jan 2017 10:46:12 +0000 Subject: [PATCH] Issue #2048733 by Lendude, kostyashupenko, Ankit Agrawal, stBorchert, swati_qa: Taxonomy vocabulary contextual filters are missing --- core/modules/taxonomy/src/TermViewsData.php | 2 +- .../Views/TaxonomyVocabularyArgumentTest.php | 76 ++++++++ ...view.test_argument_taxonomy_vocabulary.yml | 174 ++++++++++++++++++ 3 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 core/modules/taxonomy/src/Tests/Views/TaxonomyVocabularyArgumentTest.php create mode 100644 core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_argument_taxonomy_vocabulary.yml diff --git a/core/modules/taxonomy/src/TermViewsData.php b/core/modules/taxonomy/src/TermViewsData.php index 89b2b55ef29..32a238b9b7f 100644 --- a/core/modules/taxonomy/src/TermViewsData.php +++ b/core/modules/taxonomy/src/TermViewsData.php @@ -67,7 +67,7 @@ class TermViewsData extends EntityViewsData { $data['taxonomy_term_field_data']['vid']['help'] = $this->t('Filter the results of "Taxonomy: Term" to a particular vocabulary.'); unset($data['taxonomy_term_field_data']['vid']['field']); - unset($data['taxonomy_term_field_data']['vid']['argument']); + $data['taxonomy_term_field_data']['vid']['argument']['id'] = 'vocabulary_vid'; unset($data['taxonomy_term_field_data']['vid']['sort']); $data['taxonomy_term_field_data']['name']['field']['id'] = 'term_name'; diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyVocabularyArgumentTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyVocabularyArgumentTest.php new file mode 100644 index 00000000000..532335f1977 --- /dev/null +++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyVocabularyArgumentTest.php @@ -0,0 +1,76 @@ +vocabularies[] = $this->vocabulary; + // Create additional vocabulary. + $vocabulary = Vocabulary::create([ + 'name' => 'Views testing category', + 'vid' => 'views_testing_category', + ]); + $vocabulary->save(); + $this->vocabularies[] = $vocabulary; + + // Create some terms. + $this->terms[0] = $this->createTerm([ + 'name' => 'First', + 'vid' => $this->vocabularies[0]->id(), + ]); + $this->terms[1] = $this->createTerm([ + 'name' => 'Second', + 'vid' => $this->vocabularies[1]->id(), + ]); + } + + /** + * Tests the vocabulary argument handler. + * + * @see Drupal\taxonomy\Plugin\views\argument\VocabularyVid + */ + public function testTermWithVocabularyArgument() { + $this->drupalGet('test_argument_taxonomy_vocabulary/' . $this->vocabularies[0]->id()); + // First term should be present. + $this->assertText($this->terms[0]->label()); + // Second term should not be present. + $this->assertNoText($this->terms[1]->label()); + } + +} diff --git a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_argument_taxonomy_vocabulary.yml b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_argument_taxonomy_vocabulary.yml new file mode 100644 index 00000000000..a90e618f411 --- /dev/null +++ b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_argument_taxonomy_vocabulary.yml @@ -0,0 +1,174 @@ +langcode: en +status: true +dependencies: + module: + - taxonomy + - user +id: test_argument_taxonomy_vocabulary +label: test_argument_taxonomy_vocabulary +module: views +description: '' +tag: '' +base_table: taxonomy_term_field_data +base_field: tid +core: 8.x +display: + default: + display_plugin: default + id: default + display_title: Master + position: 0 + display_options: + access: + type: perm + options: + perm: 'access content' + 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: Apply + 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: none + options: + offset: 0 + style: + type: default + row: + type: 'entity:taxonomy_term' + fields: + name: + id: name + table: taxonomy_term_field_data + field: name + entity_type: taxonomy_term + entity_field: name + label: '' + alter: + alter_text: false + make_link: false + absolute: false + trim: false + word_boundary: false + ellipsis: false + strip_tags: false + html: false + hide_empty: false + empty_zero: false + type: string + settings: + link_to_entity: true + plugin_id: term_name + relationship: none + group_type: group + admin_label: '' + exclude: 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_alter_empty: true + click_sort_column: value + group_column: value + 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 + convert_spaces: false + filters: { } + sorts: { } + title: '' + header: { } + footer: { } + empty: { } + relationships: { } + arguments: + vid: + id: vid + table: taxonomy_term_field_data + field: vid + 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: { } + break_phrase: false + not: false + entity_type: taxonomy_term + entity_field: vid + plugin_id: vocabulary_vid + display_extenders: { } + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url + - user.permissions + tags: { } + page_1: + display_plugin: page + id: page_1 + display_title: Page + position: 1 + display_options: + display_extenders: { } + path: test_argument_taxonomy_vocabulary + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url + - user.permissions + tags: { } +