SitemapTaxonomyTermsRssTest.php in Sitemap 8
File
src/Tests/SitemapTaxonomyTermsRssTest.php
View source
<?php
namespace Drupal\sitemap\Tests;
class SitemapTaxonomyTermsRssTest extends SitemapTaxonomyTestBase {
public static $modules = [
'sitemap',
'node',
'taxonomy',
];
protected function setUp() {
parent::setUp();
$this->terms = $this
->createTerms($this->vocabulary);
$edit = [
'term_threshold' => -1,
];
$this
->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));
}
public function testIncludeRssLinks() {
$this
->drupalGet('/sitemap');
foreach ($this->terms as $term) {
$this
->assertLinkByHref('/taxonomy/term/' . $term
->id() . '/feed');
}
$edit = [
'show_rss_links' => 0,
];
$this
->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));
$this
->drupalGet('/sitemap');
foreach ($this->terms as $term) {
$this
->assertNoLinkByHref('/taxonomy/term/' . $term
->id() . '/feed');
}
}
public function testRssFeedDepth() {
$terms = $this->terms;
$edit = [
'rss_taxonomy' => -1,
];
$this
->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));
$this
->drupalGet('sitemap');
foreach ($terms as $term) {
$this
->assertLinkByHref('/taxonomy/term/' . $term
->id() . '/feed');
}
$edit = [
'rss_taxonomy' => 0,
];
$this
->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));
$this
->drupalGet('sitemap');
foreach ($terms as $term) {
$this
->assertNoLinkByHref('/taxonomy/term/' . $term
->id() . '/feed');
}
$edit = [
'rss_taxonomy' => 1,
];
$this
->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));
$this
->drupalGet('sitemap');
$this
->assertLinkByHref('/taxonomy/term/' . $terms[0]
->id() . '/feed');
$this
->assertNoLinkByHref('/taxonomy/term/' . $terms[1]
->id() . '/feed');
$this
->assertNoLinkByHref('/taxonomy/term/' . $terms[2]
->id() . '/feed');
$edit = [
'rss_taxonomy' => 2,
];
$this
->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));
$this
->drupalGet('sitemap');
$this
->assertLinkByHref('/taxonomy/term/' . $terms[0]
->id() . '/feed');
$this
->assertLinkByHref('/taxonomy/term/' . $terms[1]
->id() . '/feed');
$this
->assertNoLinkByHref('/taxonomy/term/' . $terms[2]
->id() . '/feed');
$edit = [
'rss_taxonomy' => 3,
];
$this
->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));
$this
->drupalGet('sitemap');
foreach ($terms as $term) {
$this
->assertLinkByHref('/taxonomy/term/' . $term
->id() . '/feed');
}
}
}