You are here

public function SitemapTaxonomyTest::testVocabularyDescription in Sitemap 8

Same name and namespace in other branches
  1. 8.2 src/Tests/SitemapTaxonomyTest.php \Drupal\sitemap\Tests\SitemapTaxonomyTest::testVocabularyDescription()
  2. 2.0.x src/Tests/SitemapTaxonomyTest.php \Drupal\sitemap\Tests\SitemapTaxonomyTest::testVocabularyDescription()

Tests vocabulary description.

File

src/Tests/SitemapTaxonomyTest.php, line 29

Class

SitemapTaxonomyTest
Tests the display of taxonomies based on sitemap settings.

Namespace

Drupal\sitemap\Tests

Code

public function testVocabularyDescription() {

  // Assert that vocabulary description is not included if no tags are
  // displayed.
  $this
    ->drupalGet('/sitemap');
  $this
    ->assertNoText($this->vocabulary
    ->getDescription(), 'Vocabulary description is not included.');

  // Create taxonomy terms.
  $this
    ->createTerms($this->vocabulary);

  // Set to show all taxonomy terms, even if they are not assigned to any
  // nodes.
  $edit = [
    'term_threshold' => -1,
  ];
  $this
    ->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));

  // Assert that the vocabulary description is included in the sitemap when
  // terms are displayed.
  $this
    ->drupalGet('/sitemap');
  $this
    ->assertText($this->vocabulary
    ->getDescription(), 'Vocabulary description is included.');

  // Configure module not to show vocabulary descriptions.
  $edit = [
    'show_description' => FALSE,
  ];
  $this
    ->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));

  // Assert that vocabulary description is not included in the sitemap.
  $this
    ->drupalGet('/sitemap');
  $this
    ->assertNoText($this->vocabulary
    ->getDescription(), 'Vocabulary description is not included.');
}