/**
  * Test for nested aggregation toArray() method exception.
  */
 public function testToArray()
 {
     $termAggregation = new TermsAggregation('acme');
     $aggregation = new NestedAggregation('test_nested_agg');
     $aggregation->setPath('test_path');
     $aggregation->addAggregation($termAggregation);
     $expectedResult = ['nested' => ['path' => 'test_path'], 'aggregations' => [$termAggregation->getName() => $termAggregation->toArray()]];
     $this->assertEquals($expectedResult, $aggregation->toArray());
 }
 /**
  * Test for nested aggregation toArray() method exception.
  */
 public function testToArray()
 {
     $termMock = $this->getMockBuilder('ONGR\\ElasticsearchDSL\\Aggregation\\TermsAggregation')->disableOriginalConstructor()->getMock();
     $termMock->expects($this->once())->method('toArray')->will($this->returnValue(['terms' => []]));
     $aggregation = new NestedAggregation('test_nested_agg');
     $aggregation->setPath('test_path');
     $aggregation->addAggregation($termMock);
     $expectedResult = ['agg_test_nested_agg' => ['nested' => ['path' => 'test_path'], 'aggregations' => ['terms' => []]]];
     $this->assertEquals($expectedResult, $aggregation->toArray());
 }