From 14f74d141ab5580688bfd46d2f74c026e43ed967 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 1 Apr 2015 06:11:44 +0200 Subject: Update to MediaWiki 1.24.2 --- tests/phpunit/includes/MimeMagicTest.php | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/phpunit/includes/MimeMagicTest.php (limited to 'tests/phpunit/includes/MimeMagicTest.php') diff --git a/tests/phpunit/includes/MimeMagicTest.php b/tests/phpunit/includes/MimeMagicTest.php new file mode 100644 index 00000000..742d3827 --- /dev/null +++ b/tests/phpunit/includes/MimeMagicTest.php @@ -0,0 +1,49 @@ +mimeMagic = MimeMagic::singleton(); + parent::setUp(); + } + + /** + * @dataProvider providerImproveTypeFromExtension + * @param string $ext File extension (no leading dot) + * @param string $oldMime Initially detected MIME + * @param string $expectedMime MIME type after taking extension into account + */ + function testImproveTypeFromExtension( $ext, $oldMime, $expectedMime ) { + $actualMime = $this->mimeMagic->improveTypeFromExtension( $oldMime, $ext ); + $this->assertEquals( $expectedMime, $actualMime ); + } + + function providerImproveTypeFromExtension() { + return array( + array( 'gif', 'image/gif', 'image/gif' ), + array( 'gif', 'unknown/unknown', 'unknown/unknown' ), + array( 'wrl', 'unknown/unknown', 'model/vrml' ), + array( 'txt', 'text/plain', 'text/plain' ), + array( 'csv', 'text/plain', 'text/csv' ), + array( 'tsv', 'text/plain', 'text/tab-separated-values' ), + array( 'json', 'text/plain', 'application/json' ), + array( 'foo', 'application/x-opc+zip', 'application/zip' ), + array( 'docx', 'application/x-opc+zip', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ), + array( 'djvu', 'image/x-djvu', 'image/vnd.djvu' ), + array( 'wav', 'audio/wav', 'audio/wav' ), + ); + } + + /** + * Test to make sure that encoder=ffmpeg2theora doesn't trigger + * MEDIATYPE_VIDEO (bug 63584) + */ + function testOggRecognize() { + $oggFile = __DIR__ . '/../data/media/say-test.ogg'; + $actualType = $this->mimeMagic->getMediaType( $oggFile, 'application/ogg' ); + $this->assertEquals( $actualType, MEDIATYPE_AUDIO ); + } +} -- cgit v1.2.3-54-g00ecf