/**
  * Test for stats aggregation toArray() method.
  */
 public function testToArray()
 {
     $aggregation = new StatsAggregation('test_agg');
     $aggregation->setField('test_field');
     $expectedResult = ['agg_test_agg' => ['stats' => ['field' => 'test_field']]];
     $this->assertEquals($expectedResult, $aggregation->toArray());
 }
 /**
  * Tests if parameter can be passed to constructor.
  */
 public function testConstructor()
 {
     $aggregation = new StatsAggregation('foo', 'fieldValue', 'scriptValue');
     $this->assertSame(['stats' => ['field' => 'fieldValue', 'script' => 'scriptValue']], $aggregation->toArray());
 }