/** * @return SolrFacetQuery[] */ private function extractFacetQueriesFromSolrResponse() : array { if (!isset($this->response['facet_counts']['facet_queries'])) { return []; } $rawFacetQueries = $this->response['facet_counts']['facet_queries']; return array_map(function ($query) use($rawFacetQueries) { return SolrFacetQuery::fromStringAndCount($query, $rawFacetQueries[$query]); }, array_keys($rawFacetQueries)); }
public function testTransformationIsAppliedToPlainFacetFieldValue() { $attributeCodeString = 'foo'; $value = 'bar'; $encodedValue = 'baz'; $facetQueryString = sprintf('%s:(%s)', $attributeCodeString, $value); /** @var FacetFieldTransformation|\PHPUnit_Framework_MockObject_MockObject $stubTransformation */ $stubTransformation = $this->createMock(FacetFieldTransformation::class); $stubTransformation->method('encode')->with($value)->willReturn($encodedValue); /** @var FacetFieldTransformationRegistry|\PHPUnit_Framework_MockObject_MockObject $stubRegistry */ $stubRegistry = $this->createMock(FacetFieldTransformationRegistry::class); $stubRegistry->method('hasTransformationForCode')->with($attributeCodeString)->willReturn(true); $stubRegistry->method('getTransformationByCode')->with($attributeCodeString)->willReturn($stubTransformation); $facetQuery = SolrFacetQuery::fromStringAndCount($facetQueryString, 1); $this->assertSame($encodedValue, $facetQuery->getEncodedValue($stubRegistry)); }