forked from TYPO3-Solr/ext-solr
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Handle float values in options facet parser
Ports: TYPO3-Solr#3722 by @saschanowak
- Loading branch information
1 parent
22dee75
commit 8f2f567
Showing
2 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
Tests/Unit/Domain/Search/ResultSet/Facets/OptionBased/Options/OptionsFacetParserTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace ApacheSolrForTypo3\Solr\Tests\Unit\Domain\Search\ResultSet\Facets\OptionBased\Options; | ||
|
||
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\OptionBased\Options\OptionsFacetParser; | ||
use ApacheSolrForTypo3\Solr\System\Solr\ResponseAdapter; | ||
use ApacheSolrForTypo3\Solr\Tests\Unit\UnitTest; | ||
|
||
class OptionsFacetParserTest extends UnitTest | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function canListFloatValuesAsOptionsFromSolrResponse(): void | ||
{ | ||
$responseAdapter = new ResponseAdapter( | ||
/* @lang JSON */ | ||
'{ | ||
"facets": { | ||
"floatOptions": { | ||
"buckets": [ | ||
{ "val": 0.001, "count": 1 }, | ||
{ "val": 0.002, "count": 2 }, | ||
{ "val": 0.003, "count": 3 } | ||
] | ||
} | ||
} | ||
}' | ||
); | ||
$optionsFacetParser = $this->getAccessibleMock( | ||
OptionsFacetParser::class, | ||
null, | ||
[], | ||
'', | ||
false | ||
); | ||
/** @link OptionsFacetParser::getOptionsFromSolrResponse */ | ||
$optionsArray = $optionsFacetParser->_call( | ||
'getOptionsFromSolrResponse', | ||
'floatOptions', | ||
$responseAdapter, | ||
); | ||
self::assertCount(3, $optionsArray, 'EXT:solr can not list floats in facets.'); | ||
} | ||
} |