From 9cc5e454098e4b67232c83e54e0a3e973b0c8afd Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Wed, 26 Sep 2018 16:45:04 +0200 Subject: [PATCH 1/2] BUGFIX: Allow to define zero as valid filter value via TypoScript 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. Resolves: #163 --- Classes/Domain/Search/SearchService.php | 4 +- Documentation/source/changelog.rst | 1 + ...-allow-zero-as-typoscript-filter-value.rst | 10 ++++ .../Unit/Domain/Search/SearchServiceTest.php | 55 +++++++++---------- 4 files changed, 39 insertions(+), 31 deletions(-) create mode 100644 Documentation/source/changelog/20180926-163-allow-zero-as-typoscript-filter-value.rst diff --git a/Classes/Domain/Search/SearchService.php b/Classes/Domain/Search/SearchService.php index 1fc792e..7c8beeb 100644 --- a/Classes/Domain/Search/SearchService.php +++ b/Classes/Domain/Search/SearchService.php @@ -126,9 +126,7 @@ class SearchService ArrayUtility::mergeRecursiveWithOverrule( $filter, - $this->configuration->get('searching.filter'), - true, - false + $this->configuration->get('searching.filter') ); $searchRequest->setFilter($filter); diff --git a/Documentation/source/changelog.rst b/Documentation/source/changelog.rst index d6a2b09..2cad89f 100644 --- a/Documentation/source/changelog.rst +++ b/Documentation/source/changelog.rst @@ -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 diff --git a/Documentation/source/changelog/20180926-163-allow-zero-as-typoscript-filter-value.rst b/Documentation/source/changelog/20180926-163-allow-zero-as-typoscript-filter-value.rst new file mode 100644 index 0000000..860e164 --- /dev/null +++ b/Documentation/source/changelog/20180926-163-allow-zero-as-typoscript-filter-value.rst @@ -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`. diff --git a/Tests/Unit/Domain/Search/SearchServiceTest.php b/Tests/Unit/Domain/Search/SearchServiceTest.php index 50c1f49..3b88076 100644 --- a/Tests/Unit/Domain/Search/SearchServiceTest.php +++ b/Tests/Unit/Domain/Search/SearchServiceTest.php @@ -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 */ From ec3d93fb641b590d00861006a4703943a44c3ddc Mon Sep 17 00:00:00 2001 From: Justus Moroni Date: Thu, 27 Sep 2018 16:57:16 +0200 Subject: [PATCH 2/2] TASK: Raise version number to 0.0.7 --- Documentation/source/conf.py | 4 ++-- Documentation/source/installation.rst | 2 +- ext_emconf.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/source/conf.py b/Documentation/source/conf.py index 2e2632b..c559ba3 100644 --- a/Documentation/source/conf.py +++ b/Documentation/source/conf.py @@ -59,9 +59,9 @@ author = u'Daniel Siepmann' # built documents. # # The short X.Y version. -version = u'0.0.6' +version = u'0.0.7' # The full version, including alpha/beta/rc tags. -release = u'0.0.6' +release = u'0.0.7' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # diff --git a/Documentation/source/installation.rst b/Documentation/source/installation.rst index acd56d7..e24b348 100644 --- a/Documentation/source/installation.rst +++ b/Documentation/source/installation.rst @@ -9,7 +9,7 @@ Composer The extension can be installed through composer:: - composer require "codappix/search_core" "~0.0.6" + composer require "codappix/search_core" "~0.0.7" Note that you have to allow unstable packages: diff --git a/ext_emconf.php b/ext_emconf.php index a21c748..b0bc5ed 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -18,7 +18,7 @@ $EM_CONF[$_EXTKEY] = [ ], ], 'state' => 'beta', - 'version' => '0.0.6', + 'version' => '0.0.7', 'author' => 'Daniel Siepmann', 'author_email' => 'coding@daniel-siepmann.de', ];