Merge pull request #87 from Codappix/feature/predefined-filter

BUGFIX: Keep existing arguments in filter mode
This commit is contained in:
Daniel Siepmann 2017-09-16 00:00:53 +02:00 committed by GitHub
commit 5509d4a56b
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' if (isset($this->settings['searching']['mode']) && $this->settings['searching']['mode'] === 'filter'
&& $this->request->hasArgument('searchRequest') === false && $this->request->hasArgument('searchRequest') === false
) { ) {
$this->request->setArguments([ $this->request->setArguments(array_merge(
'searchRequest' => $this->objectManager->get(SearchRequest::class), $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 * @test
*/ */