Skip to content
Snippets Groups Projects
Commit 1af436cb authored by Jörn Friedrich Dreyer's avatar Jörn Friedrich Dreyer
Browse files

add test for search() in shared cache

parent a7b4cd77
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment