From 3f48b2be276a48e00fcbf1939eee226aa8429825 Mon Sep 17 00:00:00 2001
From: Mantas <marc.mantas@gmail.com>
Date: Mon, 27 Jun 2016 15:33:56 +0300
Subject: [PATCH] added date histogram aggregation test

---
 .../DateHistogramAggregationTest.php          | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 tests/Aggregation/DateHistogramAggregationTest.php

diff --git a/tests/Aggregation/DateHistogramAggregationTest.php b/tests/Aggregation/DateHistogramAggregationTest.php
new file mode 100644
index 0000000..50f1643
--- /dev/null
+++ b/tests/Aggregation/DateHistogramAggregationTest.php
@@ -0,0 +1,58 @@
+<?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\Aggregation;
+
+use ONGR\ElasticsearchDSL\Aggregation\DateHistogramAggregation;
+
+/**
+ * Unit test for children aggregation.
+ */
+class DateHistogramAggregationTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * Tests if ChildrenAggregation#getArray throws exception when expected.
+     *
+     * @expectedException \LogicException
+     */
+    public function testGetArrayException()
+    {
+        $aggregation = new DateHistogramAggregation('foo');
+        $aggregation->getArray();
+    }
+
+    /**
+     * Tests getType method.
+     */
+    public function testDateHistogramAggregationGetType()
+    {
+        $aggregation = new DateHistogramAggregation('foo');
+        $result = $aggregation->getType();
+        $this->assertEquals('date_histogram', $result);
+    }
+
+    /**
+     * Tests getArray method.
+     */
+    public function testChildrenAggregationGetArray()
+    {
+        $mock = $this->getMockBuilder('ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation')
+            ->disableOriginalConstructor()
+            ->getMockForAbstractClass();
+        $aggregation = new DateHistogramAggregation('foo');
+        $aggregation->addAggregation($mock);
+        $aggregation->setField('date');
+        $aggregation->setInterval('month');
+        $result = $aggregation->getArray();
+        $expected = ['field' => 'date', 'interval' => 'month'];
+        $this->assertEquals($expected, $result);
+    }
+}
-- 
GitLab