BUGFIX: Keep existing arguments in filter mode

E.g. to support paginate widget arguments.
This commit is contained in:
Daniel Siepmann 2017-09-15 23:47:34 +02:00
parent 0dd65085b6
commit 306f5bef84
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
2 changed files with 35 additions and 3 deletions

View file

@ -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),
]
));
}
}

View file

@ -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
*/