Skip to content
Snippets Groups Projects
Commit e2ac23ae authored by Aivaras Gotovskis's avatar Aivaras Gotovskis
Browse files

Add parameters to nested query.

parent 9582224e
No related branches found
No related tags found
No related merge requests found
......@@ -12,12 +12,15 @@
namespace ONGR\ElasticsearchDSL\Query;
use ONGR\ElasticsearchDSL\BuilderInterface;
use ONGR\ElasticsearchDSL\ParametersTrait;
/**
* Elasticsearch nested query class.
*/
class NestedQuery implements BuilderInterface
{
use ParametersTrait;
/**
* @var string
*/
......@@ -51,11 +54,13 @@ class NestedQuery implements BuilderInterface
*/
public function toArray()
{
return [
'path' => $this->path,
'query' => [
$this->query->getType() => $this->query->toArray(),
],
];
return $this->processArray(
[
'path' => $this->path,
'query' => [
$this->query->getType() => $this->query->toArray(),
],
]
);
}
}
......@@ -40,4 +40,21 @@ class NestedQueryTest extends \PHPUnit_Framework_TestCase
$query = new NestedQuery('test_path', $missingFilterMock);
$this->assertEquals($result, $query->toArray());
}
/**
* Tests if Nested Query has parameters.
*/
public function testParameters()
{
$nestedQuery = $this->getMockBuilder('ONGR\ElasticsearchDSL\Query\NestedQuery')
->disableOriginalConstructor()
->setMethods(null)
->getMock();
$this->assertTrue(method_exists($nestedQuery, 'addParameter'), 'Nested query must have addParameter method');
$this->assertTrue(method_exists($nestedQuery, 'setParameters'), 'Nested query must have setParameters method');
$this->assertTrue(method_exists($nestedQuery, 'getParameters'), 'Nested query must have getParameters method');
$this->assertTrue(method_exists($nestedQuery, 'hasParameter'), 'Nested query must have hasParameter method');
$this->assertTrue(method_exists($nestedQuery, 'getParameter'), 'Nested query must have getParameter method');
}
}
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