public function FileMimeTest::testFileMime in File MIME 8
Tests that a file MIME is set on the file object.
File
- tests/
src/ Functional/ FileMimeTest.php, line 45
Class
- FileMimeTest
- File MIME tests.
Namespace
Drupal\Tests\filemime\FunctionalCode
public function testFileMime() {
$file = File::create([
'uid' => 1,
'filename' => 'druplicon.filemime',
'uri' => 'public://druplicon.filemime',
'created' => 1,
'changed' => 1,
'status' => FILE_STATUS_PERMANENT,
]);
file_put_contents($file
->getFileUri(), 'hello world');
$file
->save();
$this
->assertSame('example/x-does-not-exist', $file
->getMimeType(), 'File MIME was set correctly.');
}