diff --git a/src/Aggregation/Pipeline/MovingFunctionAggregation.php b/src/Aggregation/Pipeline/MovingFunctionAggregation.php new file mode 100644 index 0000000000000000000000000000000000000000..70d587e80d77b3b20839619d97457ca97fe3baf6 --- /dev/null +++ b/src/Aggregation/Pipeline/MovingFunctionAggregation.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of the ONGR package. + * + * (c) NFQ Technologies UAB <info@nfq.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ONGR\ElasticsearchDSL\Aggregation\Pipeline; + +/** + * Class representing Max Bucket Pipeline Aggregation. + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-movfn-aggregation.html + */ +class MovingFunctionAggregation extends AbstractPipelineAggregation +{ + /** + * {@inheritdoc} + */ + public function getType() + { + return 'moving_fn'; + } +} diff --git a/tests/Unit/Aggregation/Pipeline/MovingFunctionAggregationTest.php b/tests/Unit/Aggregation/Pipeline/MovingFunctionAggregationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0f769cf1cec2dc68afbd7f5a9f8f75dddda15a42 --- /dev/null +++ b/tests/Unit/Aggregation/Pipeline/MovingFunctionAggregationTest.php @@ -0,0 +1,36 @@ +<?php + +/* + * This file is part of the ONGR package. + * + * (c) NFQ Technologies UAB <info@nfq.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation\Pipeline; + +use ONGR\ElasticsearchDSL\Aggregation\Pipeline\MovingFunctionAggregation; + +/** + * Unit test for sum bucket aggregation. + */ +class MovingFunctionAggregationTest extends \PHPUnit\Framework\TestCase +{ + /** + * Tests toArray method. + */ + public function testToArray() + { + $aggregation = new MovingFunctionAggregation('acme', 'test'); + + $expected = [ + 'moving_fn' => [ + 'buckets_path' => 'test', + ], + ]; + + $this->assertEquals($expected, $aggregation->toArray()); + } +}