1 taxonomy.test TaxonomyRSSTestCase::testTaxonomyRSS()

Tests that terms added to nodes are displayed in core RSS feed.

Create a node and assert that taxonomy terms appear in rss.xml.

File

core/modules/taxonomy/tests/taxonomy.test, line 956
Tests for taxonomy.module.

Class

TaxonomyRSSTestCase
Tests the rendering of term reference fields in RSS feeds.

Code

function testTaxonomyRSS() {
  // Create two taxonomy terms.
  $term1 = $this->createTerm($this->vocabulary);

  // RSS display must be added manually.
  $this->backdropGet("admin/structure/types/manage/post/display");
  list($enable_link) = $this->xpath('//tr[contains(@class, "view-mode--rss")]//a');
  $enable_href_parts = backdrop_parse_url($enable_link['href']);
  $this->backdropGet($enable_href_parts['path'], $enable_href_parts);

  // Change the format to 'RSS category'.
  $this->backdropGet("admin/structure/types/manage/post/display/rss");
  $edit = array(
    "fields[taxonomy_" . $this->vocabulary->machine_name . "][type]" => 'taxonomy_term_reference_rss_category',
  );
  $this->backdropPost(NULL, $edit, t('Save'));

  // Post a post.
  $edit = array();
  $langcode = LANGUAGE_NONE;
  $edit["title"] = $this->randomName();
  $edit[$this->instance['field_name'] . '[' . $langcode . '][]'] = $term1->tid;
  $this->backdropPost('node/add/post', $edit, t('Save'));

  // Check that the term is displayed when the RSS feed is viewed.
  $this->backdropGet('rss.xml');
  $test_element = array(
    'key' => 'category',
    'value' => $term1->name,
    'attributes' => array(
      'domain' => url('taxonomy/term/' . $term1->tid, array('absolute' => TRUE)),
    ),
  );
  $this->assertRaw(format_xml_elements(array($test_element)), 'Term is displayed when viewing the rss feed.');
}