mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-25 16:56:12 +01:00
Merge pull request #87 from Codappix/feature/predefined-filter
BUGFIX: Keep existing arguments in filter mode
This commit is contained in:
commit
5509d4a56b
2 changed files with 35 additions and 3 deletions
|
@ -49,9 +49,12 @@ class SearchController extends ActionController
|
|||
if (isset($this->settings['searching']['mode']) && $this->settings['searching']['mode'] === 'filter'
|
||||
&& $this->request->hasArgument('searchRequest') === false
|
||||
) {
|
||||
$this->request->setArguments([
|
||||
'searchRequest' => $this->objectManager->get(SearchRequest::class),
|
||||
]);
|
||||
$this->request->setArguments(array_merge(
|
||||
$this->request->getArguments(),
|
||||
[
|
||||
'searchRequest' => $this->objectManager->get(SearchRequest::class),
|
||||
]
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -83,6 +83,35 @@ class SearchControllerTest extends AbstractUnitTestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function searchRequestArgumentIsAddedToExistingArguments()
|
||||
{
|
||||
$this->request->setArguments([
|
||||
'@widget_0' => [
|
||||
'currentPage' => '7',
|
||||
]
|
||||
]);
|
||||
$this->inject($this->subject, 'settings', [
|
||||
'searching' => [
|
||||
'mode' => 'filter',
|
||||
]
|
||||
]);
|
||||
|
||||
$this->subject->initializeSearchAction();
|
||||
$this->assertInstanceOf(
|
||||
SearchRequest::class,
|
||||
$this->request->getArgument('searchRequest'),
|
||||
'Search request was not created.'
|
||||
);
|
||||
$this->assertSame(
|
||||
['currentPage' => '7'],
|
||||
$this->request->getArgument('@widget_0'),
|
||||
'Existing arguments were not kept.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue