Import: Handle uploads with sha1 starting with 0 properly
[mediawiki.git] / tests / phpunit / includes / MimeMagicTest.php
blob3c45f305e57d1bf3258d2b2b925b9cbbb9db5ed6
1 <?php
2 class MimeMagicTest extends PHPUnit_Framework_TestCase {
4 /** @var MimeMagic */
5 private $mimeMagic;
7 function setUp() {
8 $this->mimeMagic = MimeMagic::singleton();
9 parent::setUp();
12 /**
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() {
24 return array(
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' ),
40 /**
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 );