Skip to content
Snippets Groups Projects
Commit 3f48b2be authored by Mantas's avatar Mantas
Browse files

added date histogram aggregation test

parent 6d9a5507
No related branches found
No related tags found
No related merge requests found
<?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);
}
}
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