You are here

public function FileEntityFormatterTest::testFormatterFileLinkWithQueryString in Drupal 10

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);
}