You are here

public function XmlSitemapFunctionalTest::testBaseURL in XML sitemap 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/XmlSitemapFunctionalTest.php \Drupal\Tests\xmlsitemap\Functional\XmlSitemapFunctionalTest::testBaseURL()

Test base URL functionality.

@codingStandardsIgnoreStart

File

tests/src/Functional/XmlSitemapFunctionalTest.php, line 53

Class

XmlSitemapFunctionalTest
Tests the generation of sitemaps.

Namespace

Drupal\Tests\xmlsitemap\Functional

Code

public function testBaseURL() {

  // @codingStandardsIgnoreEnd
  $this
    ->drupalLogin($this->admin_user);
  $edit = [
    'xmlsitemap_base_url' => '',
  ];
  $this
    ->drupalPostForm('admin/config/search/xmlsitemap/settings', $edit, 'Save configuration');
  $edit = [
    'xmlsitemap_base_url' => 'invalid',
  ];
  $this
    ->drupalPostForm('admin/config/search/xmlsitemap/settings', $edit, 'Save configuration');
  $this
    ->assertSession()
    ->pageTextContains('Invalid base URL.');
  $edit = [
    'xmlsitemap_base_url' => 'http://example.com/ ',
  ];
  $this
    ->drupalPostForm('admin/config/search/xmlsitemap/settings', $edit, 'Save configuration');
  $this
    ->assertSession()
    ->pageTextContains('Invalid base URL.');
  $edit = [
    'xmlsitemap_base_url' => 'http://example.com/',
  ];
  $this
    ->drupalPostForm('admin/config/search/xmlsitemap/settings', $edit, 'Save configuration');
  $this
    ->assertSession()
    ->pageTextContains('The configuration options have been saved.');
  $this
    ->regenerateSitemap();
  $this
    ->drupalGetSitemap([], [
    'base_url' => NULL,
  ]);
  $this
    ->assertSession()
    ->responseContains('<loc>http://example.com/</loc>');
}