You are here

protected function SitemapTaxonomyTermsTest::linkSettingsTest in Sitemap 2.0.x

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

Helper function for testing link settings.

2 calls to SitemapTaxonomyTermsTest::linkSettingsTest()
SitemapTaxonomyTermsTest::testNestedTermLinks in src/Tests/SitemapTaxonomyTermsTest.php
Tests the nested term link settings.
SitemapTaxonomyTermsTest::testTermLinks in src/Tests/SitemapTaxonomyTermsTest.php
Tests the term link settings.

File

src/Tests/SitemapTaxonomyTermsTest.php, line 220

Class

SitemapTaxonomyTermsTest
Tests the display of taxonomies based on sitemap settings.

Namespace

Drupal\sitemap\Tests

Code

protected function linkSettingsTest() {

  // Confirm that terms without content are not linked by default.
  $this
    ->drupalGet('/sitemap');
  foreach ($this->terms as $term) {
    $this
      ->assertNoLink($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());
  }

  // Test that terms with content are linked...
  $this
    ->createNodeWithTerms($this->terms);
  $this
    ->drupalGet('/sitemap');
  foreach ($this->terms as $term) {
    $this
      ->assertLink($term
      ->label());
  }

  // ... even when always_link is disabled.
  $this
    ->saveSitemapForm([
    "plugins[vocabulary:{$vid}][settings][always_link]" => FALSE,
  ]);
  $this
    ->drupalGet('/sitemap');
  foreach ($this->terms as $term) {
    $this
      ->assertLink($term
      ->label());
  }
}