public function XmlSitemapEnginesFunctionalTest::testCustomURL in XML sitemap 8
Same name and namespace in other branches
- 2.x xmlsitemap_engines/tests/src/Functional/XmlSitemapEnginesFunctionalTest.php \Drupal\Tests\xmlsitemap_engines\Functional\XmlSitemapEnginesFunctionalTest::testCustomURL()
Check if custom urls are functional.
@codingStandardsIgnoreStart
File
- xmlsitemap_engines/
tests/ src/ Functional/ XmlSitemapEnginesFunctionalTest.php, line 146
Class
- XmlSitemapEnginesFunctionalTest
- Test xmlsitemap_engines functionality.
Namespace
Drupal\Tests\xmlsitemap_engines\FunctionalCode
public function testCustomURL() {
// @codingStandardsIgnoreEnd
$edit = [
'custom_urls' => 'an-invalid-url',
];
$this
->drupalPostForm('admin/config/search/xmlsitemap/engines', $edit, t('Save configuration'));
$this
->assertSession()
->pageTextContains('Invalid URL an-invalid-url.');
$this
->assertSession()
->pageTextNotContains('The configuration options have been saved.');
$url = Url::fromUri('base://ping', [
'absolute' => TRUE,
])
->toString();
$edit = [
'custom_urls' => $url,
];
$this
->drupalPostForm('admin/config/search/xmlsitemap/engines', $edit, t('Save configuration'));
$this
->assertSession()
->pageTextContains(t('The configuration options have been saved.'));
$edit = [
'custom_urls' => $this->submit_url,
];
$this
->drupalPostForm('admin/config/search/xmlsitemap/engines', $edit, t('Save configuration'));
$this
->assertSession()
->pageTextContains(t('The configuration options have been saved.'));
$this
->submitEngines();
$url = xmlsitemap_engines_prepare_url($this->submit_url, Url::fromRoute('xmlsitemap.sitemap_xml', [], [
'absolute' => TRUE,
])
->toString());
$this
->assertWatchdogMessage([
'type' => 'xmlsitemap',
'message' => 'Submitted the sitemap to %url and received response @code.',
'variables' => [
'%url' => $url,
'@code' => 200,
],
]);
$this
->assertWatchdogMessage([
'type' => 'xmlsitemap',
'message' => 'Received ping for @sitemap.',
'variables' => [
'@sitemap' => Url::fromRoute('xmlsitemap.sitemap_xml', [], [
'absolute' => TRUE,
])
->toString(),
],
]);
}