function FileEntityFormatterTest::testFormatterFileLink
Same name in other branches
- 8.9.x core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php \Drupal\Tests\file\Kernel\Formatter\FileEntityFormatterTest::testFormatterFileLink()
- 10 core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php \Drupal\Tests\file\Kernel\Formatter\FileEntityFormatterTest::testFormatterFileLink()
- 11.x core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php \Drupal\Tests\file\Kernel\Formatter\FileEntityFormatterTest::testFormatterFileLink()
Tests the file_link field formatter.
File
-
core/
modules/ file/ tests/ src/ Kernel/ Formatter/ FileEntityFormatterTest.php, line 80
Class
- FileEntityFormatterTest
- Tests the default file formatter.
Namespace
Drupal\Tests\file\Kernel\FormatterCode
public function testFormatterFileLink() {
$entity_display = EntityViewDisplay::create([
'targetEntityType' => 'file',
'bundle' => 'file',
]);
$entity_display->setComponent('filename', [
'type' => 'file_link',
]);
$build = $entity_display->buildMultiple($this->files)[0]['filename'][0];
$this->assertEquals('file.png', $build['#title']);
$this->assertEquals($this->fileUrlGenerator
->generate('public://file.png'), $build['#url']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.