diff --git a/core/modules/taxonomy/config/install/views.view.taxonomy_term.yml b/core/modules/taxonomy/config/install/views.view.taxonomy_term.yml index 4ba669a..6ff1211 100644 --- a/core/modules/taxonomy/config/install/views.view.taxonomy_term.yml +++ b/core/modules/taxonomy/config/install/views.view.taxonomy_term.yml @@ -1,8 +1,16 @@ -base_field: nid +langcode: en +status: true +dependencies: + module: + - taxonomy +id: taxonomy_term +label: 'Taxonomy term' +module: taxonomy +description: 'Content belonging to a certain taxonomy term.' +tag: default base_table: node +base_field: nid core: '8' -description: 'Content belonging to a certain taxonomy term.' -status: true display: default: id: default @@ -131,7 +139,49 @@ display: reduce_duplicates: false plugin_id: taxonomy_index_tid provider: taxonomy - filters: { } + filters: + langcode: + id: langcode + table: node_field_data + field: langcode + relationship: none + group_type: group + admin_label: '' + dependencies: + module: + - views + operator: in + value: + '***LANGUAGE_language_content***': '***LANGUAGE_language_content***' + group: 1 + exposed: false + expose: + operator_id: '' + label: '' + description: '' + use_operator: false + operator: '' + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + plugin_id: language + provider: views style: type: default options: @@ -165,6 +215,8 @@ display: empty: { } relationships: { } fields: { } + field_langcode: '***LANGUAGE_language_content***' + field_langcode_add_to_query: null page_1: id: page_1 display_title: Page @@ -176,6 +228,8 @@ display: options: { } provider: views path: taxonomy/term/% + field_langcode: '***LANGUAGE_language_content***' + field_langcode_add_to_query: null feed_1: id: feed_1 display_title: Feed @@ -225,12 +279,5 @@ display: relationship: none view_mode: default provider: views -label: 'Taxonomy term' -module: taxonomy -id: taxonomy_term -tag: default -langcode: en -dependencies: - module: - - node - - taxonomy + field_langcode: '***LANGUAGE_language_content***' + field_langcode_add_to_query: null diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyTermViewTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyTermViewTest.php new file mode 100644 index 0000000..7bba5b3 --- /dev/null +++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyTermViewTest.php @@ -0,0 +1,126 @@ +admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access')); + $this->drupalLogin($this->admin_user); + + // Create a vocabulary and add two term reference fields to article nodes. + + $this->field_name_1 = drupal_strtolower($this->randomMachineName()); + entity_create('field_storage_config', array( + 'name' => $this->field_name_1, + 'entity_type' => 'node', + 'type' => 'taxonomy_term_reference', + 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, + 'settings' => array( + 'allowed_values' => array( + array( + 'vocabulary' => $this->vocabulary->id(), + 'parent' => 0, + ), + ), + ), + ))->save(); + entity_create('field_instance_config', array( + 'field_name' => $this->field_name_1, + 'bundle' => 'article', + 'entity_type' => 'node', + ))->save(); + entity_get_form_display('node', 'article', 'default') + ->setComponent($this->field_name_1, array( + 'type' => 'options_select', + )) + ->save(); + entity_get_display('node', 'article', 'default') + ->setComponent($this->field_name_1, array( + 'type' => 'taxonomy_term_reference_link', + )) + ->save(); + } + + /** + * Tests that the taxonomy term view is working properly. + */ + public function testTaxonomyTermView() { + // Create terms in the vocabulary. + $term = $this->createTerm($this->vocabulary); + + // Post an article. + $edit = array(); + $edit['title[0][value]'] = $original_title = $this->randomMachineName(); + $edit['body[0][value]'] = $this->randomMachineName(); + $edit["{$this->field_name_1}[]"] = $term->id(); + $this->drupalPostForm('node/add/article', $edit, t('Save')); + $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); + + $this->drupalGet('taxonomy/term/' . $term->id()); + $this->assertText($term->label()); + $this->assertText($node->label()); + + \Drupal::moduleHandler()->install(array('language', 'content_translation')); + $language = new Language(array('id' => 'ur')); + language_save($language); + // Enable translation for the article content type and ensure the change is + // picked up. + content_translation_set_config('node', 'article', 'enabled', TRUE); + $roles = $this->admin_user->getRoles(TRUE); + Role::load(reset($roles)) + ->grantPermission('create content translations') + ->grantPermission('translate any entity') + ->save(); + drupal_static_reset(); + \Drupal::entityManager()->clearCachedDefinitions(); + \Drupal::service('router.builder')->rebuild(); + + $edit['title[0][value]'] = $translated_title = $this->randomMachineName(); + + $this->drupalPostForm('node/' . $node->id() . '/translations/add/en/ur', $edit, t('Save (this translation)')); + + /** @var \Drupal\views\ViewStorageInterface $view */ + $view = View::load('taxonomy_term'); + $view->enable()->save(); + + $this->drupalGet('taxonomy/term/' . $term->id()); + $this->assertText($term->label()); + $this->assertText($original_title); + $this->assertNoText($translated_title); + + $this->drupalGet('ur/taxonomy/term/' . $term->id()); + $this->assertText($term->label()); + $this->assertNoText($original_title); + $this->assertText($translated_title); + } + +}