mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-21 21:56:10 +01:00
Merge pull request #164 from Codappix/feature/163-allow-zero-as-typoscript-filter
Feature: 163 allow zero as typoscript filter
This commit is contained in:
commit
d279acdbc8
4 changed files with 39 additions and 31 deletions
|
@ -126,9 +126,7 @@ class SearchService
|
|||
|
||||
ArrayUtility::mergeRecursiveWithOverrule(
|
||||
$filter,
|
||||
$this->configuration->get('searching.filter'),
|
||||
true,
|
||||
false
|
||||
$this->configuration->get('searching.filter')
|
||||
);
|
||||
|
||||
$searchRequest->setFilter($filter);
|
||||
|
|
|
@ -13,3 +13,4 @@ Changelog
|
|||
changelog/20180308-131-respect-page-cache-clear
|
||||
changelog/20180308-introduce-php70-type-hints
|
||||
changelog/20180306-120-facet-configuration
|
||||
changelog/20180926-163-allow-zero-as-typoscript-filter-value
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
Bugfix 163 "It's not possible to configure a filter via TS with value 0 - zero"
|
||||
===============================================================================
|
||||
|
||||
Prior to the change it was not possible to define a filter while searching, via
|
||||
TypoScript, with the value `0`. `0` was filtered as empty value.
|
||||
|
||||
Now the configured filter is no longer filtered, it's up to the integrator to provide
|
||||
proper configuration. Therefore `0` is now a valid and respected filter value.
|
||||
|
||||
See :issue:`163`.
|
|
@ -164,6 +164,33 @@ class SearchServiceTest extends AbstractUnitTestCase
|
|||
$this->subject->search($searchRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function configuredFilterWithValueZeroAreAddedToRequestWithoutAnyFilter()
|
||||
{
|
||||
$this->configuration->expects($this->any())
|
||||
->method('getIfExists')
|
||||
->withConsecutive(['searching.size'], ['searching.facets'])
|
||||
->will($this->onConsecutiveCalls(null, null));
|
||||
$this->configuration->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->onConsecutiveCalls(
|
||||
['property' => '0'],
|
||||
$this->throwException(new InvalidArgumentException)
|
||||
));
|
||||
|
||||
$this->connection->expects($this->once())
|
||||
->method('search')
|
||||
->with($this->callback(function ($searchRequest) {
|
||||
return $searchRequest->getFilter() === ['property' => '0'];
|
||||
}))
|
||||
->willReturn($this->getMockBuilder(SearchResultInterface::class)->getMock());
|
||||
|
||||
$searchRequest = new SearchRequest('SearchWord');
|
||||
$this->subject->search($searchRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
@ -220,34 +247,6 @@ class SearchServiceTest extends AbstractUnitTestCase
|
|||
$this->subject->search($searchRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function emptyConfiguredFilterIsNotChangingRequestWithExistingFilter()
|
||||
{
|
||||
$this->configuration->expects($this->any())
|
||||
->method('getIfExists')
|
||||
->withConsecutive(['searching.size'], ['searching.facets'])
|
||||
->will($this->onConsecutiveCalls(null, null));
|
||||
$this->configuration->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->onConsecutiveCalls(
|
||||
['anotherProperty' => ''],
|
||||
$this->throwException(new InvalidArgumentException)
|
||||
));
|
||||
|
||||
$this->connection->expects($this->once())
|
||||
->method('search')
|
||||
->with($this->callback(function ($searchRequest) {
|
||||
return $searchRequest->getFilter() === ['anotherProperty' => 'anything'];
|
||||
}))
|
||||
->willReturn($this->getMockBuilder(SearchResultInterface::class)->getMock());
|
||||
|
||||
$searchRequest = new SearchRequest('SearchWord');
|
||||
$searchRequest->setFilter(['anotherProperty' => 'anything']);
|
||||
$this->subject->search($searchRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue