public function FileEntityFormatterTest::testFormatterFileUri in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/file/src/Tests/Formatter/FileEntityFormatterTest.php \Drupal\file\Tests\Formatter\FileEntityFormatterTest::testFormatterFileUri()
Tests the file_link field formatter.
File
- core/
modules/ file/ src/ Tests/ Formatter/ FileEntityFormatterTest.php, line 94 - Contains \Drupal\file\Tests\Formatter\FileEntityFormatterTest.
Class
- FileEntityFormatterTest
- Tests the default file formatter.
Namespace
Drupal\file\Tests\FormatterCode
public function testFormatterFileUri() {
$entity_display = EntityViewDisplay::create([
'targetEntityType' => 'file',
'bundle' => 'file',
]);
$entity_display
->setComponent('uri', [
'type' => 'file_uri',
]);
$build = $entity_display
->buildMultiple($this->files)[0]['uri'][0];
$this
->assertEqual('public://file.png', $build['#markup']);
$entity_display
->setComponent('uri', [
'type' => 'file_uri',
'settings' => [
'file_download_path' => TRUE,
],
]);
$build = $entity_display
->buildMultiple($this->files)[0]['uri'][0];
$this
->assertEqual(file_create_url('public://file.png'), $build['#markup']);
$entity_display
->setComponent('uri', [
'type' => 'file_uri',
'settings' => [
'file_download_path' => TRUE,
'link_to_file' => TRUE,
],
]);
$build = $entity_display
->buildMultiple($this->files)[0]['uri'][0];
$this
->assertEqual(file_create_url('public://file.png'), $build['#title']);
$this
->assertEqual(Url::fromUri(file_create_url('public://file.png')), $build['#url']);
}