public function SitemapTaxonomyTermsRssTest::testIncludeRssLinks in Sitemap 2.0.x
Same name and namespace in other branches
- 8.2 src/Tests/SitemapTaxonomyTermsRssTest.php \Drupal\sitemap\Tests\SitemapTaxonomyTermsRssTest::testIncludeRssLinks()
- 8 src/Tests/SitemapTaxonomyTermsRssTest.php \Drupal\sitemap\Tests\SitemapTaxonomyTermsRssTest::testIncludeRssLinks()
Tests included RSS links.
File
- src/Tests/ SitemapTaxonomyTermsRssTest.php, line 27 
Class
- SitemapTaxonomyTermsRssTest
- Tests the display of RSS links based on sitemap settings.
Namespace
Drupal\sitemap\TestsCode
public function testIncludeRssLinks() {
  // The vocabulary is already configured to display in parent ::setUp().
  $vocab = $this->vocabulary;
  $vid = $vocab
    ->id();
  // Create terms.
  $this->terms = $this
    ->createTerms($vocab);
  // Assert that RSS links for terms are not included in the sitemap.
  $this
    ->drupalGet('/sitemap');
  foreach ($this->terms as $term) {
    $this
      ->assertNoLinkByHref('/taxonomy/term/' . $term
      ->id() . '/feed');
  }
  // Include an RSS link for all terms.
  $this
    ->saveSitemapForm([
    "plugins[vocabulary:{$vid}][settings][enable_rss]" => TRUE,
  ]);
  // Assert that RSS links are included in the sitemap.
  $this
    ->drupalGet('/sitemap');
  foreach ($this->terms as $term) {
    $this
      ->assertLinkByHref('/taxonomy/term/' . $term
      ->id() . '/feed');
  }
  // Change RSS feed depth to 0.
  $this
    ->saveSitemapForm([
    "plugins[vocabulary:{$vid}][settings][rss_depth]" => 0,
  ]);
  // Assert that RSS links are not included in the sitemap.
  $this
    ->drupalGet('sitemap');
  foreach ($this->terms as $term) {
    $this
      ->assertNoLinkByHref('/taxonomy/term/' . $term
      ->id() . '/feed');
  }
}