diff --git a/recipes/drupal_cms_seo_tools/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_seo_tools/tests/src/Functional/ComponentValidationTest.php index 4515f008f5a5c25a90b7c0ed104a1de28890e63f..d7a732cbbb8c889ad55e99f36b13654ca4d65eca 100644 --- a/recipes/drupal_cms_seo_tools/tests/src/Functional/ComponentValidationTest.php +++ b/recipes/drupal_cms_seo_tools/tests/src/Functional/ComponentValidationTest.php @@ -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.'); } }