function TaxonomyFieldVidTest::testViewsHandlerVidField

Same name in other branches
  1. 9 core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldVidTest.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyFieldVidTest::testViewsHandlerVidField()
  2. 10 core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldVidTest.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyFieldVidTest::testViewsHandlerVidField()
  3. 11.x core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldVidTest.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyFieldVidTest::testViewsHandlerVidField()

Tests the field handling for the Vocabulary ID.

File

core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldVidTest.php, line 81

Class

TaxonomyFieldVidTest
Tests the taxonomy term VID field handler.

Namespace

Drupal\Tests\taxonomy\Kernel\Views

Code

public function testViewsHandlerVidField() {
    
    /** @var \Drupal\Core\Render\RendererInterface $renderer */
    $renderer = \Drupal::service('renderer');
    $view = Views::getView('test_taxonomy_vid_field');
    $this->executeView($view);
    $actual = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
        return $view->field['vid']
            ->advancedRender($view->result[0]);
    });
    $vocabulary = Vocabulary::load($this->term1
        ->bundle());
    $expected = $vocabulary->get('name');
    $this->assertEquals($expected, $actual);
}

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