public function testSumAggregation()
 {
     $agg = new Sum("sum");
     $agg->setField("price");
     $query = new Query();
     $query->addAggregation($agg);
     $results = $this->_index->search($query)->getAggregation("sum");
     $this->assertEquals(5 + 8 + 1 + 3, $results['value']);
 }
Exemplo n.º 2
0
 /**
  * @group functional
  */
 public function testSumAggregation()
 {
     $agg = new Sum('sum');
     $agg->setField('price');
     $query = new Query();
     $query->addAggregation($agg);
     $results = $this->_getIndexForTest()->search($query)->getAggregation('sum');
     $this->assertEquals(5 + 8 + 1 + 3, $results['value']);
 }
Exemplo n.º 3
0
 /**
  * @group unit
  */
 public function testSetScript()
 {
     $aggregation = 'sum';
     $string = "doc['price'].value";
     $params = array('param1' => 'one', 'param2' => 1);
     $lang = 'groovy';
     $agg = new Sum($aggregation);
     $script = new Script($string, $params, $lang);
     $agg->setScript($script);
     $array = $agg->toArray();
     $expected = array($aggregation => array('script' => $string, 'params' => $params, 'lang' => $lang));
     $this->assertEquals($expected, $array);
 }