mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-25 13:56:11 +01:00
Merge pull request #59 from Codappix/feature/add-facet-keys
TASK: Add keys for better access to Facets
This commit is contained in:
commit
441ac7dd84
3 changed files with 5 additions and 5 deletions
|
@ -87,7 +87,7 @@ class Facet implements FacetInterface
|
|||
}
|
||||
|
||||
foreach ($this->buckets as $bucket) {
|
||||
$this->options[] = new FacetOption($bucket);
|
||||
$this->options[$bucket['key']] = new FacetOption($bucket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ class SearchResult implements SearchResultInterface
|
|||
}
|
||||
|
||||
foreach ($this->result->getAggregations() as $aggregationName => $aggregation) {
|
||||
$this->facets[] = $this->objectManager->get(Facet::class, $aggregationName, $aggregation);
|
||||
$this->facets[$aggregationName] = $this->objectManager->get(Facet::class, $aggregationName, $aggregation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,16 +78,16 @@ class FilterTest extends AbstractFunctionalTestCase
|
|||
|
||||
$this->assertSame(1, count($result->getFacets()), 'Did not receive the single defined facet.');
|
||||
|
||||
$facet = $result->getFacets()[0];
|
||||
$facet = current($result->getFacets());
|
||||
$this->assertSame('contentTypes', $facet->getName(), 'Name of facet was not as expected.');
|
||||
$this->assertSame('CType', $facet->getField(), 'Field of facet was not expected.');
|
||||
|
||||
$options = $facet->getOptions();
|
||||
$this->assertSame(2, count($options), 'Did not receive the expected number of possible options for facet.');
|
||||
$option = $options[0];
|
||||
$option = $options['HTML'];
|
||||
$this->assertSame('HTML', $option->getName(), 'Option did not have expected Name.');
|
||||
$this->assertSame(1, $option->getCount(), 'Option did not have expected count.');
|
||||
$option = $options[1];
|
||||
$option = $options['Header'];
|
||||
$this->assertSame('Header', $option->getName(), 'Option did not have expected Name.');
|
||||
$this->assertSame(1, $option->getCount(), 'Option did not have expected count.');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue