public function FieldPluginBaseTest::testRenderTrimmedWithMoreLinkAndPath 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::testRenderTrimmedWithMoreLinkAndPath()
- 9 core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::testRenderTrimmedWithMoreLinkAndPath()
Tests rendering with a more link.
@dataProvider providerTestRenderTrimmedWithMoreLinkAndPath @covers ::renderText
Parameters
string $path: An internal or external path.
string $url: The final url used by the more link.
File
- core/
modules/ views/ tests/ src/ Unit/ Plugin/ field/ FieldPluginBaseTest.php, line 243 - 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 testRenderTrimmedWithMoreLinkAndPath($path, $url) {
$alter = [
'trim' => TRUE,
'max_length' => 7,
'more_link' => TRUE,
// Don't invoke translation.
'ellipsis' => FALSE,
'more_link_text' => 'more link',
'more_link_path' => $path,
];
$this->display
->expects($this
->any())
->method('getHandlers')
->willReturnMap([
[
'argument',
[],
],
[
'field',
[],
],
]);
$this
->setUpUrlIntegrationServices();
$field = $this
->setupTestField([
'alter' => $alter,
]);
$field->field_alias = 'key';
$row = new ResultRow([
'key' => 'a long value',
]);
$expected_result = 'a long <a href="' . $url . '" class="views-more-link">more link</a>';
$result = $field
->advancedRender($row);
$this
->assertEquals($expected_result, $result);
}