From f6a1d0304a6d313f2b1471b7b209bb66cc6918be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?= <simonas.serlinskas@nfq.com>
Date: Thu, 24 Jan 2019 16:37:24 +0200
Subject: [PATCH] add significant text aggregation

---
 .../Bucketing/SignificantTextAggregation.php  | 28 ++++++++++++
 .../SignificantTextAggregationTest.php        | 45 +++++++++++++++++++
 2 files changed, 73 insertions(+)
 create mode 100644 src/Aggregation/Bucketing/SignificantTextAggregation.php
 create mode 100644 tests/Unit/Aggregation/Bucketing/SignificantTextAggregationTest.php

diff --git a/src/Aggregation/Bucketing/SignificantTextAggregation.php b/src/Aggregation/Bucketing/SignificantTextAggregation.php
new file mode 100644
index 0000000..4b6bd5a
--- /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 0000000..23b96f3
--- /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);
+    }
+}
-- 
GitLab