2 class MimeMagicTest
extends PHPUnit_Framework_TestCase
{
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 [ 'gif', 'image/gif', 'image/gif' ],
26 [ 'gif', 'unknown/unknown', 'unknown/unknown' ],
27 [ 'wrl', 'unknown/unknown', 'model/vrml' ],
28 [ 'txt', 'text/plain', 'text/plain' ],
29 [ 'csv', 'text/plain', 'text/csv' ],
30 [ 'tsv', 'text/plain', 'text/tab-separated-values' ],
31 [ 'js', 'text/javascript', 'application/javascript' ],
32 [ 'js', 'application/x-javascript', 'application/javascript' ],
33 [ 'json', 'text/plain', 'application/json' ],
34 [ 'foo', 'application/x-opc+zip', 'application/zip' ],
35 [ 'docx', 'application/x-opc+zip',
36 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ],
37 [ 'djvu', 'image/x-djvu', 'image/vnd.djvu' ],
38 [ 'wav', 'audio/wav', 'audio/wav' ],
43 * Test to make sure that encoder=ffmpeg2theora doesn't trigger
44 * MEDIATYPE_VIDEO (bug 63584)
46 function testOggRecognize() {
47 $oggFile = __DIR__
. '/../data/media/say-test.ogg';
48 $actualType = $this->mimeMagic
->getMediaType( $oggFile, 'application/ogg' );
49 $this->assertEquals( $actualType, MEDIATYPE_AUDIO
);