/**
  * Set a script for this aggregation
  * @param string|Script $script
  * @return AbstractSimpleAggregation
  */
 public function setScript($script)
 {
     if ($script instanceof Script) {
         $this->setParam('params', $script->getParams());
         $script = $script->getScript();
     }
     return $this->setParam('script', $script);
 }
 /**
  * @group unit
  */
 public function testConstructor()
 {
     $value = "_score * doc['my_numeric_field'].value";
     $script = new Script($value);
     $expected = array('script' => $value);
     $this->assertEquals($value, $script->getScript());
     $this->assertEquals($expected, $script->toArray());
     $params = array('param1' => 'one', 'param2' => 10);
     $script = new Script($value, $params);
     $expected = array('script' => $value, 'params' => $params);
     $this->assertEquals($value, $script->getScript());
     $this->assertEquals($params, $script->getParams());
     $this->assertEquals($expected, $script->toArray());
     $lang = 'mvel';
     $script = new Script($value, $params, $lang);
     $expected = array('script' => $value, 'params' => $params, 'lang' => $lang);
     $this->assertEquals($value, $script->getScript());
     $this->assertEquals($params, $script->getParams());
     $this->assertEquals($lang, $script->getLang());
     $this->assertEquals($expected, $script->toArray());
 }