function FieldPluginBaseTest::testRenderTrimmedWithMoreLinkAndPath

Same name in other branches
  1. 9 core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::testRenderTrimmedWithMoreLinkAndPath()
  2. 8.9.x core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::testRenderTrimmedWithMoreLinkAndPath()
  3. 10 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 240

Class

FieldPluginBaseTest
@coversDefaultClass \Drupal\views\Plugin\views\field\FieldPluginBase @group views

Namespace

Drupal\Tests\views\Unit\Plugin\field

Code

public function testRenderTrimmedWithMoreLinkAndPath($path, $url) : void {
    $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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.