function TaxonomyFieldAllTermsTest::testViewsHandlerAllTermsField

Same name and namespace in other branches
  1. 9 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');
    $actual = $this->xpath('//a[@href="' . $this->term1
        ->toUrl()
        ->toString() . '"]');
    $this->assertCount(2, $actual, 'Correct number of taxonomy term1 links');
    $this->assertEqual($actual[0]->getText(), $this->term1
        ->label());
    $this->assertEqual($actual[1]->getText(), $this->term1
        ->label());
    $this->assertEscaped($this->term1
        ->label());
    $actual = $this->xpath('//a[@href="' . $this->term2
        ->toUrl()
        ->toString() . '"]');
    $this->assertCount(2, $actual, 'Correct number of taxonomy term2 links');
    $this->assertEqual($actual[0]->getText(), $this->term2
        ->label());
    $this->assertEqual($actual[1]->getText(), $this->term2
        ->label());
}

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