summaryrefslogtreecommitdiffstats
path: root/tests/lib/files/view.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-12-02 16:48:15 +0100
committerRobin Appelman <icewind@owncloud.com>2015-12-03 13:09:13 +0100
commit19b2fe6a3ab4d9ded3c6974ac109d5d5b02251bb (patch)
tree358b0d40c401b61e0a5ac81b995c4e4a8db0fea1 /tests/lib/files/view.php
parentdf5872ec50a68de5d99bd6b5cf17ceb94f2ef833 (diff)
downloadnextcloud-server-19b2fe6a3ab4d9ded3c6974ac109d5d5b02251bb.tar.gz
nextcloud-server-19b2fe6a3ab4d9ded3c6974ac109d5d5b02251bb.zip
Fix mimetype filter in getDirectoryContent
Diffstat (limited to 'tests/lib/files/view.php')
-rw-r--r--tests/lib/files/view.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 186cf28d7c3..1fc4b9ab684 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -2389,4 +2389,39 @@ class View extends \Test\TestCase {
$view = new \OC\Files\View('/' . $this->user . '/files');
$this->assertEquals('foo', $view->rmdir('mount'));
}
+
+ public function mimeFilterProvider() {
+ return [
+ [null, ['test1.txt', 'test2.txt', 'test3.md', 'test4.png']],
+ ['text/plain', ['test1.txt', 'test2.txt']],
+ ['text/markdown', ['test3.md']],
+ ['text', ['test1.txt', 'test2.txt', 'test3.md']],
+ ];
+ }
+
+ /**
+ * @param string $filter
+ * @param string[] $expected
+ * @dataProvider mimeFilterProvider
+ */
+ public function testGetDirectoryContentMimeFilter($filter, $expected) {
+ $storage1 = new Temporary();
+ $root = $this->getUniqueID('/');
+ \OC\Files\Filesystem::mount($storage1, array(), $root . '/');
+ $view = new \OC\Files\View($root);
+
+ $view->file_put_contents('test1.txt', 'asd');
+ $view->file_put_contents('test2.txt', 'asd');
+ $view->file_put_contents('test3.md', 'asd');
+ $view->file_put_contents('test4.png', '');
+
+ $content = $view->getDirectoryContent('', $filter);
+
+ $files = array_map(function(FileInfo $info) {
+ return $info->getName();
+ }, $content);
+ sort($files);
+
+ $this->assertEquals($expected, $files);
+ }
}