Commit a5480de8 by Klimov Paul

Test case "FileHelperTest::testGetMimeTypeByExtension()" has been added.

parent 8f7a7837
......@@ -278,4 +278,21 @@ class FileHelperTest extends TestCase
FileHelper::mkdir($dirName, null, true);
$this->assertTrue(file_exists($dirName), 'Unable to create directory recursively!');
}
public function testGetMimeTypeByExtension()
{
$magicFile = $this->testFilePath . DIRECTORY_SEPARATOR . 'mime_type.php';
$mimeTypeMap = array(
'txa' => 'application/json',
'txb' => 'another/mime',
);
$magicFileContent = '<?php return ' . var_export($mimeTypeMap, true) . ';';
file_put_contents($magicFile, $magicFileContent);
foreach ($mimeTypeMap as $extension => $mimeType) {
$fileName = 'test.' . $extension;
$this->assertNull(FileHelper::getMimeTypeByExtension($fileName));
$this->assertEquals($mimeType, FileHelper::getMimeTypeByExtension($fileName, $magicFile));
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment