diff --git a/src/Aggregation/Bucketing/SignificantTextAggregation.php b/src/Aggregation/Bucketing/SignificantTextAggregation.php new file mode 100644 index 0000000000000000000000000000000000000000..4b6bd5a36cebb583a6e363675fcb0f08fc42d3e9 --- /dev/null +++ b/src/Aggregation/Bucketing/SignificantTextAggregation.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\Bucketing; + +/** + * Class representing TermsAggregation. + * + * @link https://goo.gl/xI7zoa + */ +class SignificantTextAggregation extends TermsAggregation +{ + /** + * {@inheritdoc} + */ + public function getType() + { + return 'significant_text'; + } +} diff --git a/tests/Unit/Aggregation/Bucketing/SignificantTextAggregationTest.php b/tests/Unit/Aggregation/Bucketing/SignificantTextAggregationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..23b96f3f9513bce0ab82312d8bb4a63a8cf2b1e9 --- /dev/null +++ b/tests/Unit/Aggregation/Bucketing/SignificantTextAggregationTest.php @@ -0,0 +1,45 @@ +<?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\Bucketing\Aggregation; + +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\SignificantTextAggregation; + +/** + * Unit test for children aggregation. + */ +class SignificantTextAggregationTest extends \PHPUnit\Framework\TestCase +{ + /** + * Tests getType method. + */ + public function testSignificantTextAggregationGetType() + { + $aggregation = new SignificantTextAggregation('foo'); + $result = $aggregation->getType(); + $this->assertEquals('significant_text', $result); + } + + /** + * Tests getArray method. + */ + public function testSignificantTermsAggregationGetArray() + { + $mock = $this->getMockBuilder('ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation') + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $aggregation = new SignificantTextAggregation('foo', 'title'); + $aggregation->addAggregation($mock); + $result = $aggregation->getArray(); + $expected = ['field' => 'title']; + $this->assertEquals($expected, $result); + } +}