You are here

public function SitemapFrontpageTest::testRssFeed in Sitemap 8.2

Same name and namespace in other branches
  1. 2.0.x src/Tests/SitemapFrontpageTest.php \Drupal\sitemap\Tests\SitemapFrontpageTest::testRssFeed()

Tests RSS feed for front page.

File

src/Tests/SitemapFrontpageTest.php, line 45

Class

SitemapFrontpageTest
Tests the display of RSS links based on sitemap settings.

Namespace

Drupal\sitemap\Tests

Code

public function testRssFeed() {

  // Assert default RSS feed for front page.
  $this
    ->drupalGet('/sitemap');
  $this
    ->assertSession()
    ->linkByHrefExists('/rss.xml');
  $elements = $this
    ->cssSelect(".sitemap-plugin--frontpage img");
  $this
    ->assertEquals(count($elements), 1, 'RSS icon is included.');

  // Change RSS feed for front page.
  $href = mb_strtolower($this
    ->randomMachineName());
  $this
    ->saveSitemapForm([
    'plugins[frontpage][settings][rss]' => '/' . $href,
  ]);

  // Assert that RSS feed for front page has been changed.
  $this
    ->drupalGet('/sitemap');
  $this
    ->assertSession()
    ->linkByHrefExists('/' . $href);

  // Assert that the RSS feed can be removed entirely.
  $this
    ->saveSitemapForm([
    'plugins[frontpage][settings][rss]' => '',
  ]);
  $this
    ->drupalGet('/sitemap');
  $elements = $this
    ->cssSelect(".sitemap-plugin--frontpage img");
  $this
    ->assertEquals(count($elements), 0, 'RSS icon is not included.');
}