function TaxonomyFieldAllTermsTest::testViewsHandlerAllTermsField

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

Tests the "all terms" field handler.

File

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

Class

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

Namespace

Drupal\Tests\taxonomy\Functional\Views

Code

public function testViewsHandlerAllTermsField() {
    $this->term1
        ->setName('<em>Markup</em>')
        ->save();
    $view = Views::getView('taxonomy_all_terms_test');
    $this->executeView($view);
    $this->drupalGet('taxonomy_all_terms_test');
    // Test term1 links.
    $xpath = '//a[@href="' . $this->term1
        ->toUrl()
        ->toString() . '"]';
    $this->assertSession()
        ->elementsCount('xpath', $xpath, 2);
    $links = $this->xpath($xpath);
    $this->assertEquals($this->term1
        ->label(), $links[0]->getText());
    $this->assertEquals($this->term1
        ->label(), $links[1]->getText());
    $this->assertSession()
        ->assertEscaped($this->term1
        ->label());
    // Test term2 links.
    $xpath = '//a[@href="' . $this->term2
        ->toUrl()
        ->toString() . '"]';
    $this->assertSession()
        ->elementsCount('xpath', $xpath, 2);
    $links = $this->xpath($xpath);
    $this->assertEquals($this->term2
        ->label(), $links[0]->getText());
    $this->assertEquals($this->term2
        ->label(), $links[1]->getText());
}

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