Skip to content
Snippets Groups Projects
Commit fe6014c9 authored by Simonas Šerlinskas's avatar Simonas Šerlinskas
Browse files

Merge pull request #289 from chyzas/patch-dsl-scripts-aggregations

Added more aggregations
parents 62a08b7d e4571a83
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\ElasticsearchBundle\Tests\Unit\DSL\Aggregation;
use ONGR\ElasticsearchBundle\DSL\Aggregation\ExtendedStatsAggregation;
class ExtendedStatsAggregationTest extends \PHPUnit_Framework_TestCase
{
/**
* Tests if exception is thrown when expected.
*
* @expectedException \LogicException
*/
public function testExtendedStatsAggregationGetArrayException()
{
$agg = new ExtendedStatsAggregation('foo');
$agg->getArray();
}
}
<?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\ElasticsearchBundle\Tests\Unit\DSL\Aggregation;
use ONGR\ElasticsearchBundle\DSL\Aggregation\PercentileRanksAggregation;
/**
* Percentile ranks aggregation unit tests.
*/
class PercentileRanksAggregationTest extends \PHPUnit_Framework_TestCase
{
/**
* @var PercentileRanksAggregation
*/
public $agg;
/**
* Phpunit setup.
*/
public function setUp()
{
$this->agg = new PercentileRanksAggregation('foo');
}
/**
* Tests if exception is thrown when required parameters not set.
*
* @expectedException \LogicException
*/
public function testIfPercentileRanksAggregationThrowsAnException()
{
$this->agg->toArray();
}
/**
* Tests exception when only field is set.
*
* @expectedException \LogicException
*/
public function testIfExceptionIsThrownWhenFieldSetAndValueNotSet()
{
$this->agg->setField('bar');
$this->agg->toArray();
}
/**
* Tests exception when only value is set.
*
* @expectedException \LogicException
*/
public function testIfExceptionIsThrownWhenScriptSetAndValueNotSet()
{
$this->agg->setScript('bar');
$this->agg->toArray();
}
}
<?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\ElasticsearchBundle\Tests\Unit\DSL\Aggregation;
use ONGR\ElasticsearchBundle\DSL\Aggregation\PercentilesAggregation;
class PercentilesAggregationTest extends \PHPUnit_Framework_TestCase
{
/**
* Tests if PercentilesAggregation#getArray throws exception when expected.
*
* @expectedException \LogicException
* @expectedExceptionMessage Percentiles aggregation must have field or script set.
*/
public function testPercentilesAggregationGetArrayException()
{
$aggregation = new PercentilesAggregation('bar');
$aggregation->getArray();
}
}
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