Skip to content
Snippets Groups Projects
Commit 13177521 authored by Aivaras Gotovskis's avatar Aivaras Gotovskis
Browse files

Add constructor arguments to PercentileRanksAggregation.

parent 64d805f5
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,25 @@ class PercentileRanksAggregation extends AbstractAggregation
*/
private $compression;
/**
* Inner aggregations container init.
*
* @param string $name
* @param string $field
* @param array $values
* @param string $script
* @param int $compression
*/
public function __construct($name, $field = null, $values = null, $script = null, $compression = null)
{
parent::__construct($name);
$this->setField($field);
$this->setValues($values);
$this->setScript($script);
$this->setCompression($compression);
}
/**
* @return array
*/
......@@ -98,7 +117,6 @@ class PercentileRanksAggregation extends AbstractAggregation
* @param array $a
*
* @return bool
*
* @throws \LogicException
*/
private function isRequiredParametersSet($a)
......
......@@ -62,4 +62,32 @@ class PercentileRanksAggregationTest extends \PHPUnit_Framework_TestCase
$this->agg->setScript('bar');
$this->agg->toArray();
}
/**
* Test getType method.
*/
public function testGetType()
{
$this->assertEquals('percentile_ranks', $this->agg->getType());
}
/**
* Test toArray method.
*/
public function testToArray()
{
$this->agg->setField('bar');
$this->agg->setValues(['bar']);
$this->assertSame(
[
'agg_foo' => [
'percentile_ranks' => [
'field' => 'bar',
'values' => ['bar'],
],
],
],
$this->agg->toArray()
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment