You are here

public function XMLSitemapFunctionalTest::testBaseURL in XML sitemap 7.2

Same name and namespace in other branches
  1. 6.2 xmlsitemap.test \XMLSitemapFunctionalTest::testBaseURL()

Test base URL functionality.

@codingStandardsIgnoreStart

File

./xmlsitemap.test, line 924
Unit tests for the xmlsitemap.

Class

XMLSitemapFunctionalTest
XML Sitemap Functional Test.

Code

public function testBaseURL() {

  // @codingStandardsIgnoreEnd
  $edit = array(
    'xmlsitemap_base_url' => '',
  );
  $this
    ->drupalPost('admin/config/search/xmlsitemap/settings', $edit, t('Save configuration'));
  $this
    ->assertText(t('Default base URL field is required.'));
  $edit = array(
    'xmlsitemap_base_url' => 'invalid',
  );
  $this
    ->drupalPost('admin/config/search/xmlsitemap/settings', $edit, t('Save configuration'));
  $this
    ->assertText(t('Invalid base URL.'));
  $edit = array(
    'xmlsitemap_base_url' => 'http://example.com/ ',
  );
  $this
    ->drupalPost('admin/config/search/xmlsitemap/settings', $edit, t('Save configuration'));
  $this
    ->assertText(t('Invalid base URL.'));
  $edit = array(
    'xmlsitemap_base_url' => 'http://example.com/',
  );
  $this
    ->drupalPost('admin/config/search/xmlsitemap/settings', $edit, t('Save configuration'));
  $this
    ->assertText(t('The configuration options have been saved.'));
  $this
    ->regenerateSitemap();
  $this
    ->drupalGetSitemap(array(), array(
    'base_url' => NULL,
  ));
  $this
    ->assertRaw('<loc>http://example.com/</loc>');
}