/**
  * Tests cardinality aggregation using script instead of field.
  */
 public function testCardinalityWithScript()
 {
     $repository = $this->getManager()->getRepository('AcmeTestBundle:Product');
     $aggregation = new CardinalityAggregation('foo');
     $aggregation->setScript("doc['product.price'].value + ' ' + doc['product.title'].value");
     $search = $repository->createSearch()->addAggregation($aggregation);
     $result = $repository->execute($search)->getAggregations()->find('foo');
     $this->assertEquals(2, $result->getValue()['value']);
 }
 /**
  * Tests getType method.
  */
 public function testCardinallyAggregationGetType()
 {
     $aggregation = new CardinalityAggregation('foo');
     $result = $aggregation->getType();
     $this->assertEquals('cardinality', $result);
 }