public function SitemapTaxonomyTermsRssTest::testRssFeedDepth in Sitemap 8.2
Same name and namespace in other branches
- 8 src/Tests/SitemapTaxonomyTermsRssTest.php \Drupal\sitemap\Tests\SitemapTaxonomyTermsRssTest::testRssFeedDepth()
- 2.0.x src/Tests/SitemapTaxonomyTermsRssTest.php \Drupal\sitemap\Tests\SitemapTaxonomyTermsRssTest::testRssFeedDepth()
Tests RSS feed depth.
File
- src/
Tests/ SitemapTaxonomyTermsRssTest.php, line 64
Class
- SitemapTaxonomyTermsRssTest
- Tests the display of RSS links based on sitemap settings.
Namespace
Drupal\sitemap\TestsCode
public function testRssFeedDepth() {
// The vocabulary is already configured to display in parent ::setUp().
$vocab = $this->vocabulary;
$vid = $vocab
->id();
// Create terms.
$this->terms = $this
->createNestedTerms($vocab);
// Assert that RSS links are not included by default.
$this
->drupalGet('sitemap');
foreach ($this->terms as $term) {
$this
->assertSession()
->linkByHrefNotExists('/taxonomy/term/' . $term
->id() . '/feed');
}
// Set RSS feed depth to maximum.
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][enable_rss]" => TRUE,
]);
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][rss_depth]" => 9,
]);
// Assert that all RSS links are included in the sitemap.
$this
->drupalGet('sitemap');
foreach ($this->terms as $term) {
$this
->assertSession()
->linkByHrefExists('/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
->assertSession()
->linkByHrefNotExists('/taxonomy/term/' . $term
->id() . '/feed');
}
// Change RSS feed depth to 1.
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][rss_depth]" => 1,
]);
// Assert that only RSS feed link for term 1 is included in the sitemap.
$this
->drupalGet('sitemap');
$this
->assertSession()
->linkByHrefExists('/taxonomy/term/' . $this->terms[0]
->id() . '/feed');
$this
->assertSession()
->linkByHrefNotExists('/taxonomy/term/' . $this->terms[1]
->id() . '/feed');
$this
->assertSession()
->linkByHrefNotExists('/taxonomy/term/' . $this->terms[2]
->id() . '/feed');
// Change RSS feed depth to 2.
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][rss_depth]" => 2,
]);
// Assert that RSS feed link for term 1 and term 2 is included in the site
// map.
$this
->drupalGet('sitemap');
$this
->assertSession()
->linkByHrefExists('/taxonomy/term/' . $this->terms[0]
->id() . '/feed');
$this
->assertSession()
->linkByHrefExists('/taxonomy/term/' . $this->terms[1]
->id() . '/feed');
$this
->assertSession()
->linkByHrefNotExists('/taxonomy/term/' . $this->terms[2]
->id() . '/feed');
// Change RSS feed depth to 3.
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][rss_depth]" => 3,
]);
// Assert that all RSS links are included in the sitemap.
$this
->drupalGet('sitemap');
foreach ($this->terms as $term) {
$this
->assertSession()
->linkByHrefExists('/taxonomy/term/' . $term
->id() . '/feed');
}
// Change disable RSS links.
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][enable_rss]" => FALSE,
]);
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][rss_depth]" => 9,
]);
// Assert that RSS links are not included in the sitemap.
$this
->drupalGet('sitemap');
foreach ($this->terms as $term) {
$this
->assertSession()
->linkByHrefNotExists('/taxonomy/term/' . $term
->id() . '/feed');
}
}