function TaxonomyFieldTidTest::testViewsHandlerTidField

Same name in other branches
  1. 9 core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldTidTest.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyFieldTidTest::testViewsHandlerTidField()
  2. 8.9.x core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldTidTest.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyFieldTidTest::testViewsHandlerTidField()
  3. 11.x 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 64

Class

TaxonomyFieldTidTest
Tests the taxonomy term TID field handler.

Namespace

Drupal\Tests\taxonomy\Kernel\Views

Code

public function testViewsHandlerTidField() : void {
    
    /** @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);
}

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