Skip to content
Snippets Groups Projects
Commit 16c2a799 authored by Riyas N R's avatar Riyas N R Committed by Adam G-H
Browse files

Issue #3498036 by phenaproxima, riyas_nr, poker10, thejimbirch: Test that the...

Issue #3498036 by phenaproxima, riyas_nr, poker10, thejimbirch: Test that the site map contains links to the front page and main menu items
parent d0fa3b57
Branches
Tags
1 merge request!505Issue #3498036: Add test for Sitemap module enabled plugins
Pipeline #428437 failed
......@@ -6,6 +6,7 @@ namespace Drupal\Tests\drupal_cms_seo_tools\Functional;
use Drupal\field\Entity\FieldConfig;
use Drupal\FunctionalTests\Core\Recipe\RecipeTestTrait;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\Tests\BrowserTestBase;
/**
......@@ -53,12 +54,28 @@ class ComponentValidationTest extends BrowserTestBase {
}
/**
* Checks the sitemap is accessible.
* Checks that the sitemap is accessible and contains the expected links.
*/
private function checkSitemap(): void {
// Create a main menu link to ensure it shows up in the site map.
$node = $this->drupalCreateNode(['type' => 'test']);
$menu_link = MenuLinkContent::create([
'title' => $node->getTitle(),
'link' => 'internal:' . $node->toUrl()->toString(),
'menu_name' => 'main',
]);
$menu_link->save();
$this->drupalGet('/sitemap');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->linkByHrefNotExists('/rss.xml');
$assert_session = $this->assertSession();
$assert_session->statusCodeEquals(200);
$assert_session->linkByHrefNotExists('/rss.xml');
$site_map = $assert_session->elementExists('css', '.sitemap');
$site_name = $this->config('system.site')->get('name');
$this->assertTrue($site_map->hasLink("Front page of $site_name"), 'Front page link does not appear in the site map.');
$this->assertTrue($site_map->hasLink($menu_link->label()), 'Main menu links do not appear in the site map.');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment