From de1b5392057b3ed9530f809a94d570bc68794653 Mon Sep 17 00:00:00 2001 From: LTRocky <rokasvaliukas@gmail.com> Date: Tue, 10 Mar 2015 15:49:46 +0200 Subject: [PATCH] Test DSL/Filter --- Filter/GeoDistanceFilterTest.php | 27 ++++++++++++++++++++++++++ Filter/GeoDistanceRangeFilterTest.php | 27 ++++++++++++++++++++++++++ Filter/GeoPolygonFilterTest.php | 27 ++++++++++++++++++++++++++ Filter/HasChildFilterTest.php | 28 +++++++++++++++++++++++++++ Filter/HasParentFilterTest.php | 28 +++++++++++++++++++++++++++ Highlight/FieldTest.php | 2 -- Suggester/PhraseTest.php | 2 -- 7 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 Filter/GeoDistanceFilterTest.php create mode 100644 Filter/GeoDistanceRangeFilterTest.php create mode 100644 Filter/GeoPolygonFilterTest.php create mode 100644 Filter/HasChildFilterTest.php create mode 100644 Filter/HasParentFilterTest.php diff --git a/Filter/GeoDistanceFilterTest.php b/Filter/GeoDistanceFilterTest.php new file mode 100644 index 0000000..ef47d67 --- /dev/null +++ b/Filter/GeoDistanceFilterTest.php @@ -0,0 +1,27 @@ +<?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\Filter; + +use ONGR\ElasticsearchBundle\DSL\Filter\GeoDistanceFilter; + +class GeoDistanceFilterTest extends \PHPUnit_Framework_TestCase +{ + /** + * Tests GetType method. + */ + public function testGetType() + { + $filter = new GeoDistanceFilter('test_field', 'test_distance', 'test_location'); + $result = $filter->getType(); + $this->assertEquals('geo_distance', $result); + } +} diff --git a/Filter/GeoDistanceRangeFilterTest.php b/Filter/GeoDistanceRangeFilterTest.php new file mode 100644 index 0000000..dc28570 --- /dev/null +++ b/Filter/GeoDistanceRangeFilterTest.php @@ -0,0 +1,27 @@ +<?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\Filter; + +use ONGR\ElasticsearchBundle\DSL\Filter\GeoDistanceRangeFilter; + +class GeoDistanceRangeFilterTest extends \PHPUnit_Framework_TestCase +{ + /** + * Tests GetType method. + */ + public function testGetType() + { + $filter = new GeoDistanceRangeFilter('test_field', 'test_distance', 'test_location'); + $result = $filter->getType(); + $this->assertEquals('geo_distance_range', $result); + } +} diff --git a/Filter/GeoPolygonFilterTest.php b/Filter/GeoPolygonFilterTest.php new file mode 100644 index 0000000..1eae928 --- /dev/null +++ b/Filter/GeoPolygonFilterTest.php @@ -0,0 +1,27 @@ +<?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\Filter; + +use ONGR\ElasticsearchBundle\DSL\Filter\GeoPolygonFilter; + +class GeoPolygonFilterTest extends \PHPUnit_Framework_TestCase +{ + /** + * Tests GetType method. + */ + public function testGetType() + { + $filter = new GeoPolygonFilter('test_field'); + $result = $filter->getType(); + $this->assertEquals('geo_polygon', $result); + } +} diff --git a/Filter/HasChildFilterTest.php b/Filter/HasChildFilterTest.php new file mode 100644 index 0000000..b0312b7 --- /dev/null +++ b/Filter/HasChildFilterTest.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\Filter; + +use ONGR\ElasticsearchBundle\DSL\Filter\HasChildFilter; + +class HasChildFilterTest extends \PHPUnit_Framework_TestCase +{ + /** + * Tests GetType method. + */ + public function testGetType() + { + $mock = $this->getMockBuilder('ONGR\ElasticsearchBundle\DSL\BuilderInterface')->getMock(); + $filter = new HasChildFilter('test_field', $mock); + $result = $filter->getType(); + $this->assertEquals('has_child', $result); + } +} diff --git a/Filter/HasParentFilterTest.php b/Filter/HasParentFilterTest.php new file mode 100644 index 0000000..b33f1cc --- /dev/null +++ b/Filter/HasParentFilterTest.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\Filter; + +use ONGR\ElasticsearchBundle\DSL\Filter\HasParentFilter; + +class HasParentFilterTest extends \PHPUnit_Framework_TestCase +{ + /** + * Tests GetType method. + */ + public function testGetType() + { + $mock = $this->getMockBuilder('ONGR\ElasticsearchBundle\DSL\BuilderInterface')->getMock(); + $filter = new HasParentFilter('test_field', $mock); + $result = $filter->getType(); + $this->assertEquals('has_parent', $result); + } +} diff --git a/Highlight/FieldTest.php b/Highlight/FieldTest.php index df3f071..8961ca2 100644 --- a/Highlight/FieldTest.php +++ b/Highlight/FieldTest.php @@ -11,8 +11,6 @@ namespace ONGR\ElasticsearchBundle\Tests\Unit\DSL\Aggregation; -use ONGR\ElasticsearchBundle\DSL\Bool\Bool; -use ONGR\ElasticsearchBundle\DSL\Filter\MissingFilter; use ONGR\ElasticsearchBundle\DSL\Highlight\Field; /** diff --git a/Suggester/PhraseTest.php b/Suggester/PhraseTest.php index bef3d3d..946bcee 100644 --- a/Suggester/PhraseTest.php +++ b/Suggester/PhraseTest.php @@ -98,8 +98,6 @@ class PhraseTest extends \PHPUnit_Framework_TestCase { $phrase = new Phrase('', ''); $phrase->toArray(); - - $this->getFieldsData(); } /** -- GitLab