meanwhile we can have exact matches. also show those.

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2017-10-31 14:58:48 +01:00
parent 582d2d36ee
commit 25aad121e6
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
2 changed files with 31 additions and 1 deletions

View File

@ -69,8 +69,9 @@ class AutoCompleteController extends Controller {
// result from search() thus nothing else to do here. // result from search() thus nothing else to do here.
list($results,) = $this->collaboratorSearch->search($search, $shareTypes, false, $limit, 0); list($results,) = $this->collaboratorSearch->search($search, $shareTypes, false, $limit, 0);
// there won't be exact matches without a search string $exactMatches = $results['exact'];
unset($results['exact']); unset($results['exact']);
$results = array_merge_recursive($exactMatches, $results);
$sorters = array_reverse(explode('|', $sorter)); $sorters = array_reverse(explode('|', $sorter));
$this->autoCompleteManager->runSorters($sorters, $results, [ $this->autoCompleteManager->runSorters($sorters, $results, [

View File

@ -86,4 +86,33 @@ class AutoCompleteControllerTest extends TestCase {
$this->assertEquals($expected, $list); // has better error output… $this->assertEquals($expected, $list); // has better error output…
$this->assertSame($expected, $list); $this->assertSame($expected, $list);
} }
public function testGetWithExactMatch() {
$searchResults = [
'exact' => [
'users' => [
['label' => 'Bob Y.', 'value' => ['shareWith' => 'bob']],
],
'robots' => [],
],
'users' => [
['label' => 'Robert R.', 'value' => ['shareWith' => 'bobby']],
],
];
$expected = [
[ 'id' => 'bob', 'label' => 'Bob Y.', 'source' => 'users'],
[ 'id' => 'bobby', 'label' => 'Robert R.', 'source' => 'users'],
];
$this->collaboratorSearch->expects($this->once())
->method('search')
->willReturn([$searchResults, false]);
$response = $this->controller->get('bob', 'files', '42', null);
$list = $response->getData();
$this->assertEquals($expected, $list); // has better error output…
$this->assertSame($expected, $list);
}
} }