/**
  * Tests getArray method.
  */
 public function testChildrenAggregationGetArray()
 {
     $mock = $this->getMockBuilder('ONGR\\ElasticsearchBundle\\DSL\\Aggregation\\AbstractAggregation')->disableOriginalConstructor()->getMockForAbstractClass();
     $aggregation = new ChildrenAggregation('foo');
     $aggregation->addAggregation($mock);
     $aggregation->setChildren('question');
     $result = $aggregation->getArray();
     $expected = ['type' => 'question'];
     $this->assertEquals($expected, $result);
 }
 /**
  * Test for children aggregation.
  *
  * @param AbstractAggregation $aggregation
  * @param array               $expectedResult
  * @param array               $mapping
  *
  * @dataProvider getChildrenAggregationData
  */
 public function testChildrenAggregation($aggregation, $expectedResult, $mapping)
 {
     /** @var Repository $repo */
     $repo = $this->getManager('default', true, $mapping)->getRepository('AcmeTestBundle:Product');
     $childrenAggregation = new ChildrenAggregation('test_children_agg');
     $childrenAggregation->setChildren('comment');
     $childrenAggregation->addAggregation($aggregation);
     $search = $repo->createSearch()->addAggregation($childrenAggregation);
     $results = $repo->execute($search, Repository::RESULTS_RAW);
     $this->assertArrayHasKey('aggregations', $results);
     $this->assertArraySubset($expectedResult, $results['aggregations']['agg_test_children_agg']);
 }