Merge "Make unused variable optional in ChangesList::insertDiffHist"
[lhc/web/wiklou.git] / tests / phpunit / includes / MimeMagicTest.php
1 <?php
2 class MimeMagicTest extends PHPUnit_Framework_TestCase {
3
4 /** @var MimeMagic */
5 private $mimeMagic;
6
7 function setUp() {
8 $this->mimeMagic = MimeMagic::singleton();
9 parent::setUp();
10 }
11
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
17 */
18 function testImproveTypeFromExtension( $ext, $oldMime, $expectedMime ) {
19 $actualMime = $this->mimeMagic->improveTypeFromExtension( $oldMime, $ext );
20 $this->assertEquals( $expectedMime, $actualMime );
21 }
22
23 function providerImproveTypeFromExtension() {
24 return [
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' ],
39 ];
40 }
41
42 /**
43 * Test to make sure that encoder=ffmpeg2theora doesn't trigger
44 * MEDIATYPE_VIDEO (bug 63584)
45 */
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 );
50 }
51 }