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

Add constructor arguments to PercentilesAggregation.

parent 13177521
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,25 @@ class PercentilesAggregation extends AbstractAggregation
*/
private $compression;
/**
* Inner aggregations container init.
*
* @param string $name
* @param string $field
* @param array $percents
* @param string $script
* @param int $compression
*/
public function __construct($name, $field = null, $percents = null, $script = null, $compression = null)
{
parent::__construct($name);
$this->setField($field);
$this->setPercents($percents);
$this->setScript($script);
$this->setCompression($compression);
}
/**
* @return array
*/
......
......@@ -26,4 +26,28 @@ class PercentilesAggregationTest extends \PHPUnit_Framework_TestCase
$aggregation = new PercentilesAggregation('bar');
$aggregation->getArray();
}
/**
* Test getType method.
*/
public function testGetType()
{
$aggregation = new PercentilesAggregation('bar');
$this->assertEquals('percentiles', $aggregation->getType());
}
/**
* Test getArray method.
*/
public function testGetArray()
{
$aggregation = new PercentilesAggregation('bar', 'fieldValue', ['percentsValue']);
$this->assertSame(
[
'percents' => ['percentsValue'],
'field' => 'fieldValue',
],
$aggregation->getArray()
);
}
}
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