function FieldPluginBaseTest::testRenderAsLinkWithPathAndTokens
Same name in other branches
- 9 core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::testRenderAsLinkWithPathAndTokens()
- 10 core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::testRenderAsLinkWithPathAndTokens()
- 11.x core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::testRenderAsLinkWithPathAndTokens()
Test rendering of a link with a path and options.
@dataProvider providerTestRenderAsLinkWithPathAndTokens @covers ::renderAsLink
File
-
core/
modules/ views/ tests/ src/ Unit/ Plugin/ field/ FieldPluginBaseTest.php, line 537
Class
- FieldPluginBaseTest
- @coversDefaultClass \Drupal\views\Plugin\views\field\FieldPluginBase @group views
Namespace
Drupal\Tests\views\Unit\Plugin\fieldCode
public function testRenderAsLinkWithPathAndTokens($path, $tokens, $link_html) {
$alter = [
'make_link' => TRUE,
'path' => $path,
];
$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' => 'test-path/' . explode('/', $path)[1],
'#context' => [
'foo' => 123,
],
'#post_render' => [
function () {
},
],
];
$this->renderer
->expects($this->once())
->method('renderPlain')
->with($build)
->willReturn('base:test-path/123');
$result = $field->advancedRender($row);
$this->assertEquals($link_html, $result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.