You are here

public function XMLSitemapEnginesFunctionalTest::testCustomURL in XML sitemap 7.2

Same name and namespace in other branches
  1. 6.2 xmlsitemap_engines/tests/xmlsitemap_engines.test \XMLSitemapEnginesFunctionalTest::testCustomURL()

Test Custom URL.

@codingStandardsIgnoreStart

File

xmlsitemap_engines/tests/xmlsitemap_engines.test, line 131
Tests for the xmlsitemap_engines module.

Class

XMLSitemapEnginesFunctionalTest
Functional Test.

Code

public function testCustomURL() {

  // @codingStandardsIgnoreEnd
  $edit = array(
    'xmlsitemap_engines_custom_urls' => 'an-invalid-url',
  );
  $this
    ->drupalPost('admin/config/search/xmlsitemap/engines', $edit, t('Save configuration'));
  $this
    ->assertText('Invalid URL an-invalid-url.');
  $this
    ->assertNoText('The configuration options have been saved.');
  $url = url('ping', array(
    'absolute' => TRUE,
  ));
  $edit = array(
    'xmlsitemap_engines_custom_urls' => $url,
  );
  $this
    ->drupalPost('admin/config/search/xmlsitemap/engines', $edit, t('Save configuration'));
  $this
    ->assertText(t('The configuration options have been saved.'));
  $this
    ->submitEngines();
  $this
    ->assertWatchdogMessage(array(
    'type' => 'xmlsitemap',
    'message' => 'Submitted the sitemap to %url and received response @code.',
    'variables' => array(
      '%url' => $url,
      '@code' => '404',
    ),
  ));
  $this
    ->assertWatchdogMessage(array(
    'type' => 'xmlsitemap',
    'message' => 'No valid sitemap parameter provided.',
  ));
  $this
    ->assertWatchdogMessage(array(
    'type' => 'page not found',
    'message' => 'ping',
  ));
  $edit = array(
    'xmlsitemap_engines_custom_urls' => $this->submit_url,
  );
  $this
    ->drupalPost('admin/config/search/xmlsitemap/engines', $edit, t('Save configuration'));
  $this
    ->assertText(t('The configuration options have been saved.'));
  $this
    ->submitEngines();
  $url = xmlsitemap_engines_prepare_url($this->submit_url, url('sitemap.xml', array(
    'absolute' => TRUE,
  )));
  $this
    ->assertWatchdogMessage(array(
    'type' => 'xmlsitemap',
    'message' => 'Submitted the sitemap to %url and received response @code.',
    'variables' => array(
      '%url' => $url,
      '@code' => '200',
    ),
  ));
  $this
    ->assertWatchdogMessage(array(
    'type' => 'xmlsitemap',
    'message' => 'Recieved ping for @sitemap.',
    'variables' => array(
      '@sitemap' => url('sitemap.xml', array(
        'absolute' => TRUE,
      )),
    ),
  ));
}