diff --git a/Aggregation/FiltersAggregationTest.php b/Aggregation/FiltersAggregationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4bdcc2a5c454e958aa4600252600438ebb21180d --- /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 0000000000000000000000000000000000000000..d1ede4672dc7005adb5626e7d6314739ac2f5a81 --- /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/GeoDistanceAggregationTest.php b/Aggregation/GeoDistanceAggregationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..73075a6b2c18a78e408b55795921847221ad4503 --- /dev/null +++ b/Aggregation/GeoDistanceAggregationTest.php @@ -0,0 +1,55 @@ +<?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\GeoDistanceAggregation; + +class GeoDistanceAggregationTest extends \PHPUnit_Framework_TestCase +{ + /** + * Test if exception is thrown when field is not set. + * + * @expectedException \LogicException + * @expectedExceptionMessage Geo distance aggregation must have a field set. + */ + public function testGeoDistanceAggregationExceptionWhenFieldIsNotSet() + { + $agg = new GeoDistanceAggregation('test_agg'); + $agg->setOrigin('50, 70'); + $agg->getArray(); + } + + /** + * Test if exception is thrown when origin is not set. + * + * @expectedException \LogicException + * @expectedExceptionMessage Geo distance aggregation must have an origin set. + */ + public function testGeoDistanceAggregationExceptionWhenOriginIsNotSet() + { + $agg = new GeoDistanceAggregation('test_agg'); + $agg->setField('location'); + $agg->getArray(); + } + + /** + * Test if exception is thrown when field is not set. + * + * @expectedException \LogicException + * @expectedExceptionMessage Either from or to must be set. Both cannot be null. + */ + public function testGeoDistanceAggregationAddRangeException() + { + $agg = new GeoDistanceAggregation('test_agg'); + $agg->addRange(); + } +} diff --git a/Aggregation/GeoHashGridAggregationTest.php b/Aggregation/GeoHashGridAggregationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0a520e9fe28f99f9afcbce6e0d45359150da080f --- /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(); + } +}