function FileEntityFormatterTest::testFormatterFileMime
Same name in other branches
- 9 core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php \Drupal\Tests\file\Kernel\Formatter\FileEntityFormatterTest::testFormatterFileMime()
- 8.9.x core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php \Drupal\Tests\file\Kernel\Formatter\FileEntityFormatterTest::testFormatterFileMime()
- 10 core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php \Drupal\Tests\file\Kernel\Formatter\FileEntityFormatterTest::testFormatterFileMime()
Tests the file_extension field formatter.
File
-
core/
modules/ file/ tests/ src/ Kernel/ Formatter/ FileEntityFormatterTest.php, line 145
Class
- FileEntityFormatterTest
- Tests the default file formatter.
Namespace
Drupal\Tests\file\Kernel\FormatterCode
public function testFormatterFileMime() : void {
$entity_display = EntityViewDisplay::create([
'targetEntityType' => 'file',
'bundle' => 'file',
]);
$entity_display->setComponent('filemime', [
'type' => 'file_filemime',
'settings' => [
'filemime_image' => TRUE,
],
]);
foreach (array_values($this->files) as $file) {
$build = $entity_display->build($file);
$this->assertEquals('image__file_icon', $build['filemime'][0]['#theme']);
$this->assertEquals(spl_object_hash($file), spl_object_hash($build['filemime'][0]['#file']));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.