Skip to content
Snippets Groups Projects
Commit 8eb502a2 authored by Mantas's avatar Mantas
Browse files

added getters and setters and parameter trait

parent 65c115d3
No related branches found
No related tags found
No related merge requests found
......@@ -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];
}
}
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment