You are here

public function TaxonomyFieldTidTest::testViewsHandlerTidField in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldTidTest.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyFieldTidTest::testViewsHandlerTidField()

Tests the taxonomy field handler.

File

core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldTidTest.php, line 62

Class

TaxonomyFieldTidTest
Tests the taxonomy term TID field handler.

Namespace

Drupal\Tests\taxonomy\Kernel\Views

Code

public function testViewsHandlerTidField() {

  /** @var \Drupal\Core\Render\RendererInterface $renderer */
  $renderer = \Drupal::service('renderer');
  $view = Views::getView('test_taxonomy_tid_field');
  $this
    ->executeView($view);
  $actual = $renderer
    ->executeInRenderContext(new RenderContext(), function () use ($view) {
    return $view->field['name']
      ->advancedRender($view->result[0]);
  });
  $expected = Link::fromTextAndUrl($this->term1
    ->label(), $this->term1
    ->toUrl());
  $this
    ->assertEquals($expected
    ->toString(), $actual);
}