/**
  * 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());
 }
 /**
  * {@inheritdoc}
  */
 public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
 {
     if ($this->sorts->isRelevant()) {
         return $this->sorts->toArray();
     }
 }