public function FieldPluginBaseTest::testRenderAsExternalLinkWithPathAndTokens in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::testRenderAsExternalLinkWithPathAndTokens()
- 9 core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::testRenderAsExternalLinkWithPathAndTokens()
Tests rendering of a link with a path and options.
@dataProvider providerTestRenderAsExternalLinkWithPathAndTokens @covers ::renderAsLink
File
- core/
modules/ views/ tests/ src/ Unit/ Plugin/ field/ FieldPluginBaseTest.php, line 597 - Contains \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest.
Class
- FieldPluginBaseTest
- @coversDefaultClass \Drupal\views\Plugin\views\field\FieldPluginBase @group views
Namespace
Drupal\Tests\views\Unit\Plugin\fieldCode
public function testRenderAsExternalLinkWithPathAndTokens($path, $tokens, $link_html, $context) {
$alter = [
'make_link' => TRUE,
'path' => $path,
'url' => '',
];
if (isset($context['alter'])) {
$alter += $context['alter'];
}
$this
->setUpUrlIntegrationServices();
$this
->setupDisplayWithEmptyArgumentsAndFields();
$this->executable->build_info['substitutions'] = $tokens;
$field = $this
->setupTestField([
'alter' => $alter,
]);
$field->field_alias = 'key';
$row = new ResultRow([
'key' => 'value',
]);
$build = [
'#type' => 'inline_template',
'#template' => $path,
'#context' => [
'foo' => $context['context_path'],
],
'#post_render' => [
function () {
},
],
];
$this->renderer
->expects($this
->once())
->method('renderPlain')
->with($build)
->willReturn($context['context_path']);
$result = $field
->advancedRender($row);
$this
->assertEquals($link_html, $result);
}