From e0bfc4913b5b1698d832481e35e7ec95506b1362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?= <simonas.serlinskas@nfq.com> Date: Fri, 27 Jan 2017 11:27:53 +0200 Subject: [PATCH] refactor tests after deprecations remove --- .../Bucketing/DateRangeAggregation.php | 2 +- .../ChildrenAggregationTest.php | 4 +- .../DateHistogramAggregationTest.php | 4 +- .../DateRangeAggregationTest.php | 13 +- .../{ => Bucketing}/FilterAggregationTest.php | 6 +- .../FiltersAggregationTest.php | 4 +- .../GeoDistanceAggregationTest.php | 4 +- .../GeoHashGridAggregationTest.php | 4 +- .../{ => Bucketing}/GlobalAggregationTest.php | 4 +- .../Ipv4RangeAggregationTest.php | 5 +- .../MissingAggregationTest.php | 4 +- .../{ => Bucketing}/NestedAggregationTest.php | 6 +- .../{ => Bucketing}/RangeAggregationTest.php | 5 +- .../ReverseNestedAggregationTest.php | 7 +- .../SamplerAggregationTest.php | 6 +- .../SignificantTermsAggregationTest.php | 4 +- .../{ => Bucketing}/TermsAggregationTest.php | 5 +- .../CardinalityAggregationTest.php | 4 +- .../{ => Metric}/GeoBoundsAggregationTest.php | 5 +- .../GeoCentroidAggregationTest.php | 4 +- .../PercentileRanksAggregationTest.php | 5 +- .../PercentilesAggregationTest.php | 4 +- .../{ => Metric}/StatsAggregationTest.php | 5 +- .../{ => Metric}/TopHitsAggregationTest.php | 4 +- tests/Unit/Integration/SearchTest.php | 141 ------------------ .../AggregationsEndpointTest.php | 2 +- .../SearchEndpoint/SuggestEndpointTest.php | 6 +- tests/Unit/SearchTest.php | 8 +- tests/Unit/Suggest/CompletionSuggestTest.php | 90 ----------- tests/Unit/Suggest/TermSuggestTest.php | 69 --------- 30 files changed, 64 insertions(+), 370 deletions(-) rename tests/Unit/Aggregation/{ => Bucketing}/ChildrenAggregationTest.php (91%) rename tests/Unit/Aggregation/{ => Bucketing}/DateHistogramAggregationTest.php (91%) rename tests/Unit/Aggregation/{ => Bucketing}/DateRangeAggregationTest.php (91%) rename tests/Unit/Aggregation/{ => Bucketing}/FilterAggregationTest.php (94%) rename tests/Unit/Aggregation/{ => Bucketing}/FiltersAggregationTest.php (96%) rename tests/Unit/Aggregation/{ => Bucketing}/GeoDistanceAggregationTest.php (96%) rename tests/Unit/Aggregation/{ => Bucketing}/GeoHashGridAggregationTest.php (93%) rename tests/Unit/Aggregation/{ => Bucketing}/GlobalAggregationTest.php (93%) rename tests/Unit/Aggregation/{ => Bucketing}/Ipv4RangeAggregationTest.php (89%) rename tests/Unit/Aggregation/{ => Bucketing}/MissingAggregationTest.php (89%) rename tests/Unit/Aggregation/{ => Bucketing}/NestedAggregationTest.php (82%) rename tests/Unit/Aggregation/{ => Bucketing}/RangeAggregationTest.php (97%) rename tests/Unit/Aggregation/{ => Bucketing}/ReverseNestedAggregationTest.php (87%) rename tests/Unit/Aggregation/{ => Bucketing}/SamplerAggregationTest.php (88%) rename tests/Unit/Aggregation/{ => Bucketing}/SignificantTermsAggregationTest.php (89%) rename tests/Unit/Aggregation/{ => Bucketing}/TermsAggregationTest.php (96%) rename tests/Unit/Aggregation/{ => Metric}/CardinalityAggregationTest.php (94%) rename tests/Unit/Aggregation/{ => Metric}/GeoBoundsAggregationTest.php (90%) rename tests/Unit/Aggregation/{ => Metric}/GeoCentroidAggregationTest.php (89%) rename tests/Unit/Aggregation/{ => Metric}/PercentileRanksAggregationTest.php (91%) rename tests/Unit/Aggregation/{ => Metric}/PercentilesAggregationTest.php (90%) rename tests/Unit/Aggregation/{ => Metric}/StatsAggregationTest.php (86%) rename tests/Unit/Aggregation/{ => Metric}/TopHitsAggregationTest.php (92%) delete mode 100644 tests/Unit/Integration/SearchTest.php delete mode 100644 tests/Unit/Suggest/CompletionSuggestTest.php delete mode 100644 tests/Unit/Suggest/TermSuggestTest.php diff --git a/src/Aggregation/Bucketing/DateRangeAggregation.php b/src/Aggregation/Bucketing/DateRangeAggregation.php index 4de68cc..9b68dcb 100644 --- a/src/Aggregation/Bucketing/DateRangeAggregation.php +++ b/src/Aggregation/Bucketing/DateRangeAggregation.php @@ -74,7 +74,7 @@ class DateRangeAggregation extends AbstractAggregation * @param string|null $from * @param string|null $to * - * @return RangeAggregation + * @return $this * * @throws \LogicException */ diff --git a/tests/Unit/Aggregation/ChildrenAggregationTest.php b/tests/Unit/Aggregation/Bucketing/ChildrenAggregationTest.php similarity index 91% rename from tests/Unit/Aggregation/ChildrenAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/ChildrenAggregationTest.php index dd5cd63..3e00aca 100644 --- a/tests/Unit/Aggregation/ChildrenAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/ChildrenAggregationTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\ChildrenAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\ChildrenAggregation; /** * Unit test for children aggregation. diff --git a/tests/Unit/Aggregation/DateHistogramAggregationTest.php b/tests/Unit/Aggregation/Bucketing/DateHistogramAggregationTest.php similarity index 91% rename from tests/Unit/Aggregation/DateHistogramAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/DateHistogramAggregationTest.php index 5845f88..da340c6 100644 --- a/tests/Unit/Aggregation/DateHistogramAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/DateHistogramAggregationTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\DateHistogramAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\DateHistogramAggregation; /** * Unit test for children aggregation. diff --git a/tests/Unit/Aggregation/DateRangeAggregationTest.php b/tests/Unit/Aggregation/Bucketing/DateRangeAggregationTest.php similarity index 91% rename from tests/Unit/Aggregation/DateRangeAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/DateRangeAggregationTest.php index 03afc28..8fc3bbb 100644 --- a/tests/Unit/Aggregation/DateRangeAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/DateRangeAggregationTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\DateRangeAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\DateRangeAggregation; class DateRangeAggregationTest extends \PHPUnit_Framework_TestCase { @@ -44,10 +44,9 @@ class DateRangeAggregationTest extends \PHPUnit_Framework_TestCase */ public function testDateRangeAggregationGetArray() { - $agg = new DateRangeAggregation('foo'); + $agg = new DateRangeAggregation('foo', 'baz'); $agg->addRange(10, 20); $agg->setFormat('bar'); - $agg->setField('baz'); $result = $agg->getArray(); $expected = [ 'format' => 'bar', @@ -116,8 +115,10 @@ class DateRangeAggregationTest extends \PHPUnit_Framework_TestCase public function testDateRangeAggregationConstructor($field = null, $format = null, array $ranges = null) { /** @var DateRangeAggregation|\PHPUnit_Framework_MockObject_MockObject $aggregation */ - $aggregation = $this->getMockBuilder('ONGR\ElasticsearchDSL\Aggregation\DateRangeAggregation') - ->disableOriginalConstructor()->getMock(); + $aggregation = $this->getMockBuilder('ONGR\ElasticsearchDSL\Aggregation\Bucketing\DateRangeAggregation') + ->setMethods(['setField', 'setFormat', 'addRange']) + ->disableOriginalConstructor() + ->getMock(); $aggregation->expects($this->once())->method('setField')->with($field); $aggregation->expects($this->once())->method('setFormat')->with($format); $aggregation->expects($this->exactly(count($ranges)))->method('addRange'); diff --git a/tests/Unit/Aggregation/FilterAggregationTest.php b/tests/Unit/Aggregation/Bucketing/FilterAggregationTest.php similarity index 94% rename from tests/Unit/Aggregation/FilterAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/FilterAggregationTest.php index 9386df2..a067b94 100644 --- a/tests/Unit/Aggregation/FilterAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/FilterAggregationTest.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\FilterAggregation; -use ONGR\ElasticsearchDSL\Aggregation\HistogramAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\FilterAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\HistogramAggregation; use ONGR\ElasticsearchDSL\Query\BoolQuery; use ONGR\ElasticsearchDSL\Query\ExistsQuery; use ONGR\ElasticsearchDSL\Query\MatchAllQuery; diff --git a/tests/Unit/Aggregation/FiltersAggregationTest.php b/tests/Unit/Aggregation/Bucketing/FiltersAggregationTest.php similarity index 96% rename from tests/Unit/Aggregation/FiltersAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/FiltersAggregationTest.php index b487fd9..f5b4369 100644 --- a/tests/Unit/Aggregation/FiltersAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/FiltersAggregationTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\FiltersAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\FiltersAggregation; use ONGR\ElasticsearchDSL\BuilderInterface; /** diff --git a/tests/Unit/Aggregation/GeoDistanceAggregationTest.php b/tests/Unit/Aggregation/Bucketing/GeoDistanceAggregationTest.php similarity index 96% rename from tests/Unit/Aggregation/GeoDistanceAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/GeoDistanceAggregationTest.php index 1c5d21b..c19b1f1 100644 --- a/tests/Unit/Aggregation/GeoDistanceAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/GeoDistanceAggregationTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\GeoDistanceAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\GeoDistanceAggregation; class GeoDistanceAggregationTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Aggregation/GeoHashGridAggregationTest.php b/tests/Unit/Aggregation/Bucketing/GeoHashGridAggregationTest.php similarity index 93% rename from tests/Unit/Aggregation/GeoHashGridAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/GeoHashGridAggregationTest.php index 499d642..627a4f3 100644 --- a/tests/Unit/Aggregation/GeoHashGridAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/GeoHashGridAggregationTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\GeoHashGridAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\GeoHashGridAggregation; /** * Unit test for geohash grid aggregation. diff --git a/tests/Unit/Aggregation/GlobalAggregationTest.php b/tests/Unit/Aggregation/Bucketing/GlobalAggregationTest.php similarity index 93% rename from tests/Unit/Aggregation/GlobalAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/GlobalAggregationTest.php index 40e101e..03f5ca9 100644 --- a/tests/Unit/Aggregation/GlobalAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/GlobalAggregationTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\GlobalAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\GlobalAggregation; class GlobalAggregationTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Aggregation/Ipv4RangeAggregationTest.php b/tests/Unit/Aggregation/Bucketing/Ipv4RangeAggregationTest.php similarity index 89% rename from tests/Unit/Aggregation/Ipv4RangeAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/Ipv4RangeAggregationTest.php index 4d42c41..f6b60db 100644 --- a/tests/Unit/Aggregation/Ipv4RangeAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/Ipv4RangeAggregationTest.php @@ -9,10 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation; -use ONGR\ElasticsearchDSL\Aggregation\Ipv4RangeAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\Ipv4RangeAggregation; class Ipv4RangeAggregationTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Aggregation/MissingAggregationTest.php b/tests/Unit/Aggregation/Bucketing/MissingAggregationTest.php similarity index 89% rename from tests/Unit/Aggregation/MissingAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/MissingAggregationTest.php index ed8d222..11f6b4a 100644 --- a/tests/Unit/Aggregation/MissingAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/MissingAggregationTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\MissingAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\MissingAggregation; class MissingAggregationTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Aggregation/NestedAggregationTest.php b/tests/Unit/Aggregation/Bucketing/NestedAggregationTest.php similarity index 82% rename from tests/Unit/Aggregation/NestedAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/NestedAggregationTest.php index f24a002..51886af 100644 --- a/tests/Unit/Aggregation/NestedAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/NestedAggregationTest.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\NestedAggregation; -use ONGR\ElasticsearchDSL\Aggregation\TermsAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\NestedAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\TermsAggregation; class NestedAggregationTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Aggregation/RangeAggregationTest.php b/tests/Unit/Aggregation/Bucketing/RangeAggregationTest.php similarity index 97% rename from tests/Unit/Aggregation/RangeAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/RangeAggregationTest.php index 70ee5cc..741a0be 100644 --- a/tests/Unit/Aggregation/RangeAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/RangeAggregationTest.php @@ -9,10 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation; -use ONGR\ElasticsearchDSL\Aggregation\RangeAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\RangeAggregation; class RangeAggregationTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Aggregation/ReverseNestedAggregationTest.php b/tests/Unit/Aggregation/Bucketing/ReverseNestedAggregationTest.php similarity index 87% rename from tests/Unit/Aggregation/ReverseNestedAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/ReverseNestedAggregationTest.php index 2c12f60..e14a055 100644 --- a/tests/Unit/Aggregation/ReverseNestedAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/ReverseNestedAggregationTest.php @@ -9,11 +9,10 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation; -use ONGR\ElasticsearchDSL\Aggregation\ReverseNestedAggregation; -use ONGR\ElasticsearchDSL\Aggregation\TermsAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\ReverseNestedAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\TermsAggregation; class ReverseNestedAggregationTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Aggregation/SamplerAggregationTest.php b/tests/Unit/Aggregation/Bucketing/SamplerAggregationTest.php similarity index 88% rename from tests/Unit/Aggregation/SamplerAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/SamplerAggregationTest.php index 4ac64c8..09a9455 100644 --- a/tests/Unit/Aggregation/SamplerAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/SamplerAggregationTest.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\SamplerAggregation; -use ONGR\ElasticsearchDSL\Aggregation\TermsAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\SamplerAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\TermsAggregation; /** * Unit test for children aggregation. diff --git a/tests/Unit/Aggregation/SignificantTermsAggregationTest.php b/tests/Unit/Aggregation/Bucketing/SignificantTermsAggregationTest.php similarity index 89% rename from tests/Unit/Aggregation/SignificantTermsAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/SignificantTermsAggregationTest.php index 6f75c1b..98da346 100644 --- a/tests/Unit/Aggregation/SignificantTermsAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/SignificantTermsAggregationTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\SignificantTermsAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\SignificantTermsAggregation; /** * Unit test for children aggregation. diff --git a/tests/Unit/Aggregation/TermsAggregationTest.php b/tests/Unit/Aggregation/Bucketing/TermsAggregationTest.php similarity index 96% rename from tests/Unit/Aggregation/TermsAggregationTest.php rename to tests/Unit/Aggregation/Bucketing/TermsAggregationTest.php index 3d61d8f..ea9c826 100644 --- a/tests/Unit/Aggregation/TermsAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/TermsAggregationTest.php @@ -9,10 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation; -use ONGR\ElasticsearchDSL\Aggregation\TermsAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\TermsAggregation; class TermsAggregationTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Aggregation/CardinalityAggregationTest.php b/tests/Unit/Aggregation/Metric/CardinalityAggregationTest.php similarity index 94% rename from tests/Unit/Aggregation/CardinalityAggregationTest.php rename to tests/Unit/Aggregation/Metric/CardinalityAggregationTest.php index 4cf5d1d..14cf1b0 100644 --- a/tests/Unit/Aggregation/CardinalityAggregationTest.php +++ b/tests/Unit/Aggregation/Metric/CardinalityAggregationTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Metric\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\CardinalityAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Metric\CardinalityAggregation; /** * Unit test for cardinality aggregation. diff --git a/tests/Unit/Aggregation/GeoBoundsAggregationTest.php b/tests/Unit/Aggregation/Metric/GeoBoundsAggregationTest.php similarity index 90% rename from tests/Unit/Aggregation/GeoBoundsAggregationTest.php rename to tests/Unit/Aggregation/Metric/GeoBoundsAggregationTest.php index 505b912..02984bf 100644 --- a/tests/Unit/Aggregation/GeoBoundsAggregationTest.php +++ b/tests/Unit/Aggregation/Metric/GeoBoundsAggregationTest.php @@ -9,10 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Metric\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation; -use ONGR\ElasticsearchDSL\Aggregation\GeoBoundsAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Metric\GeoBoundsAggregation; /** * Unit test for geo bounds aggregation. diff --git a/tests/Unit/Aggregation/GeoCentroidAggregationTest.php b/tests/Unit/Aggregation/Metric/GeoCentroidAggregationTest.php similarity index 89% rename from tests/Unit/Aggregation/GeoCentroidAggregationTest.php rename to tests/Unit/Aggregation/Metric/GeoCentroidAggregationTest.php index a28a16c..4f263e5 100644 --- a/tests/Unit/Aggregation/GeoCentroidAggregationTest.php +++ b/tests/Unit/Aggregation/Metric/GeoCentroidAggregationTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Metric\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\GeoCentroidAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Metric\GeoCentroidAggregation; /** * Unit test for children aggregation. diff --git a/tests/Unit/Aggregation/PercentileRanksAggregationTest.php b/tests/Unit/Aggregation/Metric/PercentileRanksAggregationTest.php similarity index 91% rename from tests/Unit/Aggregation/PercentileRanksAggregationTest.php rename to tests/Unit/Aggregation/Metric/PercentileRanksAggregationTest.php index 8c71bbd..dd3ae46 100644 --- a/tests/Unit/Aggregation/PercentileRanksAggregationTest.php +++ b/tests/Unit/Aggregation/Metric/PercentileRanksAggregationTest.php @@ -9,10 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Metric\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation; -use ONGR\ElasticsearchDSL\Aggregation\PercentileRanksAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Metric\PercentileRanksAggregation; /** * Percentile ranks aggregation unit tests. diff --git a/tests/Unit/Aggregation/PercentilesAggregationTest.php b/tests/Unit/Aggregation/Metric/PercentilesAggregationTest.php similarity index 90% rename from tests/Unit/Aggregation/PercentilesAggregationTest.php rename to tests/Unit/Aggregation/Metric/PercentilesAggregationTest.php index a7c4fff..b7cbec2 100644 --- a/tests/Unit/Aggregation/PercentilesAggregationTest.php +++ b/tests/Unit/Aggregation/Metric/PercentilesAggregationTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Metric\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\PercentilesAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Metric\PercentilesAggregation; class PercentilesAggregationTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Aggregation/StatsAggregationTest.php b/tests/Unit/Aggregation/Metric/StatsAggregationTest.php similarity index 86% rename from tests/Unit/Aggregation/StatsAggregationTest.php rename to tests/Unit/Aggregation/Metric/StatsAggregationTest.php index 4d98696..794bb80 100644 --- a/tests/Unit/Aggregation/StatsAggregationTest.php +++ b/tests/Unit/Aggregation/Metric/StatsAggregationTest.php @@ -9,10 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Metric\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation; -use ONGR\ElasticsearchDSL\Aggregation\StatsAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Metric\StatsAggregation; class StatsAggregationTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Aggregation/TopHitsAggregationTest.php b/tests/Unit/Aggregation/Metric/TopHitsAggregationTest.php similarity index 92% rename from tests/Unit/Aggregation/TopHitsAggregationTest.php rename to tests/Unit/Aggregation/Metric/TopHitsAggregationTest.php index 127e02b..53f6294 100644 --- a/tests/Unit/Aggregation/TopHitsAggregationTest.php +++ b/tests/Unit/Aggregation/Metric/TopHitsAggregationTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace ONGR\ElasticsearchDSL\Tests\Unit\Aggregation; +namespace ONGR\ElasticsearchDSL\Tests\Unit\Metric\Aggregation; -use ONGR\ElasticsearchDSL\Aggregation\TopHitsAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Metric\TopHitsAggregation; use ONGR\ElasticsearchDSL\Sort\FieldSort; /** diff --git a/tests/Unit/Integration/SearchTest.php b/tests/Unit/Integration/SearchTest.php deleted file mode 100644 index fb2c6e3..0000000 --- a/tests/Unit/Integration/SearchTest.php +++ /dev/null @@ -1,141 +0,0 @@ -<?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\ElasticsearchDSL\Tests\Unit\Aggregation\Integration; - -use ONGR\ElasticsearchDSL\Aggregation\FiltersAggregation; -use ONGR\ElasticsearchDSL\Aggregation\HistogramAggregation; -use ONGR\ElasticsearchDSL\Query\TermQuery; -use ONGR\ElasticsearchDSL\Search; -use PHPUnit_Framework_TestCase; - -/** - * Tests integration of examples from the documentation. - */ -class SearchTest extends PHPUnit_Framework_TestCase -{ - /** - * Tests integration of the FiltersAggregation named example from the documentation. - * - * @link https://github.com/ongr-io/ElasticsearchDSL/blob/master/docs/Aggregation/Filters.md#named-example - */ - public function testFiltersAggregationNamedExample() - { - $errorTermFilter = new TermQuery('body', 'error'); - $warningTermFilter = new TermQuery('body', 'warning'); - - $histogramAggregation = new HistogramAggregation('monthly', 'timestamp'); - $histogramAggregation->setInterval('1M'); - - $filterAggregation = new FiltersAggregation( - 'grades_stats', - [ - 'error' => $errorTermFilter, - 'warning' => $warningTermFilter, - ] - ); - $filterAggregation->addAggregation($histogramAggregation); - - $search = new Search(); - $search->addAggregation($filterAggregation); - - $this->assertSame( - [ - 'aggregations' => [ - 'grades_stats' => [ - 'filters' => [ - 'filters' => [ - 'error' => [ - 'term' => [ - 'body' => 'error', - ], - ], - 'warning' => [ - 'term' => [ - 'body' => 'warning', - ], - ], - ], - ], - 'aggregations' => [ - 'monthly' => [ - 'histogram' => [ - 'field' => 'timestamp', - 'interval' => '1M', - ], - ], - ], - ], - ], - ], - $search->toArray() - ); - } - - /** - * Tests integration of the FiltersAggregation anonymous example from the documentation. - * - * @link https://github.com/ongr-io/ElasticsearchDSL/blob/master/docs/Aggregation/Filters.md#anonymous-example - */ - public function testFiltersAggregationAnonymousExample() - { - $errorTermFilter = new TermQuery('body', 'error'); - $warningTermFilter = new TermQuery('body', 'warning'); - - $histogramAggregation = new HistogramAggregation('monthly', 'timestamp'); - $histogramAggregation->setInterval('1M'); - - $filterAggregation = new FiltersAggregation( - 'grades_stats', - [ - 'error' => $errorTermFilter, - 'warning' => $warningTermFilter, - ], - true - ); - $filterAggregation->addAggregation($histogramAggregation); - - $search = new Search(); - $search->addAggregation($filterAggregation); - - $this->assertSame( - [ - 'aggregations' => [ - 'grades_stats' => [ - 'filters' => [ - 'filters' => [ - [ - 'term' => [ - 'body' => 'error', - ], - ], - [ - 'term' => [ - 'body' => 'warning', - ], - ], - ], - ], - 'aggregations' => [ - 'monthly' => [ - 'histogram' => [ - 'field' => 'timestamp', - 'interval' => '1M', - ], - ], - ], - ], - ], - ], - $search->toArray() - ); - } -} diff --git a/tests/Unit/SearchEndpoint/AggregationsEndpointTest.php b/tests/Unit/SearchEndpoint/AggregationsEndpointTest.php index a61dba8..d08a334 100644 --- a/tests/Unit/SearchEndpoint/AggregationsEndpointTest.php +++ b/tests/Unit/SearchEndpoint/AggregationsEndpointTest.php @@ -11,7 +11,7 @@ namespace ONGR\ElasticsearchDSL\Tests\Unit\Unit\SearchEndpoint; -use ONGR\ElasticsearchDSL\Aggregation\MissingAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Bucketing\MissingAggregation; use ONGR\ElasticsearchDSL\SearchEndpoint\AggregationsEndpoint; /** diff --git a/tests/Unit/SearchEndpoint/SuggestEndpointTest.php b/tests/Unit/SearchEndpoint/SuggestEndpointTest.php index e6e1cca..f71884f 100644 --- a/tests/Unit/SearchEndpoint/SuggestEndpointTest.php +++ b/tests/Unit/SearchEndpoint/SuggestEndpointTest.php @@ -12,7 +12,7 @@ namespace ONGR\ElasticsearchDSL\Tests\Unit\Unit\SearchEndpoint; use ONGR\ElasticsearchDSL\SearchEndpoint\SuggestEndpoint; -use ONGR\ElasticsearchDSL\Suggest\TermSuggest; +use ONGR\ElasticsearchDSL\Suggest\Suggest; use PHPUnit_Framework_MockObject_MockObject as MockObject; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; @@ -33,7 +33,7 @@ class SuggestEndpointTest extends \PHPUnit_Framework_TestCase { $suggestName = 'acme_suggest'; $text = 'foo'; - $suggest = new TermSuggest($suggestName, $text); + $suggest = new Suggest($suggestName, 'text', $text, 'acme'); $endpoint = new SuggestEndpoint(); $endpoint->add($suggest, $suggestName); $builders = $endpoint->getAll(); @@ -54,7 +54,7 @@ class SuggestEndpointTest extends \PHPUnit_Framework_TestCase 'Symfony\Component\Serializer\Normalizer\NormalizerInterface' ); - $suggest = new TermSuggest('foo', 'bar'); + $suggest = new Suggest('foo', 'bar', 'acme', 'foo'); $instance->add($suggest); $this->assertEquals( diff --git a/tests/Unit/SearchTest.php b/tests/Unit/SearchTest.php index aca6544..a6c9db1 100644 --- a/tests/Unit/SearchTest.php +++ b/tests/Unit/SearchTest.php @@ -15,7 +15,7 @@ use ONGR\ElasticsearchDSL\Query\ExistsQuery; use ONGR\ElasticsearchDSL\Query\TermQuery; use ONGR\ElasticsearchDSL\Search; use ONGR\ElasticsearchDSL\Sort\FieldSort; -use ONGR\ElasticsearchDSL\Suggest\TermSuggest; +use ONGR\ElasticsearchDSL\Suggest\Suggest; /** * Test for Search. @@ -266,7 +266,7 @@ class SearchTest extends \PHPUnit_Framework_TestCase ], ], ], - (new Search())->addSuggest(new TermSuggest('foo', 'bar', ['field' => 'title', 'size' => 2])), + (new Search())->addSuggest(new Suggest('foo', 'term', 'bar', 'title', ['size' => 2])), ]; $cases['multiple_suggests'] = [ @@ -283,8 +283,8 @@ class SearchTest extends \PHPUnit_Framework_TestCase ], ], (new Search()) - ->addSuggest(new TermSuggest('foo', 'bar', ['field' => 'title', 'size' => 2])) - ->addSuggest(new TermSuggest('bar', 'foo', ['field' => 'title', 'size' => 2])), + ->addSuggest(new Suggest('foo', 'term', 'bar', 'title', ['size' => 2])) + ->addSuggest(new Suggest('bar', 'term', 'foo', 'title', ['size' => 2])), ]; return $cases; diff --git a/tests/Unit/Suggest/CompletionSuggestTest.php b/tests/Unit/Suggest/CompletionSuggestTest.php deleted file mode 100644 index 066ae5b..0000000 --- a/tests/Unit/Suggest/CompletionSuggestTest.php +++ /dev/null @@ -1,90 +0,0 @@ -<?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\ElasticsearchDSL\Tests\Unit\Suggest; - -use ONGR\ElasticsearchDSL\Suggest\CompletionSuggest; - -class CompletionSuggestTest extends \PHPUnit_Framework_TestCase -{ - /** - * Tests getType method. - */ - public function testSuggestGetType() - { - $suggest = new CompletionSuggest('foo', 'bar'); - $result = $suggest->getType(); - $this->assertEquals('completion_suggest', $result); - } - - /** - * Tests toArray() method. - */ - public function testSuggestWithoutFieldAndSize() - { - // Case #1 suggest without field and size params. - $suggest = new CompletionSuggest('foo', 'bar'); - $expected = ['foo' => [ - 'text' => 'bar', - 'completion' => [ - 'field' => 'suggest', - 'size' => 3, - ], - ]]; - $this->assertEquals($expected, $suggest->toArray()); - } - - /** - * Tests toArray() method. - */ - public function testToArray() - { - $suggest = new CompletionSuggest( - 'foo', - 'bar', - [ - 'size' => 5, - 'field' => 'title', - 'fuzzy' => ['fuzziness' => 2] - ] - ); - $expected = ['foo' => [ - 'text' => 'bar', - 'completion' => [ - 'field' => 'title', - 'size' => 5, - 'fuzzy' => ['fuzziness' => 2] - ], - ]]; - $this->assertEquals($expected, $suggest->toArray()); - } - - public function testToArrayWithoutField() - { - $suggest = new CompletionSuggest( - 'foo', - 'bar', - [ - 'size' => 5, - 'fuzzy' => ['fuzziness' => 2] - ] - ); - $expected = ['foo' => [ - 'text' => 'bar', - 'completion' => [ - 'field' => 'suggest', - 'size' => 5, - 'fuzzy' => ['fuzziness' => 2] - ], - ]]; - $this->assertEquals($expected, $suggest->toArray()); - } -} diff --git a/tests/Unit/Suggest/TermSuggestTest.php b/tests/Unit/Suggest/TermSuggestTest.php deleted file mode 100644 index 6492937..0000000 --- a/tests/Unit/Suggest/TermSuggestTest.php +++ /dev/null @@ -1,69 +0,0 @@ -<?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\ElasticsearchDSL\Tests\Unit\Suggest; - -use ONGR\ElasticsearchDSL\Suggest\TermSuggest; - -class TermSuggestTest extends \PHPUnit_Framework_TestCase -{ - /** - * Tests getType method. - */ - public function testSuggestGetType() - { - $suggest = new TermSuggest('foo', 'bar'); - $result = $suggest->getType(); - $this->assertEquals('term_suggest', $result); - } - - /** - * Tests toArray() method. - */ - public function testSuggestWithoutFieldAndSize() - { - // Case #1 suggest without field and size params. - $suggest = new TermSuggest('foo', 'bar'); - $expected = ['foo' => [ - 'text' => 'bar', - 'term' => [ - 'field' => '_all', - 'size' => 3, - ], - ]]; - $this->assertEquals($expected, $suggest->toArray()); - } - - /** - * Tests toArray() method. - */ - public function testToArray() - { - $suggest = new TermSuggest( - 'foo', - 'bar', - [ - 'size' => 5, - 'field' => 'title', - 'analyzer' => 'whitespace', - ] - ); - $expected = ['foo' => [ - 'text' => 'bar', - 'term' => [ - 'field' => 'title', - 'size' => 5, - 'analyzer' => 'whitespace', - ], - ]]; - $this->assertEquals($expected, $suggest->toArray()); - } -} -- GitLab