You are here

public function SitemapTaxonomyTermsTest::testNestedTermLinks in Sitemap 2.0.x

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

Tests the nested term link settings.

File

src/Tests/SitemapTaxonomyTermsTest.php, line 185

Class

SitemapTaxonomyTermsTest
Tests the display of taxonomies based on sitemap settings.

Namespace

Drupal\sitemap\Tests

Code

public function testNestedTermLinks() {

  // Create terms.
  $this->terms = $this
    ->createNestedTerms($this->vocabulary);
  $this
    ->linkSettingsTest();

  // Test link when parent term does not meet threshold.
  $vid = $this->vocabulary
    ->id();
  $this
    ->saveSitemapForm([
    "plugins[vocabulary:{$vid}][settings][term_count_threshold]" => 2,
  ]);
  $childTerms = $this->terms;
  array_shift($childTerms);
  $this
    ->createNodeWithTerms($childTerms);
  $this
    ->drupalGet('/sitemap');
  $this
    ->assertNoLink($this->terms[0]
    ->label());
  foreach ($childTerms as $term) {
    $this
      ->assertLink($term
      ->label());
  }

  // Test 'always display links'.
  $vid = $this->vocabulary
    ->id();
  $this
    ->saveSitemapForm([
    "plugins[vocabulary:{$vid}][settings][always_link]" => TRUE,
  ]);
  $this
    ->drupalGet('/sitemap');
  foreach ($this->terms as $term) {
    $this
      ->assertLink($term
      ->label());
  }
}