You are here

public function TaxonomyFieldAllTermsTest::testViewsHandlerAllTermsField 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::testViewsHandlerAllTermsField()

Tests the "all terms" field handler.

File

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

Class

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

Namespace

Drupal\taxonomy\Tests\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
    ->url() . '"]');
  $this
    ->assertEqual(count($actual), 2, 'Correct number of taxonomy term1 links');
  $this
    ->assertEqual($actual[0]
    ->__toString(), $this->term1
    ->label());
  $this
    ->assertEqual($actual[1]
    ->__toString(), $this->term1
    ->label());
  $this
    ->assertEscaped($this->term1
    ->label());
  $actual = $this
    ->xpath('//a[@href="' . $this->term2
    ->url() . '"]');
  $this
    ->assertEqual(count($actual), 2, 'Correct number of taxonomy term2 links');
  $this
    ->assertEqual($actual[0]
    ->__toString(), $this->term2
    ->label());
  $this
    ->assertEqual($actual[1]
    ->__toString(), $this->term2
    ->label());
}