SitemapTaxonomyTermsRssTest.php in Sitemap 8.2
File
src/Tests/SitemapTaxonomyTermsRssTest.php
View source
<?php
namespace Drupal\sitemap\Tests;
class SitemapTaxonomyTermsRssTest extends SitemapTaxonomyTestBase {
protected function setUp() {
parent::setUp();
$vocab = $this->vocabulary;
$vid = $vocab
->id();
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][term_count_threshold]" => 0,
]);
}
public function testIncludeRssLinks() {
$vocab = $this->vocabulary;
$vid = $vocab
->id();
$this->terms = $this
->createTerms($vocab);
$this
->drupalGet('/sitemap');
foreach ($this->terms as $term) {
$this
->assertSession()
->linkByHrefNotExists('/taxonomy/term/' . $term
->id() . '/feed');
}
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][enable_rss]" => TRUE,
]);
$this
->drupalGet('/sitemap');
foreach ($this->terms as $term) {
$this
->assertSession()
->linkByHrefExists('/taxonomy/term/' . $term
->id() . '/feed');
}
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][rss_depth]" => 0,
]);
$this
->drupalGet('sitemap');
foreach ($this->terms as $term) {
$this
->assertSession()
->linkByHrefNotExists('/taxonomy/term/' . $term
->id() . '/feed');
}
}
public function testRssFeedDepth() {
$vocab = $this->vocabulary;
$vid = $vocab
->id();
$this->terms = $this
->createNestedTerms($vocab);
$this
->drupalGet('sitemap');
foreach ($this->terms as $term) {
$this
->assertSession()
->linkByHrefNotExists('/taxonomy/term/' . $term
->id() . '/feed');
}
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][enable_rss]" => TRUE,
]);
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][rss_depth]" => 9,
]);
$this
->drupalGet('sitemap');
foreach ($this->terms as $term) {
$this
->assertSession()
->linkByHrefExists('/taxonomy/term/' . $term
->id() . '/feed');
}
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][rss_depth]" => 0,
]);
$this
->drupalGet('sitemap');
foreach ($this->terms as $term) {
$this
->assertSession()
->linkByHrefNotExists('/taxonomy/term/' . $term
->id() . '/feed');
}
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][rss_depth]" => 1,
]);
$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');
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][rss_depth]" => 2,
]);
$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');
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][rss_depth]" => 3,
]);
$this
->drupalGet('sitemap');
foreach ($this->terms as $term) {
$this
->assertSession()
->linkByHrefExists('/taxonomy/term/' . $term
->id() . '/feed');
}
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][enable_rss]" => FALSE,
]);
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][rss_depth]" => 9,
]);
$this
->drupalGet('sitemap');
foreach ($this->terms as $term) {
$this
->assertSession()
->linkByHrefNotExists('/taxonomy/term/' . $term
->id() . '/feed');
}
}
}