From 9e3162f887ed1d562d29f1bdc9313f5038073364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20Jonu=C5=A1as?= <mantas.jonusas@nfq.lt> Date: Thu, 5 Mar 2015 17:02:38 +0200 Subject: [PATCH] Added filters, geo bound, geohash grid aggregations --- Aggregation/FiltersAggregationTest.php | 33 ++++++++++++++++++++++ Aggregation/GeoBoundsAggregationTest.php | 31 ++++++++++++++++++++ Aggregation/GeoHashGridAggregationTest.php | 31 ++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 Aggregation/FiltersAggregationTest.php create mode 100644 Aggregation/GeoBoundsAggregationTest.php create mode 100644 Aggregation/GeoHashGridAggregationTest.php diff --git a/Aggregation/FiltersAggregationTest.php b/Aggregation/FiltersAggregationTest.php new file mode 100644 index 0000000..4bdcc2a --- /dev/null +++ b/Aggregation/FiltersAggregationTest.php @@ -0,0 +1,33 @@ +<?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\FiltersAggregation; + +/** + * Unit test for filters aggregation. + */ +class FiltersAggregationTest extends \PHPUnit_Framework_TestCase +{ + /** + * Test if exception is thrown when not anonymous filter is without name. + * + * @expectedException \LogicException + * @expectedExceptionMessage In not anonymous filters filter name must be set. + */ + public function testIfExceptionIsThrown() + { + $mock = $this->getMockBuilder('ONGR\ElasticsearchBundle\DSL\BuilderInterface')->getMock(); + $aggregation = new FiltersAggregation('test_agg'); + $aggregation->addFilter($mock); + } +} diff --git a/Aggregation/GeoBoundsAggregationTest.php b/Aggregation/GeoBoundsAggregationTest.php new file mode 100644 index 0000000..d1ede46 --- /dev/null +++ b/Aggregation/GeoBoundsAggregationTest.php @@ -0,0 +1,31 @@ +<?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\GeoBoundsAggregation; + +/** + * Unit test for geo bounds aggregation. + */ +class GeoBoundsAggregationTest extends \PHPUnit_Framework_TestCase +{ + /** + * Test if exception is thrown. + * + * @expectedException \LogicException + */ + public function testGeoBoundsAggregationException() + { + $agg = new GeoBoundsAggregation('test_agg'); + $agg->getArray(); + } +} diff --git a/Aggregation/GeoHashGridAggregationTest.php b/Aggregation/GeoHashGridAggregationTest.php new file mode 100644 index 0000000..0a520e9 --- /dev/null +++ b/Aggregation/GeoHashGridAggregationTest.php @@ -0,0 +1,31 @@ +<?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\GeoHashGridAggregation; + +/** + * Unit test for geohash grid aggregation. + */ +class GeoHashGridAggregationTest extends \PHPUnit_Framework_TestCase +{ + /** + * Test if exception is thrown. + * + * @expectedException \LogicException + */ + public function testGeoHashGridAggregationException() + { + $agg = new GeoHashGridAggregation('test_agg'); + $agg->getArray(); + } +} -- GitLab