2 class MimeMagicTest
extends MediaWikiTestCase
{
8 $this->mimeMagic
= MimeMagic
::singleton();
13 * @dataProvider providerImproveTypeFromExtension
14 * @param string $ext File extension (no leading dot)
15 * @param string $oldMime Initially detected MIME
16 * @param string $expectedMime MIME type after taking extension into account
18 function testImproveTypeFromExtension( $ext, $oldMime, $expectedMime ) {
19 $actualMime = $this->mimeMagic
->improveTypeFromExtension( $oldMime, $ext );
20 $this->assertEquals( $expectedMime, $actualMime );
23 function providerImproveTypeFromExtension() {
25 array( 'gif', 'image/gif', 'image/gif' ),
26 array( 'gif', 'unknown/unknown', 'unknown/unknown' ),
27 array( 'wrl', 'unknown/unknown', 'model/vrml' ),
28 array( 'txt', 'text/plain', 'text/plain' ),
29 array( 'csv', 'text/plain', 'text/csv' ),
30 array( 'tsv', 'text/plain', 'text/tab-separated-values' ),
31 array( 'json', 'text/plain', 'application/json' ),
32 array( 'foo', 'application/x-opc+zip', 'application/zip' ),
33 array( 'docx', 'application/x-opc+zip',
34 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ),
35 array( 'djvu', 'image/x-djvu', 'image/vnd.djvu' ),
36 array( 'wav', 'audio/wav', 'audio/wav' ),
41 * Test to make sure that encoder=ffmpeg2theora doesn't trigger
42 * MEDIATYPE_VIDEO (bug 63584)
44 function testOggRecognize() {
45 $oggFile = __DIR__
. '/../data/media/say-test.ogg';
46 $actualType = $this->mimeMagic
->getMediaType( $oggFile, 'application/ogg' );
47 $this->assertEquals( $actualType, MEDIATYPE_AUDIO
);