function FileEntityFormatterTest::testFormatterFileMime

Same name in other branches
  1. 9 core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php \Drupal\Tests\file\Kernel\Formatter\FileEntityFormatterTest::testFormatterFileMime()
  2. 10 core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php \Drupal\Tests\file\Kernel\Formatter\FileEntityFormatterTest::testFormatterFileMime()
  3. 11.x 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 137

Class

FileEntityFormatterTest
Tests the default file formatter.

Namespace

Drupal\Tests\file\Kernel\Formatter

Code

public function testFormatterFileMime() {
    $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 $i => $file) {
        $build = $entity_display->build($file);
        $this->assertEqual('image__file_icon', $build['filemime'][0]['#theme']);
        $this->assertEqual(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.