/**
  * 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 value is set.
  *
  * @expectedException \LogicException
  */
 public function testIfExceptionIsThrownWhenScriptSetAndValueNotSet()
 {
     $this->agg->setScript('bar');
     $this->agg->toArray();
 }