13 $this->mimeAnalyzer =
new MimeAnalyzer( [
14 'infoFile' =>
$IP .
"/includes/libs/mime/mime.info",
15 'typeFile' =>
$IP .
"/includes/libs/mime/mime.types",
17 'http://www.w3.org/2000/svg:svg' =>
'image/svg+xml',
18 'svg' =>
'image/svg+xml',
19 'http://www.lysator.liu.se/~alla/dia/:diagram' =>
'application/x-dia-diagram',
20 'http://www.w3.org/1999/xhtml:html' =>
'text/html',
21 'html' =>
'text/html',
28 $class =
new ReflectionClass( get_class( $this->mimeAnalyzer ) );
29 $method = $class->getMethod(
'doGuessMimeType' );
30 $method->setAccessible(
true );
31 return $method->invokeArgs( $this->mimeAnalyzer, $parameters );
41 $actualMime = $this->mimeAnalyzer->improveTypeFromExtension( $oldMime,
$ext );
42 $this->assertEquals( $expectedMime, $actualMime );
47 [
'gif',
'image/gif',
'image/gif' ],
48 [
'gif',
'unknown/unknown',
'unknown/unknown' ],
49 [
'wrl',
'unknown/unknown',
'model/vrml' ],
50 [
'txt',
'text/plain',
'text/plain' ],
51 [
'csv',
'text/plain',
'text/csv' ],
52 [
'tsv',
'text/plain',
'text/tab-separated-values' ],
53 [
'js',
'text/javascript',
'application/javascript' ],
54 [
'js',
'application/x-javascript',
'application/javascript' ],
55 [
'json',
'text/plain',
'application/json' ],
56 [
'foo',
'application/x-opc+zip',
'application/zip' ],
57 [
'docx',
'application/x-opc+zip',
58 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ],
59 [
'djvu',
'image/x-djvu',
'image/vnd.djvu' ],
60 [
'wav',
'audio/wav',
'audio/wav' ],
69 $oggFile = __DIR__ .
'/../../../data/media/say-test.ogg';
70 $actualType = $this->mimeAnalyzer->getMediaType( $oggFile,
'application/ogg' );
79 $oggFile = __DIR__ .
'/../../../data/media/say-test.opus';
80 $actualType = $this->mimeAnalyzer->getMediaType( $oggFile,
'application/ogg' );
88 $file = __DIR__ .
'/../../../data/media/say-test-with-id3.mp3';
89 $actualType = $this->mimeAnalyzer->getMediaType( $file );
97 $file = __DIR__ .
'/../../../data/media/say-test-with-id3.mp3';
99 $this->assertEquals(
'audio/mpeg', $actualType );
106 $file = __DIR__ .
'/../../../data/media/say-test-mpeg1.mp3';
108 $this->assertEquals(
'audio/mpeg', $actualType );
115 $file = __DIR__ .
'/../../../data/media/say-test-mpeg2.mp3';
117 $this->assertEquals(
'audio/mpeg', $actualType );
124 $file = __DIR__ .
'/../../../data/media/say-test-mpeg2.5.mp3';
126 $this->assertEquals(
'audio/mpeg', $actualType );
MimeAnalyzer $mimeAnalyzer
testMP3NoID3RecognizeMPEG2()
Test to make sure that MP3 without id3 tag is recognized (MPEG-2 sample rates)
doGuessMimeType(array $parameters=[])
testOggRecognize()
Test to make sure that encoder=ffmpeg2theora doesn't trigger MEDIATYPE_VIDEO (T65584)
testMP3NoID3RecognizeMPEG2_5()
Test to make sure that MP3 without id3 tag is recognized (MPEG-2.5 sample rates)
testMP3NoID3RecognizeMPEG1()
Test to make sure that MP3 without id3 tag is recognized (MPEG-1 sample rates)
testOpusRecognize()
Test to make sure that Opus audio files don't trigger MEDIATYPE_MULTIMEDIA (bug T151352)
testMP3AsAudio()
Test to make sure that mp3 files are detected as audio type.
testMP3WithID3Recognize()
Test to make sure that MP3 with id3 tag is recognized.
providerImproveTypeFromExtension()
testImproveTypeFromExtension( $ext, $oldMime, $expectedMime)
providerImproveTypeFromExtension