/**
  * Tests toArray method.
  *
  * @param string $parentType   Parent type.
  * @param string $queryType    Type of query for mock query class.
  * @param array  $queryToArray Return value for mock query class toArray method.
  * @param array  $parameters   Optional parameters.
  * @param string $dslType      Filter or query.
  * @param array  $expected     Expected result.
  *
  * @dataProvider getArrayDataProvider
  */
 public function testToArray($parentType, $queryType, $queryToArray, $parameters, $dslType, $expected)
 {
     $mockQuery = $this->getMockBuilder('ONGR\\ElasticsearchBundle\\DSL\\BuilderInterface')->getMock();
     $mockQuery->expects($this->once())->method('getType')->will($this->returnValue($queryType));
     $mockQuery->expects($this->once())->method('toArray')->will($this->returnValue($queryToArray));
     $filter = new HasParentFilter($parentType, $mockQuery, $parameters);
     $filter->setDslType($dslType);
     $result = $filter->toArray();
     $this->assertEquals($expected, $result);
 }
 /**
  * Data provider for testHasChildQuery().
  *
  * @return array
  */
 public function getTestHasParentFilterData()
 {
     $out = [];
     $testData = $this->getDataArray();
     $mapping = ['product' => ['properties' => ['title' => ['type' => 'string']]], 'comment' => ['_parent' => ['type' => 'product'], '_routing' => ['required' => true], 'properties' => ['sub_title' => ['type' => 'string']]]];
     unset($testData['default']['comment'][0]['_parent']);
     // Case #0: Test with data.
     $filter = new HasParentFilter('product', new TermFilter('title', 'foo'));
     $out[] = [$filter, [$testData['default']['comment'][0]], $mapping];
     // Case #1: Test with no data.
     $filter = new HasParentFilter('product', new TermQuery('title', 'nofoo'));
     $filter->setDslType('query');
     $out[] = [$filter, [], $mapping];
     return $out;
 }