summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-02-07 13:33:49 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-02-07 13:33:49 +0100
commit90556cb70bd97dd3507741272c0ebbfee652d900 (patch)
tree591ade6888f70f0f663cf02e8d1ac64f46dbbcca /tests/lib
parentb05e4e085c438b6fc2fca43052261b638843362c (diff)
parent7fbf1a20d7365da4c7eaea3aff857a5d72ee13fb (diff)
downloadnextcloud-server-90556cb70bd97dd3507741272c0ebbfee652d900.tar.gz
nextcloud-server-90556cb70bd97dd3507741272c0ebbfee652d900.zip
Merge pull request #12283 from oparoz/sfnt-fonts
Updated the media type of some font types
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/repair/repairmimetypes.php105
1 files changed, 105 insertions, 0 deletions
diff --git a/tests/lib/repair/repairmimetypes.php b/tests/lib/repair/repairmimetypes.php
index 6eaf68d8a44..403474957f1 100644
--- a/tests/lib/repair/repairmimetypes.php
+++ b/tests/lib/repair/repairmimetypes.php
@@ -1,6 +1,7 @@
<?php
/**
* Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
+ * Copyright (c) 2014 Olivier Paroz owncloud@oparoz.com
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
@@ -110,6 +111,33 @@ class TestRepairMimeTypes extends \Test\TestCase {
)
);
}
+
+ /**
+ * Test renaming old fonts mime types
+ */
+ public function testRenameFontsMimeTypes() {
+ $this->addEntries(
+ array(
+ array('test.ttf', 'application/x-font-ttf'),
+ array('test.otf', 'font/opentype'),
+ array('test.pfb', 'application/octet-stream'),
+ )
+ );
+
+ $this->repair->run();
+
+ // force mimetype reload
+ DummyFileCache::clearCachedMimeTypes();
+ $this->storage->getCache()->loadMimeTypes();
+
+ $this->checkEntries(
+ array(
+ array('test.ttf', 'application/font-sfnt'),
+ array('test.otf', 'application/font-sfnt'),
+ array('test.pfb', 'application/x-font'),
+ )
+ );
+ }
/**
* Test renaming the APK mime type
@@ -137,6 +165,31 @@ class TestRepairMimeTypes extends \Test\TestCase {
)
);
}
+
+ /**
+ * Test renaming the postscript mime types
+ */
+ public function testRenamePostscriptMimeType() {
+ $this->addEntries(
+ array(
+ array('test.eps', 'application/octet-stream'),
+ array('test.ps', 'application/octet-stream'),
+ )
+ );
+
+ $this->repair->run();
+
+ // force mimetype reload
+ DummyFileCache::clearCachedMimeTypes();
+ $this->storage->getCache()->loadMimeTypes();
+
+ $this->checkEntries(
+ array(
+ array('test.eps', 'application/postscript'),
+ array('test.ps', 'application/postscript'),
+ )
+ );
+ }
/**
* Test renaming and splitting old office mime types when
@@ -188,6 +241,46 @@ class TestRepairMimeTypes extends \Test\TestCase {
$this->assertNull($this->getMimeTypeIdFromDB('application/msexcel'));
$this->assertNull($this->getMimeTypeIdFromDB('application/mspowerpoint'));
}
+
+ /**
+ * Test renaming old fonts mime types when
+ * new ones already exist
+ */
+ public function testRenameFontsMimeTypesWhenExist() {
+ $this->addEntries(
+ array(
+ array('test.ttf', 'application/x-font-ttf'),
+ array('test.otf', 'font/opentype'),
+ // make it so that the new mimetypes already exist
+ array('bogus.ttf', 'application/font-sfnt'),
+ array('bogus.otf', 'application/font-sfnt'),
+ array('bogus2.ttf', 'application/wrong'),
+ array('bogus2.otf', 'application/wrong'),
+ )
+ );
+
+ $this->repair->run();
+
+ // force mimetype reload
+ DummyFileCache::clearCachedMimeTypes();
+ $this->storage->getCache()->loadMimeTypes();
+
+ $this->checkEntries(
+ array(
+ array('test.ttf', 'application/font-sfnt'),
+ array('test.otf', 'application/font-sfnt'),
+ array('bogus.ttf', 'application/font-sfnt'),
+ array('bogus.otf', 'application/font-sfnt'),
+ array('bogus2.ttf', 'application/font-sfnt'),
+ array('bogus2.otf', 'application/font-sfnt'),
+ )
+ );
+
+ // wrong mimetypes are gone
+ $this->assertNull($this->getMimeTypeIdFromDB('application/x-font-ttf'));
+ $this->assertNull($this->getMimeTypeIdFromDB('font'));
+ $this->assertNull($this->getMimeTypeIdFromDB('font/opentype'));
+ }
/**
* Test that nothing happens and no error happens when all mimetypes are
@@ -202,6 +295,12 @@ class TestRepairMimeTypes extends \Test\TestCase {
array('test.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'),
array('test.ppt', 'application/vnd.ms-powerpoint'),
array('test.pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'),
+ array('test.apk', 'application/vnd.android.package-archive'),
+ array('test.ttf', 'application/font-sfnt'),
+ array('test.otf', 'application/font-sfnt'),
+ array('test.pfb', 'application/x-font'),
+ array('test.eps', 'application/postscript'),
+ array('test.ps', 'application/postscript'),
)
);
@@ -219,6 +318,12 @@ class TestRepairMimeTypes extends \Test\TestCase {
array('test.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'),
array('test.ppt', 'application/vnd.ms-powerpoint'),
array('test.pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'),
+ array('test.apk', 'application/vnd.android.package-archive'),
+ array('test.ttf', 'application/font-sfnt'),
+ array('test.otf', 'application/font-sfnt'),
+ array('test.pfb', 'application/x-font'),
+ array('test.eps', 'application/postscript'),
+ array('test.ps', 'application/postscript'),
)
);
}