class TaxonomyFieldTidTest
Same name and namespace in other branches
- 11.x core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldTidTest.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyFieldTidTest
- 10 core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldTidTest.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyFieldTidTest
- 8.9.x core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldTidTest.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyFieldTidTest
Tests the taxonomy term TID field handler.
@group taxonomy
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyFieldTidTest uses \Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait implements \Drupal\Tests\views\Kernel\ViewsKernelTestBase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of TaxonomyFieldTidTest
File
-
core/
modules/ taxonomy/ tests/ src/ Kernel/ Views/ TaxonomyFieldTidTest.php, line 17
Namespace
Drupal\Tests\taxonomy\Kernel\ViewsView source
class TaxonomyFieldTidTest extends ViewsKernelTestBase {
use TaxonomyTestTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'taxonomy',
'taxonomy_test_views',
'text',
'filter',
];
/**
* {@inheritdoc}
*/
public static $testViews = [
'test_taxonomy_tid_field',
];
/**
* A taxonomy term to use in this test.
*
* @var \Drupal\taxonomy\TermInterface
*/
protected $term1;
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) : void {
parent::setUp($import_test_views);
$this->installEntitySchema('taxonomy_term');
$this->installConfig([
'filter',
]);
/** @var \Drupal\taxonomy\Entity\Vocabulary $vocabulary */
$vocabulary = $this->createVocabulary();
$this->term1 = $this->createTerm($vocabulary);
ViewTestData::createTestViews(static::class, [
'taxonomy_test_views',
]);
}
/**
* Tests the taxonomy field handler.
*/
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.