You are here

public function SitemapMenuCustomTitleTest::testMenusCustomTitle in Sitemap 8

Tests a custom title setting for menus.

File

src/Tests/SitemapMenuCustomTitleTest.php, line 46

Class

SitemapMenuCustomTitleTest
Test the display of menus based on sitemap settings.

Namespace

Drupal\sitemap\Tests

Code

public function testMenusCustomTitle() {

  // Assert that main menu is included in the sitemap.
  $this
    ->drupalGet('/sitemap');
  $elements = $this
    ->cssSelect(".sitemap-box h2:contains('Main navigation')");
  $this
    ->assertEqual(count($elements), 1, 'Main menu with default title is included.');

  // Set a custom title for the main menu display.
  $custom_title = $this
    ->randomString();
  $edit = [
    'sitemap_display_name' => $custom_title,
  ];
  $this
    ->drupalPostForm('admin/structure/menu/manage/main', $edit, t('Save'));
  drupal_flush_all_caches();

  // Check that the custom title appears on the sitemap.
  $this
    ->drupalGet('/sitemap');
  $elements = $this
    ->cssSelect(".sitemap-box h2:contains('" . $custom_title . "')");
  $this
    ->assertEqual(count($elements), 1, 'Main menu with custom title is included.');
}