/**
  * Test toArray method.
  */
 public function testToArray()
 {
     $this->agg->setField('bar');
     $this->agg->setValues(['bar']);
     $this->assertSame(['agg_foo' => ['percentile_ranks' => ['field' => 'bar', 'values' => ['bar']]]], $this->agg->toArray());
 }
 /**
  * Tests exception when only field is set.
  *
  * @expectedException \LogicException
  */
 public function testIfExceptionIsThrownWhenFieldSetAndValueNotSet()
 {
     $this->agg->setField('bar');
     $this->agg->toArray();
 }