function FieldKernelTest::testRender
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php \Drupal\Tests\views\Kernel\Handler\FieldKernelTest::testRender()
- 8.9.x core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php \Drupal\Tests\views\Kernel\Handler\FieldKernelTest::testRender()
- 11.x core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php \Drupal\Tests\views\Kernel\Handler\FieldKernelTest::testRender()
Tests that the render function is called.
File
-
core/
modules/ views/ tests/ src/ Kernel/ Handler/ FieldKernelTest.php, line 56
Class
- FieldKernelTest
- Tests the generic field handler.
Namespace
Drupal\Tests\views\Kernel\HandlerCode
public function testRender() : void {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$view = Views::getView('test_field_tokens');
$this->executeView($view);
$random_text = $this->randomMachineName();
$view->field['job']
->setTestValue($random_text);
$output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['job']
->theme($view->result[0]);
});
$this->assertEquals($random_text, $output, 'Make sure the render method rendered the manual set value.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.