summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2014-07-31 12:06:13 +0200
committerJörn Friedrich Dreyer <jfd@butonic.de>2014-07-31 15:07:49 +0200
commit1af436cb59dcb28892edc2c2edc33f178cbeb66f (patch)
treec2efb0125241f50d413ee81cd126dad22a71f047
parenta7b4cd77b1ea9657dca1929561afdb1ebeb161de (diff)
downloadnextcloud-server-1af436cb59dcb28892edc2c2edc33f178cbeb66f.tar.gz
nextcloud-server-1af436cb59dcb28892edc2c2edc33f178cbeb66f.zip
add test for search() in shared cache
-rw-r--r--apps/files_sharing/tests/cache.php78
1 files changed, 75 insertions, 3 deletions
diff --git a/apps/files_sharing/tests/cache.php b/apps/files_sharing/tests/cache.php
index 8472c7f1ab0..1b0fe6fdc6d 100644
--- a/apps/files_sharing/tests/cache.php
+++ b/apps/files_sharing/tests/cache.php
@@ -95,6 +95,80 @@ class Test_Files_Sharing_Cache extends Test_Files_Sharing_Base {
parent::tearDown();
}
+ function searchDataProvider() {
+ return array(
+ array('%another%',
+ array(
+ array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'),
+ array('name' => 'another.txt', 'path' => 'subdir/another.txt'),
+ )
+ ),
+ array('%Another%',
+ array(
+ array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'),
+ array('name' => 'another.txt', 'path' => 'subdir/another.txt'),
+ )
+ ),
+ array('%dir%',
+ array(
+ array('name' => 'emptydir', 'path' => 'emptydir'),
+ array('name' => 'subdir', 'path' => 'subdir'),
+ array('name' => 'shareddir', 'path' => ''),
+ )
+ ),
+ array('%Dir%',
+ array(
+ array('name' => 'emptydir', 'path' => 'emptydir'),
+ array('name' => 'subdir', 'path' => 'subdir'),
+ array('name' => 'shareddir', 'path' => ''),
+ )
+ ),
+ array('%txt%',
+ array(
+ array('name' => 'bar.txt', 'path' => 'bar.txt'),
+ array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'),
+ array('name' => 'another.txt', 'path' => 'subdir/another.txt'),
+ )
+ ),
+ array('%Txt%',
+ array(
+ array('name' => 'bar.txt', 'path' => 'bar.txt'),
+ array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'),
+ array('name' => 'another.txt', 'path' => 'subdir/another.txt'),
+ )
+ ),
+ array('%',
+ array(
+ array('name' => 'bar.txt', 'path' => 'bar.txt'),
+ array('name' => 'emptydir', 'path' => 'emptydir'),
+ array('name' => 'subdir', 'path' => 'subdir'),
+ array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'),
+ array('name' => 'another.txt', 'path' => 'subdir/another.txt'),
+ array('name' => 'not a text file.xml', 'path' => 'subdir/not a text file.xml'),
+ array('name' => 'shareddir', 'path' => ''),
+ )
+ ),
+ array('%nonexistant%',
+ array(
+ )
+ ),
+ );
+ }
+
+ /**
+ * we cannot use a dataProvider because that would cause the stray hook detection to remove the hooks
+ * that were added in setUpBeforeClass.
+ */
+ function testSearch() {
+ foreach ($this->searchDataProvider() as $data) {
+ list($pattern, $expectedFiles) = $data;
+
+ $results = $this->sharedStorage->getCache()->search($pattern);
+
+ $this->verifyFiles($expectedFiles, $results);
+ }
+
+ }
/**
* Test searching by mime type
*/
@@ -115,8 +189,6 @@ class Test_Files_Sharing_Cache extends Test_Files_Sharing_Base {
),
);
$this->verifyFiles($check, $results);
-
- $this->verifyFiles($check, $results);
}
function testGetFolderContentsInRoot() {
@@ -245,7 +317,7 @@ class Test_Files_Sharing_Cache extends Test_Files_Sharing_Base {
}
}
}
- $this->assertTrue(empty($results));
+ $this->assertEquals(array(), $results);
}
/**