From 45033ff69b4ee23a7ba557d142ca2a9a57352318 Mon Sep 17 00:00:00 2001 From: Alexander Gorbatenko <alex@ansata.biz> Date: Wed, 14 Dec 2016 09:18:50 +0200 Subject: [PATCH] Fixed bug on nested and reverse nested aggregations. None of these aggregations requires the nested aggregations to be added. Test has also been updated. (#173) --- .../Bucketing/ReverseNestedAggregation.php | 4 ---- .../ReverseNestedAggregationTest.php | 17 ----------------- 2 files changed, 21 deletions(-) diff --git a/src/Aggregation/Bucketing/ReverseNestedAggregation.php b/src/Aggregation/Bucketing/ReverseNestedAggregation.php index 66dd066..c46c7b1 100644 --- a/src/Aggregation/Bucketing/ReverseNestedAggregation.php +++ b/src/Aggregation/Bucketing/ReverseNestedAggregation.php @@ -74,10 +74,6 @@ class ReverseNestedAggregation extends AbstractAggregation */ public function getArray() { - if (count($this->getAggregations()) == 0) { - throw new \LogicException("Reverse Nested aggregation `{$this->getName()}` has no aggregations added"); - } - $output = new \stdClass(); if ($this->getPath()) { $output = ['path' => $this->getPath()]; diff --git a/tests/Unit/Aggregation/ReverseNestedAggregationTest.php b/tests/Unit/Aggregation/ReverseNestedAggregationTest.php index a47aaeb..2c12f60 100644 --- a/tests/Unit/Aggregation/ReverseNestedAggregationTest.php +++ b/tests/Unit/Aggregation/ReverseNestedAggregationTest.php @@ -17,23 +17,6 @@ use ONGR\ElasticsearchDSL\Aggregation\TermsAggregation; class ReverseNestedAggregationTest extends \PHPUnit_Framework_TestCase { - /** - * Test for reverse_nested aggregation toArray() method exception. - * - * @expectedException \LogicException - */ - public function testToArrayException() - { - $aggregation = new ReverseNestedAggregation('test_agg'); - $aggregation->setPath('test_path'); - - $expectedResult = [ - 'reverse_nested' => ['path' => 'test_path'], - ]; - - $this->assertEquals($expectedResult, $aggregation->toArray()); - } - /** * Test for reverse_nested aggregation toArray() method exception. */ -- GitLab