You are here

function XMLSitemapFunctionalTest::testBaseURL in XML sitemap 6.2

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

Test base URL functionality.

File

./xmlsitemap.test, line 736
Unit tests for the xmlsitemap module.

Class

XMLSitemapFunctionalTest

Code

function testBaseURL() {
  $edit = array(
    'xmlsitemap_base_url' => '',
  );
  $this
    ->drupalPost('admin/settings/xmlsitemap/settings', $edit, t('Save configuration'));
  $this
    ->assertText(t('Default base URL field is required.'));
  $edit = array(
    'xmlsitemap_base_url' => 'invalid',
  );
  $this
    ->drupalPost('admin/settings/xmlsitemap/settings', $edit, t('Save configuration'));
  $this
    ->assertText(t('Invalid base URL.'));
  $edit = array(
    'xmlsitemap_base_url' => 'http://example.com/ ',
  );
  $this
    ->drupalPost('admin/settings/xmlsitemap/settings', $edit, t('Save configuration'));
  $this
    ->assertText(t('Invalid base URL.'));
  $edit = array(
    'xmlsitemap_base_url' => 'http://example.com/',
  );
  $this
    ->drupalPost('admin/settings/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>');
}