You are here

public function TaxonomyFieldAllTermsTest::testViewsHandlerAllTermsWithTokens in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php \Drupal\taxonomy\Tests\Views\TaxonomyFieldAllTermsTest::testViewsHandlerAllTermsWithTokens()

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

File

core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php, line 51
Contains \Drupal\taxonomy\Tests\Views\TaxonomyFieldAllTermsTest.

Class

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

Namespace

Drupal\taxonomy\Tests\Views

Code

public function testViewsHandlerAllTermsWithTokens() {
  $view = Views::getView('taxonomy_all_terms_test');
  $this
    ->drupalGet('taxonomy_all_terms_token_test');

  // Term itself: {{ term_node_tid }}
  $this
    ->assertText('Term: ' . $this->term1
    ->getName());

  // The taxonomy term ID for the term: {{ term_node_tid__tid }}
  $this
    ->assertText('The taxonomy term ID for the term: ' . $this->term1
    ->id());

  // The taxonomy term name for the term: {{ term_node_tid__name }}
  $this
    ->assertText('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
    ->assertText('The machine name for the vocabulary the term belongs to: ' . $this->term1
    ->getVocabularyId());

  // The name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary }}
  $vocabulary = Vocabulary::load($this->term1
    ->bundle());
  $this
    ->assertText('The name for the vocabulary the term belongs to: ' . $vocabulary
    ->label());
}