/**
  * Tests percentile ranks aggregation using script instead of field.
  */
 public function testPercentileRanksWithScript()
 {
     $repository = $this->getManager()->getRepository('AcmeTestBundle:Product');
     $aggregation = new PercentileRanksAggregation('foo');
     $aggregation->setScript("doc['product.price'].value");
     $aggregation->setValues([10, 30]);
     $search = $repository->createSearch()->addAggregation($aggregation);
     /** @var ValueAggregation $result */
     $result = $repository->execute($search)->getAggregations()->find('foo');
     $expectedResults = ['10.0' => 12.5, '30.0' => 100];
     $this->assertEquals($expectedResults, $result->getValue()['values']);
 }
 /**
  * Tests exception when only value is set.
  *
  * @expectedException \LogicException
  */
 public function testIfExceptionIsThrownWhenScriptSetAndValueNotSet()
 {
     $this->agg->setScript('bar');
     $this->agg->toArray();
 }