From 306f5bef84899c5d7b3c730761600fe8ac9e7e7a Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Fri, 15 Sep 2017 23:47:34 +0200 Subject: [PATCH] BUGFIX: Keep existing arguments in filter mode E.g. to support paginate widget arguments. --- Classes/Controller/SearchController.php | 9 ++++-- .../Unit/Controller/SearchControllerTest.php | 29 +++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/Classes/Controller/SearchController.php b/Classes/Controller/SearchController.php index a02cd80..0fa7f73 100644 --- a/Classes/Controller/SearchController.php +++ b/Classes/Controller/SearchController.php @@ -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), + ] + )); } } diff --git a/Tests/Unit/Controller/SearchControllerTest.php b/Tests/Unit/Controller/SearchControllerTest.php index fa38665..67c6d98 100644 --- a/Tests/Unit/Controller/SearchControllerTest.php +++ b/Tests/Unit/Controller/SearchControllerTest.php @@ -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 */