TASK: Add keys for better access to Facets

This commit is contained in:
Daniel Siepmann 2017-07-18 09:27:46 +02:00
parent c58e13cdf6
commit eafed7fb11
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
3 changed files with 5 additions and 5 deletions

View file

@ -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);
}
}
}

View file

@ -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);
}
}
}

View file

@ -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.');
}