aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2025-02-06 16:13:27 +0100
committerGitHub <noreply@github.com>2025-02-06 16:13:27 +0100
commit93c72f5675f391fb016f8f9aefc429c7bb0d459b (patch)
treefec3d61626fbd281136e76ddbc45505aaf08b540 /tests
parente71e58e06e4c3783e579de2a1cf04a8f201b24e9 (diff)
parent1e30936b78697c5a474c10537fa45e5cdce342e5 (diff)
downloadnextcloud-server-93c72f5675f391fb016f8f9aefc429c7bb0d459b.tar.gz
nextcloud-server-93c72f5675f391fb016f8f9aefc429c7bb0d459b.zip
Merge pull request #50660 from nextcloud/fix/mime-int
fix: make sure we process mime extensions as string
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Type/DetectionTest.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/lib/Files/Type/DetectionTest.php b/tests/lib/Files/Type/DetectionTest.php
index dcbb455efc9..a11a59bed1e 100644
--- a/tests/lib/Files/Type/DetectionTest.php
+++ b/tests/lib/Files/Type/DetectionTest.php
@@ -100,6 +100,41 @@ class DetectionTest extends \Test\TestCase {
$this->assertEquals($expected, $result);
}
+ public function dataMimeTypeCustom(): array {
+ return [
+ ['123', 'foobar/123'],
+ ['a123', 'foobar/123'],
+ ['bar', 'foobar/bar'],
+ ];
+ }
+
+ /**
+ * @dataProvider dataMimeTypeCustom
+ *
+ * @param string $ext
+ * @param string $mime
+ */
+ public function testDetectMimeTypeCustom(string $ext, string $mime): void {
+ $confDir = sys_get_temp_dir();
+ file_put_contents($confDir . '/mimetypemapping.dist.json', json_encode([]));
+
+ /** @var IURLGenerator $urlGenerator */
+ $urlGenerator = $this->getMockBuilder(IURLGenerator::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ /** @var LoggerInterface $logger */
+ $logger = $this->createMock(LoggerInterface::class);
+
+ // Create new mapping file
+ file_put_contents($confDir . '/mimetypemapping.dist.json', json_encode([$ext => [$mime]]));
+
+ $detection = new Detection($urlGenerator, $logger, $confDir, $confDir);
+ $mappings = $detection->getAllMappings();
+ $this->assertArrayHasKey($ext, $mappings);
+ $this->assertEquals($mime, $detection->detectPath('foo.' . $ext));
+ }
+
public function dataGetSecureMimeType(): array {
return [
['image/svg+xml', 'text/plain'],