/**
  * Check if aggregation returns the expected array.
  */
 public function testToArray()
 {
     $sorts = new Sorts();
     $aggregation = new TopHitsAggregation('test', 0, 1);
     $expectedAgg = new \stdClass();
     $expectedAgg->size = 0;
     $expectedAgg->from = 1;
     $expectedAgg->sort = $sorts->toArray();
     $expected = ['agg_test' => ['top_hits' => $expectedAgg]];
     $this->assertEquals($expected, $aggregation->toArray());
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function addBuilder(BuilderInterface $builder, $parameters = [])
 {
     $this->sorts->addSort($builder);
 }