Chris@17: drupalLogin($this->drupalCreateUser(['administer taxonomy', 'bypass node access', 'administer content types', 'administer node display']));
Chris@17: $this->vocabulary = $this->createVocabulary();
Chris@17: $this->fieldName = 'taxonomy_' . $this->vocabulary->id();
Chris@17:
Chris@17: $handler_settings = [
Chris@17: 'target_bundles' => [
Chris@17: $this->vocabulary->id() => $this->vocabulary->id(),
Chris@17: ],
Chris@17: 'auto_create' => TRUE,
Chris@17: ];
Chris@17: $this->createEntityReferenceField('node', 'article', $this->fieldName, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
Chris@17:
Chris@17: entity_get_form_display('node', 'article', 'default')
Chris@17: ->setComponent($this->fieldName, [
Chris@17: 'type' => 'options_select',
Chris@17: ])
Chris@17: ->save();
Chris@17: entity_get_display('node', 'article', 'default')
Chris@17: ->setComponent($this->fieldName, [
Chris@17: 'type' => 'entity_reference_label',
Chris@17: ])
Chris@17: ->save();
Chris@17: }
Chris@17:
Chris@17: /**
Chris@17: * Tests that terms added to nodes are displayed in core RSS feed.
Chris@17: *
Chris@17: * Create a node and assert that taxonomy terms appear in rss.xml.
Chris@17: */
Chris@17: public function testTaxonomyRss() {
Chris@17: // Create two taxonomy terms.
Chris@17: $term1 = $this->createTerm($this->vocabulary);
Chris@17:
Chris@17: // RSS display must be added manually.
Chris@17: $this->drupalGet("admin/structure/types/manage/article/display");
Chris@17: $edit = [
Chris@17: "display_modes_custom[rss]" => '1',
Chris@17: ];
Chris@17: $this->drupalPostForm(NULL, $edit, t('Save'));
Chris@17:
Chris@17: // Change the format to 'RSS category'.
Chris@17: $this->drupalGet("admin/structure/types/manage/article/display/rss");
Chris@17: $edit = [
Chris@17: "fields[taxonomy_" . $this->vocabulary->id() . "][type]" => 'entity_reference_rss_category',
Chris@17: "fields[taxonomy_" . $this->vocabulary->id() . "][region]" => 'content',
Chris@17: ];
Chris@17: $this->drupalPostForm(NULL, $edit, t('Save'));
Chris@17:
Chris@17: // Post an article.
Chris@17: $edit = [];
Chris@17: $edit['title[0][value]'] = $this->randomMachineName();
Chris@17: $edit[$this->fieldName . '[]'] = $term1->id();
Chris@17: $this->drupalPostForm('node/add/article', $edit, t('Save'));
Chris@17:
Chris@17: // Check that the term is displayed when the RSS feed is viewed.
Chris@17: $this->drupalGet('rss.xml');
Chris@17: $test_element = sprintf(
Chris@17: '