public function SitemapTaxonomyTest::testVocabularyDescription in Sitemap 2.0.x
Same name and namespace in other branches
- 8.2 src/Tests/SitemapTaxonomyTest.php \Drupal\sitemap\Tests\SitemapTaxonomyTest::testVocabularyDescription()
- 8 src/Tests/SitemapTaxonomyTest.php \Drupal\sitemap\Tests\SitemapTaxonomyTest::testVocabularyDescription()
Tests vocabulary description.
File
- src/
Tests/ SitemapTaxonomyTest.php, line 35
Class
- SitemapTaxonomyTest
- Tests the display of taxonomies based on sitemap settings.
Namespace
Drupal\sitemap\TestsCode
public function testVocabularyDescription() {
// The vocabulary is already configured to display in ::setUp().
$vid = $this->vocabulary
->id();
// Assert that vocabulary description is not included by default.
$this
->drupalGet('/sitemap');
$elements = $this
->cssSelect(".sitemap-plugin--vocabulary");
$this
->assertEqual(count($elements), 1, 'Vocabulary found.');
$this
->assertNoText($this->vocabulary
->getDescription());
// Display the description.
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][show_description]" => TRUE,
]);
$this
->assertText($this->vocabulary
->getDescription());
// Create taxonomy terms.
$this
->createTerms($this->vocabulary);
// Set to show all taxonomy terms, even if they are not assigned to any
// nodes.
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][term_count_threshold]" => -1,
]);
// Assert that the vocabulary description is included in the sitemap when
// terms are displayed.
$this
->drupalGet('/sitemap');
$this
->assertText($this->vocabulary
->getDescription());
// Configure sitemap not to show vocabulary descriptions.
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][show_description]" => FALSE,
]);
// Assert that vocabulary description is not included in the sitemap.
$this
->drupalGet('/sitemap');
$this
->assertNoText($this->vocabulary
->getDescription());
}