function FileEntityFormatterTest::testFormatterFileLinkWithQueryString

Same name in other branches
  1. 10 core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php \Drupal\Tests\file\Kernel\Formatter\FileEntityFormatterTest::testFormatterFileLinkWithQueryString()
  2. 11.x core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php \Drupal\Tests\file\Kernel\Formatter\FileEntityFormatterTest::testFormatterFileLinkWithQueryString()

Tests the file_link field formatter using a query string.

File

core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php, line 177

Class

FileEntityFormatterTest
Tests the default file formatter.

Namespace

Drupal\Tests\file\Kernel\Formatter

Code

public function testFormatterFileLinkWithQueryString() {
    $file = File::create([
        'uri' => 'dummy-external-readonly://file-query-string?foo=bar',
        'filename' => 'file-query-string',
    ]);
    $file->save();
    $file_link = [
        '#theme' => 'file_link',
        '#file' => $file,
    ];
    $output = \Drupal::service('renderer')->renderRoot($file_link);
    $this->assertStringContainsString($this->fileUrlGenerator
        ->generate('dummy-external-readonly://file-query-string?foo=bar')
        ->toUriString(), $output);
}

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