function TaxonomyFieldAllTermsTest::testViewsHandlerAllTermsWithTokens

Same name in other branches
  1. 9 core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyFieldAllTermsTest::testViewsHandlerAllTermsWithTokens()
  2. 8.9.x core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyFieldAllTermsTest::testViewsHandlerAllTermsWithTokens()
  3. 11.x core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyFieldAllTermsTest::testViewsHandlerAllTermsWithTokens()

Tests token replacement in the "all terms" field handler.

File

core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php, line 57

Class

TaxonomyFieldAllTermsTest
Tests the "All terms" taxonomy term field handler.

Namespace

Drupal\Tests\taxonomy\Functional\Views

Code

public function testViewsHandlerAllTermsWithTokens() : void {
    $view = Views::getView('taxonomy_all_terms_test');
    $this->drupalGet('taxonomy_all_terms_token_test');
    // Term itself: {{ term_node_tid }}
    $this->assertSession()
        ->pageTextContains('Term: ' . $this->term1
        ->getName());
    // The taxonomy term ID for the term: {{ term_node_tid__tid }}
    $this->assertSession()
        ->pageTextContains('The taxonomy term ID for the term: ' . $this->term1
        ->id());
    // The taxonomy term name for the term: {{ term_node_tid__name }}
    $this->assertSession()
        ->pageTextContains('The taxonomy term name for the term: ' . $this->term1
        ->getName());
    // The machine name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary_vid }}
    $this->assertSession()
        ->pageTextContains('The machine name for the vocabulary the term belongs to: ' . $this->term1
        ->bundle());
    // The name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary }}
    $vocabulary = Vocabulary::load($this->term1
        ->bundle());
    $this->assertSession()
        ->pageTextContains('The name for the vocabulary the term belongs to: ' . $vocabulary->label());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.