public function SitemapTaxonomyTermsTest::testNodeCounts in Sitemap 8.2
Same name and namespace in other branches
- 8 src/Tests/SitemapTaxonomyTermsTest.php \Drupal\sitemap\Tests\SitemapTaxonomyTermsTest::testNodeCounts()
- 2.0.x src/Tests/SitemapTaxonomyTermsTest.php \Drupal\sitemap\Tests\SitemapTaxonomyTermsTest::testNodeCounts()
Tests appearance of node counts.
File
- src/
Tests/ SitemapTaxonomyTermsTest.php, line 72
Class
- SitemapTaxonomyTermsTest
- Tests the display of taxonomies based on sitemap settings.
Namespace
Drupal\sitemap\TestsCode
public function testNodeCounts() {
$this->terms = $this
->createTerms($this->vocabulary);
// The vocabulary is already configured to display in parent ::setUp().
$vocab = $this->vocabulary;
$vid = $vocab
->id();
// Create test node with terms.
$this
->createNodeWithTerms($this->terms);
// Assert that node counts are not included in the sitemap by default.
$this
->drupalGet('/sitemap');
$elements = $this
->cssSelect(".sitemap-plugin--vocabulary .count:contains('(1)')");
$this
->assertEquals(count($elements), 0, 'Node counts not included.');
// Configure module to display node counts.
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][show_count]" => TRUE,
]);
// Assert that node counts are included in the sitemap.
$this
->drupalGet('sitemap');
$elements = $this
->cssSelect(".sitemap-plugin--vocabulary .count:contains('(1)')");
$this
->assertEquals(count($elements), 3, 'Node counts included.');
// TODO: Add another node and check counts.
//@TODO: Test count display when parent term does not meet threshold.
}