diff --git a/Aggregation/ExtendedStatsAggregationTest.php b/Aggregation/ExtendedStatsAggregationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..cada6226b7a00b4fa5159caf165d36feca91573c --- /dev/null +++ b/Aggregation/ExtendedStatsAggregationTest.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\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(); + } +} diff --git a/Aggregation/PercentileRanksAggregationTest.php b/Aggregation/PercentileRanksAggregationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a063b361372eb09a011d0654f1f0f8fdc183be59 --- /dev/null +++ b/Aggregation/PercentileRanksAggregationTest.php @@ -0,0 +1,65 @@ +<?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(); + } +} diff --git a/Aggregation/PercentilesAggregationTest.php b/Aggregation/PercentilesAggregationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f7d1fd7ea26eaa24818eaa5cad98a406908a8681 --- /dev/null +++ b/Aggregation/PercentilesAggregationTest.php @@ -0,0 +1,29 @@ +<?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(); + } +}