aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/filebackend/FileBackendTest.php
diff options
context:
space:
mode:
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>2015-11-03 11:10:41 +0000
committerGerrit Code Review <gerrit@wikimedia.org>2015-11-03 11:10:41 +0000
commitb85aeec5e2d637fdeab9366df9a96abfba433778 (patch)
treef2c2c2f0703fbbd085fc81a4482f3f0f611d7ab3 /tests/phpunit/includes/filebackend/FileBackendTest.php
parent2d95b805c637be3c425ee02f43cba488f5086478 (diff)
parentde290cd02db7150549da5cc66c9af3de6933a68b (diff)
downloadmediawikicore-b85aeec5e2d637fdeab9366df9a96abfba433778.tar.gz
mediawikicore-b85aeec5e2d637fdeab9366df9a96abfba433778.zip
Merge "Improve MIME detection in FileBackend"
Diffstat (limited to 'tests/phpunit/includes/filebackend/FileBackendTest.php')
-rw-r--r--tests/phpunit/includes/filebackend/FileBackendTest.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/phpunit/includes/filebackend/FileBackendTest.php b/tests/phpunit/includes/filebackend/FileBackendTest.php
index e7d092fad029..95c6092b451e 100644
--- a/tests/phpunit/includes/filebackend/FileBackendTest.php
+++ b/tests/phpunit/includes/filebackend/FileBackendTest.php
@@ -2397,6 +2397,42 @@ class FileBackendTest extends MediaWikiTestCase {
"Scoped unlocking of files succeeded with OK status ($backendName)." );
}
+ /**
+ * @dataProvider provider_testGetContentType
+ */
+ public function testGetContentType( $mimeCallback, $mimeFromString ) {
+ global $IP;
+
+ $be = TestingAccessWrapper::newFromObject( new MemoryFileBackend(
+ array(
+ 'name' => 'testing',
+ 'class' => 'MemoryFileBackend',
+ 'wikiId' => 'meow',
+ 'mimeCallback' => $mimeCallback
+ )
+ ) );
+
+ $dst = 'mwstore://testing/container/path/to/file_no_ext';
+ $src = "$IP/tests/phpunit/data/media/srgb.jpg";
+ $this->assertEquals( 'image/jpeg', $be->getContentType( $dst, null, $src ) );
+ $this->assertEquals(
+ $mimeFromString ? 'image/jpeg' : 'unknown/unknown',
+ $be->getContentType( $dst, file_get_contents( $src ), null ) );
+
+ $src = "$IP/tests/phpunit/data/media/Png-native-test.png";
+ $this->assertEquals( 'image/png', $be->getContentType( $dst, null, $src ) );
+ $this->assertEquals(
+ $mimeFromString ? 'image/png' : 'unknown/unknown',
+ $be->getContentType( $dst, file_get_contents( $src ), null ) );
+ }
+
+ public static function provider_testGetContentType() {
+ return array(
+ array( null, false ),
+ array( array( FileBackendGroup::singleton(), 'guessMimeInternal' ), true )
+ );
+ }
+
public function testReadAffinity() {
$be = TestingAccessWrapper::newFromObject(
new FileBackendMultiWrite( array(