You are here

public function SiteMapRssTest::testIncludeRssLinks in Site map 8

Tests include RSS links.

File

src/Tests/SiteMapRssTest.php, line 54

Class

SiteMapRssTest
Test case class for site map RSS feed tests.

Namespace

Drupal\site_map\Tests

Code

public function testIncludeRssLinks() {
  $terms = $this
    ->createTerms($this->vocabulary);
  $feed = '/taxonomy/term/@term/feed';
  $tags = array();

  // Get tags from terms.
  foreach ($terms as $term) {
    $tags[] = $term
      ->label();
  }

  // Create dummy node.
  $title = $this
    ->randomString();
  $edit = array(
    'title[0][value]' => $title,
    'menu[enabled]' => TRUE,
    'menu[title]' => $title,
    $this->field_tags_name => implode(',', $tags),
  );
  $this
    ->drupalPostForm('node/add/article', $edit, t('Save and publish'));

  // Assert that RSS link for front page is included in the site map.
  $this
    ->drupalGet('/sitemap');
  $this
    ->assertLinkByHref('/rss.xml');

  // Assert that RSS links are included in the site map.
  foreach ($terms as $term) {
    $this
      ->assertLinkByHref(format_string($feed, array(
      '@term' => $term
        ->id(),
    )));
  }

  // Change module not to include RSS links.
  $edit = array(
    'show_rss_links' => 0,
  );
  $this
    ->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));

  // Assert that RSS link for front page is not included in the site map.
  $this
    ->drupalGet('/sitemap');
  $this
    ->assertNoLinkByHref('/rss.xml');

  // Assert that RSS links are not included in the site map.
  foreach ($terms as $term) {
    $this
      ->assertNoLinkByHref(format_string($feed, array(
      '@term' => $term
        ->id(),
    )));
  }
}