Skip to content
Snippets Groups Projects
Unverified Commit 603f0d4c authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3042640 by jian he, claudiu.cristea: Convert TaxonomyFieldTidTest to a kernel test

parent bdd4ddb9
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
<?php
namespace Drupal\Tests\taxonomy\Functional\Views;
namespace Drupal\Tests\taxonomy\Kernel\Views;
use Drupal\Core\Link;
use Drupal\Core\Render\RenderContext;
use Drupal\Tests\taxonomy\Functional\TaxonomyTestTrait;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Views;
/**
......@@ -10,15 +14,46 @@
*
* @group taxonomy
*/
class TaxonomyFieldTidTest extends TaxonomyTestBase {
class TaxonomyFieldTidTest extends ViewsKernelTestBase {
use TaxonomyTestTrait;
/**
* Views used by this test.
*
* @var array
* {@inheritdoc}
*/
public 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) {
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(get_class($this), ['taxonomy_test_views']);
}
/**
* Tests the taxonomy field handler.
*/
public function testViewsHandlerTidField() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
......@@ -29,9 +64,9 @@ public function testViewsHandlerTidField() {
$actual = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$expected = \Drupal::l($this->term1->label(), $this->term1->toUrl());
$expected = Link::fromTextAndUrl($this->term1->label(), $this->term1->toUrl());
$this->assertEqual($expected, $actual);
$this->assertEquals($expected->toString(), $actual);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment