You are here

public function SitemapTaxonomyTermsTest::testNodeCounts in Sitemap 8

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

Tests appearance of node counts.

File

src/Tests/SitemapTaxonomyTermsTest.php, line 96

Class

SitemapTaxonomyTermsTest
Tests the display of taxonomies based on sitemap settings.

Namespace

Drupal\sitemap\Tests

Code

public function testNodeCounts() {

  // Create test node with terms.
  $this
    ->createNodeWithTerms($this->terms);

  // Assert that node counts are included in the sitemap by default.
  $this
    ->drupalGet('/sitemap');
  $this
    ->assertEqual(substr_count($this
    ->getTextContent(), '(1)'), 3, 'Node counts are included');

  // Configure module to hide node counts.
  $edit = [
    'show_count' => FALSE,
  ];
  $this
    ->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));

  // Assert that node counts are not included in the sitemap.
  $this
    ->drupalGet('sitemap');
  $this
    ->assertEqual(substr_count($this
    ->getTextContent(), '(1)'), 0, 'Node counts are not included');
}