You are here

public function TaxonomyFieldVidTest::testViewsHandlerVidField in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldVidTest.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyFieldVidTest::testViewsHandlerVidField()
  2. 9 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);
}