diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php index f1ca0dd..8329d04 100644 --- a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php +++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php @@ -8,6 +8,7 @@ namespace Drupal\taxonomy\Tests\Views; use Drupal\views\Views; +use Drupal\taxonomy\Entity\Vocabulary; /** * Tests the "All terms" taxonomy term field handler. @@ -23,7 +24,10 @@ class TaxonomyFieldAllTermsTest extends TaxonomyTestBase { */ public static $testViews = array('taxonomy_all_terms_test'); - function testViewsHandlerAllTermsField() { + /** + * Tests the "all terms" field handler. + */ + public function testViewsHandlerAllTermsField() { $view = Views::getView('taxonomy_all_terms_test'); $this->executeView($view); $this->drupalGet('taxonomy_all_terms_test'); @@ -39,4 +43,28 @@ function testViewsHandlerAllTermsField() { $this->assertEqual($actual[1]->__toString(), $this->term2->label()); } + /** + * Tests token replacement in the "all terms" field handler. + */ + public function testViewsHandlerAllTermsWithTokens() { + $view = Views::getView('taxonomy_all_terms_test'); + $this->drupalGet('taxonomy_all_terms_token_test'); + + // Term itself: {{ term_node_tid }} + $this->assertText('Term: ' . $this->term1->getName()); + + // The taxonomy term ID for the term: {{ term_node_tid__tid }} + $this->assertText('The taxonomy term ID for the term: ' . $this->term1->id()); + + // The taxonomy term name for the term: {{ term_node_tid__name }} + $this->assertText('The taxonomy term name for the term: ' . $this->term1->getName()); + + // The machine name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary_vid }} + $this->assertText('The machine name for the vocabulary the term belongs to: ' . $this->term1->getVocabularyId()); + + // The name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary }} + $vocabulary = Vocabulary::load($this->term1->bundle()); + $this->assertText('The name for the vocabulary the term belongs to: ' . $vocabulary->label()); + } + } diff --git a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.taxonomy_all_terms_test.yml b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.taxonomy_all_terms_test.yml index 7e2673c..ce71f76 100644 --- a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.taxonomy_all_terms_test.yml +++ b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.taxonomy_all_terms_test.yml @@ -162,7 +162,7 @@ display: cache_metadata: contexts: - 'languages:language_interface' - - 'url.query_args.pagers:0' + - url.query_args - 'user.node_grants:view' - user.permissions cacheable: false @@ -177,7 +177,82 @@ display: cache_metadata: contexts: - 'languages:language_interface' - - 'url.query_args.pagers:0' + - url.query_args + - 'user.node_grants:view' + - user.permissions + cacheable: false + page_2: + display_plugin: page + id: page_2 + display_title: 'Token tests' + position: 2 + display_options: + display_extenders: { } + display_description: '' + fields: + term_node_tid: + id: term_node_tid + table: node_field_data + field: term_node_tid + relationship: none + group_type: group + admin_label: '' + label: '' + exclude: false + alter: + alter_text: true + text: "Term: {{ term_node_tid }}
\nThe taxonomy term ID for the term: {{ term_node_tid__tid }}
\nThe taxonomy term name for the term: {{ term_node_tid__name }}
\nThe machine name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary_vid }}
\nThe name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary }}
" + 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 + type: separator + separator: '
' + link_to_taxonomy: false + limit: false + vids: + tags: '0' + entity_type: node + plugin_id: taxonomy_index_tid + defaults: + fields: false + path: taxonomy_all_terms_token_test + cache_metadata: + contexts: + - 'languages:language_interface' + - url.query_args - 'user.node_grants:view' - user.permissions cacheable: false