diff --git a/src/Query/Span/SpanContainingQuery.php b/src/Query/Span/SpanContainingQuery.php index 233d2727a3a010fd15269fed95cda08e0435b15b..eaf149657eade62e363a521f1fd9388a5bfbfeef 100644 --- a/src/Query/Span/SpanContainingQuery.php +++ b/src/Query/Span/SpanContainingQuery.php @@ -11,6 +11,8 @@ namespace ONGR\ElasticsearchDSL\Query\Span; +use ONGR\ElasticsearchDSL\ParametersTrait; + /** * Elasticsearch span containing query. * @@ -18,26 +20,60 @@ namespace ONGR\ElasticsearchDSL\Query\Span; */ class SpanContainingQuery implements SpanQueryInterface { + use ParametersTrait; + /** * @param SpanQueryInterface */ - private $big; + private $little; /** * @param SpanQueryInterface */ - private $little; + private $big; /** + * @param SpanQueryInterface $little * @param SpanQueryInterface $big + */ + public function __construct(SpanQueryInterface $little, SpanQueryInterface $big) + { + $this->setLittle($little); + $this->setBig($big); + } + + /** + * @return SpanQueryInterface + */ + public function getLittle() + { + return $this->little; + } + + /** * @param SpanQueryInterface $little */ - public function __construct(SpanQueryInterface $big, SpanQueryInterface $little) + public function setLittle(SpanQueryInterface $little) { - $this->big = $big; $this->little = $little; } + /** + * @return SpanQueryInterface + */ + public function getBig() + { + return $this->big; + } + + /** + * @param SpanQueryInterface $big + */ + public function setBig(SpanQueryInterface $big) + { + $this->big = $big; + } + /** * {@inheritdoc} */ @@ -51,11 +87,13 @@ class SpanContainingQuery implements SpanQueryInterface */ public function toArray() { - $out = [ - 'little' => $this->little->toArray(), - 'big' => $this->big->toArray(), + $output = [ + 'little' => $this->getLittle()->toArray(), + 'big' => $this->getBig()->toArray(), ]; - return [$this->getType() => $out]; + $output = $this->processArray($output); + + return [$this->getType() => $output]; } } diff --git a/tests/Query/Span/SpanContainingQueryTest.php b/tests/Query/Span/SpanContainingQueryTest.php index 328ffc3b838f05702a3f01868f5d19dc863cc256..d3a934b7a703a1879d3e3c9ce5d630cf785227bd 100644 --- a/tests/Query/Span/SpanContainingQueryTest.php +++ b/tests/Query/Span/SpanContainingQueryTest.php @@ -24,16 +24,16 @@ class SpanContainingQueryTest extends \PHPUnit_Framework_TestCase public function testToArray() { $query = new SpanContainingQuery( - $this->getSpanQueryMack('foo'), - $this->getSpanQueryMack('bar') + $this->getSpanQueryMock('foo'), + $this->getSpanQueryMock('bar') ); $result = [ 'span_containing' => [ 'little' => [ - 'span_term' => ['user' => 'bar'], + 'span_term' => ['user' => 'foo'], ], 'big' => [ - 'span_term' => ['user' => 'foo'], + 'span_term' => ['user' => 'bar'], ], ], ]; @@ -45,7 +45,7 @@ class SpanContainingQueryTest extends \PHPUnit_Framework_TestCase * * @returns \PHPUnit_Framework_MockObject_MockObject */ - private function getSpanQueryMack($value) + private function getSpanQueryMock($value) { $mock = $this->getMock('ONGR\ElasticsearchDSL\Query\Span\SpanQueryInterface'); $mock