function TaxonomyFieldTidTest::testViewsHandlerTidField

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()
  2. 10 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 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);
}

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